2

我写了这个语法:

/* Precedences */ 
precedence left UMINUS;
precedence left ID;

Expr ::=      ID:e              
    | NUM:e             

    | Expr:e1 TIMES Expr:e2     

    | LP Expr:e RP          

    ;

Call ::= ID:id LP  ExprComma:args RP  ; 

当我尝试在这个程序上运行解析器时:

weirdAverage(5)

(标记是:id lp num(即 expr)rp)

我得到:

 Syntax error in line 1 '('

所以,我尝试删除这个:

 precedence left ID;

现在我得到一个错误:

   [java] Warning : *** Shift/Reduce conflict found in state #16
 [java]   between Expr ::= ID (*) 
 [java]   and     Call ::= ID (*) LP ExprComma RP 
 [java]   under symbol LP
 [java]   Resolved in favor of shifting.
 [java] Warning : *** Shift/Reduce conflict found in state #79
 [java]   between Expr ::= ID (*) 
 [java]   and     Call ::= ID (*) LP ExprComma RP 
 [java]   under symbol LP
 [java]   Resolved in favor of shifting.
 [java] Error : *** More conflicts encountered than expected -- parser generation aborted
4

0 回答 0