[antlr-interest] Simple grammar problem

CARLOS MELGAREJO carlos.melgarejo at rogers.com
Thu May 24 12:24:41 PDT 2007


Hi All,

I'm facing a problem with my grammar. Maybe I'm missing something somewhere, because the generated
code is not doing things the way I want to. 

I realize after a few testing that the following input reconize and display error messages:
( 3 + 6      =>  ')' especting. That is fine, that is the way should be anyway.

But when I enter the following input:

(3 + 6 ) (     I don't see any error message. Seens to me that '(' is consumed but do not generate any
exception, and even create the right AST. 

The same happends with:
(3+6) ( )

So, the question is: How I can fix the problem, in order to display and error message in situations mentioned 
abode.

Thanks in advance.

This is my grammar
-----------------------------------------
statement 
    : expression 
    ;
   
expression
    : conditionalAndExpression ( 'or'^ conditionalAndExpression )*
    ;

--------------

atom
    : literal  
    | log 
    | Date 
    | '('! expression  ')'!
    ;
------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070524/847c0c54/attachment.html 


More information about the antlr-interest mailing list