[antlr-interest] Something like EOF token for tree parsers?

Matt Benson gudnabrsam at yahoo.com
Fri Jun 9 14:20:03 PDT 2006



--- Jörg Rathlev <joerg at jrsoftware.de> wrote:

> Hi,
> 
> in a tree parser, can I somehow make sure I have
> matched all children of
> a tree?
> 
> I have just run into a bug in the java15.tree.g, in
> rule methodHead it
> uses the following code for parsing parameter
> declarations:
> #( PARAMETERS (parameterDef)* )
> But it should be:
> #( PARAMETERS (parameterDef)*
> (variableLengthParameterDef)? )
> 
> This bug is easily fixed, but it is not easily found
> because ANTLR won't
> complain when the parameters subtree has an
> additional child at its end
> that is not matched by "parameterDef". Instead,
> variable length
> parameters are silently ignored.
> 
> In normal parsers, I can use the special "EOF" token
> to make sure I have
> reached the end of the file and I am not ignoring
> any invalid input at
> the end of the file. Does a similar feature exist
> for subtrees in tree
> parsers?

Couldn't you use a semantic predicate?

-Matt

> 
> 
> Thanks
> Joerg
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the antlr-interest mailing list