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

lgcraymer lgc at mail1.jpl.nasa.gov
Tue Mar 11 17:03:16 PST 2003


This is one of those situations where recursion works.  Try

statementList:
      (statement)=> (statement statementList)
      |
      ;

--Loring

--- In antlr-interest at yahoogroups.com, "Gunnar Wagenknecht" 
<kreismeister at y...> wrote:
> Hi!
> 
> I have a grammar where the syn. pred. doesn't seem to work. I can 
> post the whole grammar but the following example should be ok to 
> recognize the problem.
> 
> compilationUnit : statementList (function)*;
> 
> function : ("static"|"init"|"exit")? "function" identName crlf
>            statementList;
> 
> identName : IDENTIFIER;
> 
> crlf : SEMICOLON | NEWLINE;
> 
> statementList: (statement)*;  // <<< here I get non-determinisme 
>                               // warning upon
>                               // k=1 "static"|"exit"
>                               // k=2 
> IDENTIFIER|"function"|NEWLINE|SEMICOLON
> 
> statement: ...
>          | variableDeclaration
>          | ...
>          | "exit" crlf
>          | ...
>          ;
> 
> variableDeclaration : ("public"|"private"|"local"|"static") 
identName 
> crlf;
> 
> 
> I tried to reslove things with syn. pred. but whatever I do I 
> couldn't remove the warning. The generated parser also doen't work 
> correct.
> 
> What can I do to resolve the warning?
> 
> Thanks, Gunnar


 

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



More information about the antlr-interest mailing list