> -----Original Message-----
> From: [email protected] [mailto:antlr-interest-
> [email protected]] On Behalf Of Sameh W. Zaky
> Sent: Monday, May 17, 2010 7:33 AM
> To: [email protected]
> Subject: [antlr-interest] ANTLR Two Simple Questions :-)
>
> Dear All,
>
> I am a Masters student, I use Java, and I am trying to make my parser
> with
> the help of ANTLR. I need this for my Masters project.
> I am using ANTLRWorks 1.3.1
> I had 2 questions concerning it:
>
> 1) How can I have a dynamic token name (or dynamic lexer)?
> *Example: (the symbol SERVICE, will have different token values,
> depending
> on certain list (array) whose contents change over time)*
Match the possible sequences generally, then change the token type if the
strings match your dynamic list:
fragment SERVICE : ;
ID : ('a'..'z')+
{
If (myLookupMethod($text)) { $type = SERVICE; }
}
;
So the token ID will be returned if the matched text is not in your list and
the token SERVICE will be returned if it is.
> 2) Given a certain grammar, how can I (or: is it possible to) get the
> list
> of all possible next tokens?
Read: http://www.antlr.org/wiki/display/ANTLR3/Custom+Syntax+Error+Recovery
Do I get a masters too? ;-)
Jim
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.