At 19:17 10/10/2008, Juergen Weber wrote:
>Yes, I saw in the debugger that the token IDs did not match.
>But why would 'NONE' get a token ID and why would ANTLR try
>to match the ID?
This:
r : r1 | r2;
r1 : 'DELUSER' ('ALL' | 'NONE');
r2 : 'REMOVE' id;
id : ID | QUOTEDSTRING;
ID : ... ;
QUOTEDSTRING : ...;
is essentially identical to this:
r : r1 | r2;
r1 : T16 (T17 | T18);
r2 : T19 id;
id : ID | QUOTEDSTRING;
T16 : 'DELUSER';
T17 : 'ALL';
T18 : 'NONE';
T19 : 'REMOVE';
ID : ... ;
QUOTEDSTRING : ...;
Once you realise that, the next step to understanding how ANTLR
works is to look at just the lexer rules alone (forget that the
parser rules are even there!) to see how ANTLR tokenises the
input. Only *after* the lexer has completely finished and
tokenised everything does the parser start processing its first
rule.
In general I think people (especially newcomers to ANTLR) should
avoid using quoted literals in parser rules. It gets you into bad
habits and makes it too easy to forget (or not realise) how things
work under the covers :)
List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org:8080/mailman/options/antlr-interest/your-email-address
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---