[antlr-interest] Re: syn pred / lookahaed doesn't work

Gunnar Wagenknecht kreismeister at yahoo.de
Tue Mar 11 21:25:56 PST 2003


--- In antlr-interest at yahoogroups.com, "Albert Huh" <albert.huh at e...> 
wrote:

> ambiguity with k=2
> ------------------
> 1) the second token of a function can be either an IDENTIFIER 
or "function"
> 2) the second token of a variableDeclaration is an IDENTIFIER
> 3) we know that variableDeclaration is a statement
> 4) so a statement looks exactly like a function at k=2

Mhm, but I thought this is not an ambiguity because if the second 
token of a function is an IDENTIFIER than the first token of a 
function is NOT "static" or "ecit".

> i'm probably not stating anything new here to anybody.  i *think* 
this is a linear approximation issue, can somebody else confirm this?

What the hack is that?

> alternatively, you can get rid of teh warning with a combination of 
recursion and syntactic predicates.  try rewriting your statementList 
rule like this:
> 
> statementList:
>   (statement statement)=>statement statementList
>   |(statement)=>statement
>   | //empty rule, do nothing
> ;


Thank you, that was something I was trying without getting warnings 
but I couldn't finished it. Now I will try it. I'm wondering if this 
construct slows down the generated parser in a very bad way. That's 
why I threw away this solution.

Cu, Gunnar


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list