转换/减少杯子解析器中的冲突

时间:2012-12-27 16:40:39

标签: parsing cup

我写了这个语法:

/* 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

0 个答案:

没有答案