如何解决简单语法中的Shift / Reduce冲突

时间:2017-11-09 19:35:25

标签: jflex cup

语法如下:

terminal TERM1,TERM2;
non terminal  entry, sector, unit_a, unit_b;

entry ::= sector unit_b;    
sector ::= unit_a sector | unit_a;    
unit_a ::= TERM1 TERM1;    
unit_b ::= TERM1 TERM2;

当我尝试使用jcup生成解析器时,我收到以下警告

Warning : *** Shift/Reduce conflict found in state #1
  between sector ::= unit_a (*) 
  and     unit_a ::= (*) TERM1 TERM1 
  under symbol TERM1
  Resolved in favor of shifting.

Warning : *** Production "sector ::= unit_a " never reduced

我怎样才能找到导致这场冲突的原因?

0 个答案:

没有答案