On Fri, Feb 11, 2011 at 9:17 AM, Roohul <[email protected]> wrote: > Sorry for that.. > > when i use only letters (a..z | A..Z) in the variables and connectors it give > an error while creating an AST that "no viable alternative at input 'real'" > and when creating variables with digits the grammar do not compile at all and > give the following error. > "The following token definitions can never be matched because prior tokens > match the same input: Alpha" > > I hope that it is more elaboration.. >
I would try moving some of that to real lexer items. You are using generated tokens, which depending on where they go, 'real', would be matched by the rule for ID, and there would be no way to generate that. I don't know where they end up, but I do remember it being recommended to avoid them until you have more experience. Given the error, I think that is what is happening here. Look at the sample grammars and how they handle keywords. My guess is that you are trying to do too much in the lexer, you can detect a lot of this at a much later state in the parser/analysis phase. But that is just parroting common advise on this list. Kirby > Regards > > Roohul > > > > > --- On Fri, 2/11/11, Bart Kiers <[email protected]> wrote: > > From: Bart Kiers <[email protected]> > Subject: Re: [antlr-interest] Ident with ending In or Out word > To: "Roohul" <[email protected]> > Cc: "ANTLR" <[email protected]> > Date: Friday, February 11, 2011, 5:30 AM > > On Fri, Feb 11, 2011 at 2:27 PM, Roohul <[email protected]> wrote: > > Hi, > This is my sample grammar.. this did not work.. another thing is > that my variables and connectors both can have digits so I created Alpha > : LETTER (LETTER | DIGIT)*; for this but it also give an error. > > > The problem descriptions "did not work" and "also give an error" do not tell > much. Care to elaborate? > > Bart. > > > > > > > List: http://www.antlr.org/mailman/listinfo/antlr-interest > Unsubscribe: > http://www.antlr.org/mailman/options/antlr-interest/your-email-address > 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.
