That was helpful, thanks :-) On Tue, May 18, 2010 at 5:31 PM, Jim Idle <j...@temporal-wave.com> wrote:
> Well, err the method inArray() is an imaginary method that you will write. > It just needs to take a string and see if that string is currently something > that should be a UNIT_NAME. If it is real simple then you could just use a > standard List object of your choice. > > > > Please replay to the list and not my personal email - thanks J > > > > Jim > > > > From: Sameh W. Zaky [mailto:sameh...@gmail.com] > Sent: Tuesday, May 18, 2010 7:21 AM > To: Jim Idle > Subject: Re: [antlr-interest] ANTLR Two Simple Questions :-) > > > > Dear Jim, > > > > thanks for your reply. > > > > Concerning point (1): > > > > I did as you said: > > > > fragment UNIT_NAME :; > > > > ID : ('a'..'z'|'_')* > > { > > if(inArray($text)) $type=UNIT_NAME; > > } > > ; > > > > But when I click 'run' to run a test I get the error: > > D:\My Documents\Downloads\Simple Test > Grammar\output\SimpleTestLexer.java:604: cannot find symbol > > [16:15:56] symbol : method inArray(java.lang.String) > > [16:15:56] location: class SimpleTestLexer > > [16:15:56] if(inArray(getText())) > _type=UNIT_NAME; > > > > Any idea, how I can overcome this? > > > > Thanks again for your time :-) > > > > On Mon, May 17, 2010 at 6:54 PM, Jim Idle <j...@temporal-wave.com> wrote: > > > > > -----Original Message----- > > From: antlr-interest-boun...@antlr.org [mailto:antlr-interest- > > boun...@antlr.org] On Behalf Of Sameh W. Zaky > > Sent: Monday, May 17, 2010 7:33 AM > > To: antlr-interest@antlr.org > > 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 > > > > > -- > Sameh W. Zaky > > > > > List: http://www.antlr.org/mailman/listinfo/antlr-interest > Unsubscribe: > http://www.antlr.org/mailman/options/antlr-interest/your-email-address > -- Sameh W. Zaky 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 il-antlr-inter...@googlegroups.com. To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.