Achint Mehta wrote:
> Hi David/Sarah,
> 
> Thanks for your response.
> 
> So If I have to include all the tokens in SPECIAL_STRING, then I assume that
> SPECIAL_STRING has to be changed from lexer to parser rule.

Yes, exactly.

You may find as you extend the grammar that you also need non-alphanumeric
tokens, in which case only alphanumeric tokens (called "reserved words" in
most computer languages) should go in what is now 'tokenset'. So I would
call it something like 'reservedWord' instead.

> Based on your and Joe's suggestion I have modified the grammar as following:
> ----------------------------------------------------------
> grammar sample_parser;
> 
> options
> {
>    language=C;
> }
> tokens{
> T_VERSION='VERSION';
> T_COUNT='COUNT';
> }
> 
> requestline : T_VERSION '=' special_string (NEWLINE)?;
> 
> special_string:WORD | tokenset;
> tokenset: T_VERSION | T_COUNT;
> fragment
> CHAR: (('a'..'z')|('A'..'Z'));
> fragment
> DIGIT: ('0'..'9');
> WORD: (CHAR|DIGIT)+;
> NEWLINE:('\r')? '\n';
> ------------------------------------------------------------

-- 
David-Sarah Hopwood  ⚥  http://davidsarah.livejournal.com


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/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
-~----------~----~----~----~------~----~------~--~---

Reply via email to