David-Sarah Hopwood wrote:
The grammar above is not correct. Here is one that works as you want. Note that the keyword token is defined as a lexer rule (avoid the tokens { } section as it will confuse you) and is listed first in the lexer rule order. You can conflate CHAR into the SPECIAL_STRING lexer rule and avoid a method/function call at runtime:Benoit Fouletier wrote: grammar t; requestline : ANTLRTOKEN WHITESPACE SPECIAL_STRING EOF; ANTLRTOKEN : 'ANTLR'; SPECIAL_STRING : (CHAR | '=' | '.' | '-' | '@' )+ ; WHITESPACE : ( '\t' | ' ' | '\u000C' )+; NEWLINE : ('\r')? '\n'; fragment CHAR : (('a'..'z')|('A'..'Z')); Jim --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~--- |
List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
