[antlr-interest] Simple expression grammar

Johannes Luber JALuber at gmx.de
Thu May 15 13:35:09 PDT 2008


> >> OK I have written my grammar for boolean expressions mentioned earlier 
> >> (like ( (a>=3 || b<=5)&& c>=4 )  ).
> >>
> >> But my grammar accept also expressions like "abc def ght" and many
> other 
> >> strange constructions
> > 
> > I think it is only accepting that because you have used:
> > 
> > logical_or_expression+
> > 
> > Remove the + and it will only accept a single logical expression. this 
> > code accepts  abc def ght as 3 separate logical_or_expressions.
> 
> I have tried it but ... when I remove '+' it will not parse correctly 
> expression like "x>=4 || b<=5 && d<=5" . It will parse only 'x'
> 
> Thanks
> Maciek Bakalarz

How about

logical_or_expression EOF

?

Johannes
-- 
GMX startet ShortView.de. Hier findest Du Leute mit Deinen Interessen!
Jetzt dabei sein: http://www.shortview.de/?mc=sv_ext_mf@gmx


More information about the antlr-interest mailing list