sql-script(1) : lexer error 3 : 1:1: Tokens : ( EQUAL_OPERATOR | ASSIGN_OPERATOR | ... <all my keywords here> ... DOUBLE_QUOTED_TEXT | SINGLE_QUOTED_TEXT | COMMENT_RULE );, at offset 10(end of input).
This doesn't tell me anything wrt to my identifier rule. Error 3 comes before the lexer goes into recovery mode, right?
(line: 1, offset: 0, nil) nil
(line: 1, offset: 0, length: 6, index: 0, SELECT_SYMBOL [686]) select
(line: 0, offset: 0, length: 1, index: 0, <invalid> [0]) Tree Error Node
(line: 1, offset: 0, length: 1, index: 0, ANTLR3_TOKEN_EOF [-1]) <EOF>
With error:
2 errors found
sql-script(1) : lexer error 1 : Unexpected character, at offset 10(end of input).
This indicates a poorly specified lexer RULE
or unterminated input element such as: "STRING["]
: syntax error...
-end of input-(1) : parser error 3 : , at offset 0, at <EOF> unexpected input
4) Numbers are no longer automatically lex'ed correctly.
Input like "select 1" gives me now:
(line: 1, offset: 0, nil) nil
(line: 1, offset: 0, length: 6, index: 0, SELECT_SYMBOL [686]) select
(line: 1, offset: 0, length: 1, index: 0, SELECT_EXPR_TOKEN [685]) SELECT_EXPR_TOKEN
(line: 1, offset: 0, length: 1, index: 0, EXPRESSION_TOKEN [496]) EXPRESSION_TOKEN
(line: 1, offset: 0, length: 1, index: 0, COLUMN_REF_TOKEN [425]) COLUMN_REF_TOKEN
(line: 1, offset: 7, length: 1, index: 2, IDENTIFIER [528]) 1
(line: 1, offset: 0, length: 1, index: 0, ANTLR3_TOKEN_EOF [-1]) <EOF>
while it originally was:
(line: 1, offset: 0, nil) nil
(line: 1, offset: 0, length: 6, index: 0, SELECT_SYMBOL [687]) select
(line: 1, offset: 0, length: 1, index: 0, SELECT_EXPR_TOKEN [686]) SELECT_EXPR_TOKEN
(line: 1, offset: 0, length: 1, index: 0, EXPRESSION_TOKEN [496]) EXPRESSION_TOKEN
(line: 1, offset: 7, length: 1, index: 2, INT_NUMBER [549]) 1
(line: 1, offset: 0, length: 1, index: 0, ANTLR3_TOKEN_EOF [-1]) <EOF>
I tried different predicate types (e.g. gated semantic predicate) but the outcome was always the same, even though the generated code was significantly different.
For completeness, here's what I used last for testing:
IDENTIFIER:
{ isIDStart(ctx) }? => . { consumeID(ctx); }
|
;
and the C code:
ANTLR3_BOOLEAN isIDStart(pMySQLLexer ctx)
{
ANTLR3_UINT32 input = LA(1);