[antlr-interest] A bug about expression?

Alexey Demakov demakov at ispras.ru
Sun Aug 28 22:24:16 PDT 2005


Hi,

In fact, 'e1' rule doesn't accept 'e2 RP'. It consumes only e2
if it is not followed by COMMA. So, if you will use e1 as:

start : e1 EOF ;

there will be error message about RP instead of end-of-file.

Regards,
Alexey

-----
Alexey Demakov
TreeDL: Tree Description Language: http://treedl.sourceforge.net
RedVerst Group: http://www.unitesk.com


----- Original Message ----- 
From: "Daisuke OKAJIMA" <okajima at poderosa.org>
To: <antlr-interest at antlr.org>
Sent: Sunday, August 28, 2005 10:16 AM
Subject: [antlr-interest] A bug about expression?


> 
>  Hi,
> 
>  I found a suspicious behavior about antlr 2.7.5, and extracted a small
> sample grammar to reproduce the behavior. The grammar file is attached.
> 
>  In the sample, there are two expressions e1 and e2. 
> 
> e1
> : e2 (COMMA e2)?
> ;
> 
> e2
> : NUMBER
> | LP e1 RP
> ;
> 
>  On the contrary, the generated source code for the expression e1
> accepts "e2 RP" as input. This is the reason of the suspicious behavior I
> found first.
> 
> public final void e1() throws RecognitionException, TokenStreamException {
>   e2();
>   switch ( LA(1)) {
>   case COMMA:
>     ...
>   case RP:
>   {
>     break;
>   }
>   ....
> 
>  Does anybody have information about this behavior?
> 
>  regards,
> 
> -- 
> Daisuke OKAJIMA <okajima at poderosa.org>
> 



More information about the antlr-interest mailing list