@Override
    public IPrimitiveResult scan(PrimitiveContext context) throws SynException {
        if (context.current != '\'' && context.current != '"') {
            //Not a string literal. Return.
            return null;
        }
        
        //Out of memory error protection.
        context.setMaxBufferLength(MAX_STRING_LENGTH);
        
        //Scan quoted characters.
        int quote = context.current;
        context.next();
        while (context.current != quote
                && context.current != -1
                && context.current != '\n'
                && context.current != '\r')
        {
            if (context.current == '\\') {
                context.next();
                scanEscapeSequence(context);
            } else {
                context.append();
                context.next();
            }
        }
        
        if (context.current != quote) {
            //No closing quote.
            String message = context.current == -1
                    ? "String literal is not closed before the end of the file"
                    : "String literal is not closed before the end of the line";
            
            TextPos pos = context.getCurrentCharPos();
            throw new SynLexicalException(pos, message);
        }
        
        //Skip the closing quote.
        context.next();

        value = context.getString();
        return primitiveResult;
    }