[antlr-interest] Nondeterminism in a simple expression grammar
jbb at acm.org
jbb at acm.org
Fri May 7 20:44:56 PDT 2004
On Fri, 07 May 2004 21:02:15 +0000, Dave Bailey <dave at daveb.net> wrote:
>...
>options { language = "Cpp"; genHashLines = true; }
>class test_parser extends Parser;
>options { k = 3; buildAST = true; }
>
>test : (expr SEMI!)+ EOF! ;
>expr : uexp | bexp ;
>uexp : U^ expr ;
>bexp : ID (B^ (uexp | ID))* ;
>
>class test_lexer extends Lexer;
>options { testLiterals = true; }
>tokens { U = "U"; B = "B"; }
>SEMI : ';' ;
>WS : (' '|'\n'{newline();}) {$setType(antlr::Token::SKIP);} ;
>ID : ('a'..'z'|'A'..'Z')+ ;
>...
instead of
bexp : ID (B^ (uexp | ID))* ;
maybe try
bexp : ID (B^ exp)? ;
(it seemed to work okay for me in java and no k=3 is required)
hope this helps...
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list