Here are a couple of simple rules extracted from a combined grammar I have:

RETURNS                             :               ('R'|'r')'eturns'   { $text 
= "RETURNS"; } ;

returnsStatement
                :               RETURNS ':' type ';'          ->            
^(RETURNS type)
                ;

(type's definition is, I think, irrelevant.  It matches the typical things - 
int, double, etc.).

Note that the rule uses the rewrite syntax and omits the ':' and ';' tokens in 
the AST.

I am observing that my parser accepts inputs even when these tokens are missing.

For example, the line:    "returns double" is accepted (note, no ':' or ';').  
In stepping through the parse, the Match() method calls that should match the 
':' and ';' return '<missing ':'>' and '<missing ';'>', respectively, yet do 
not fail.  I understand that a feature of ANTLR is that missing tokens are 
sometimes automatically inserted to allow the parse to proceed, but shouldn't 
the erroneous line(s) be reported?

Is this behavior correct and/or expected?  If not, does anyone have any clues 
as to what might be going wrong?

Thanks,
Kevin Carroll


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.

Reply via email to