首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >讽刺的Reduce-Reduce问题

讽刺的Reduce-Reduce问题
EN

Stack Overflow用户
提问于 2015-06-12 07:53:02
回答 1查看 385关注 0票数 0

近两周来,我一直在尝试解决这个问题。起初它是移位-归约错误,现在它的归约问题。我尝试过很多方法,现在我已经到了需要帮助的地步。我已经编写了很多语言,大约10年前就开始了,这是我第一次真正发布帮助。

我正在尝试为Angel Script编写一个语法类,Angel Script是一个流行的脚本引擎,我从解析器类中获得了BNF语法。您可以在这里找到语言参考http://www.angelcode.com/angelscript/sdk/docs/manual/doc_script.html

在我的类中,对于每个规则,我添加了我试图复制的BNF语法的注释。目前,我实际上没有使用我定义的关键字。一旦我能让它正常工作而没有冲突,我会回去试着清理它。这是我的类http://pastebin.com/FydCTqmU

您只需创建一个Dll并使用语法资源管理器运行它,您就会看到所有的错误。似乎大多数错误都来自同一个问题,所以我认为一旦我能解决这个问题,它就会解决几乎所有的问题。我写了一个应用程序来帮助我将语法拆分成更具体的部分,但我认为这导致了我点击更多的reduce-reduce问题。

我试图压缩我的代码,希望能通过reduce-reduce错误,但它似乎保持完全相同,只是看起来更加凌乱。如果有人能帮我把它做好,我会更乐意通过paypal给他们寄几百美元。我都快放弃了,我已经用了两个多星期了。我的邮箱是Anth0ny229@live.com。

我已经从shift-reduce错误变成了reduce-reduce错误。似乎无论我做什么,我最终都会遇到问题。我就是想不通,我真的需要帮助。就像我提到的,我会更乐意为帮助我的人付钱给我。我计划做一个像babelua这样的Visual Studio扩展,这样人们就可以使用Visual Studio编写Angel脚本脚本,还有望添加调试支持。它将是免费的,因为我认为这将是一个很好的补充。因此,如果任何人能够以任何方式提供帮助,只要它最终有效,我将更加高兴地确保他们得到回报。谢谢。

状态标识符(不充分) Reduce-reduce输入上的冲突: const S0 void int8 int16 int32 int64 int uint8 uint16 uint32 uint64 uint float double bool?自动::移位项目:

代码语言:javascript
复制
script' -> ·script EOF 
script -> ·script_0_list 
script_0_list -> ·script_0+ 
script_0+ -> ·script_0+ script_0 
script_0+ -> ·script_0 
script_0 -> ·import 
import -> ·import type import_0_opt identifier paramlist from string ; 
script_0 -> ·enum 
enum -> ·enum_0_opt enum identifier { identifier enum_1_opt enum_2_list } 
enum_0_opt -> ·shared 
script_0 -> ·typedef 
typedef -> ·typedef primtype identifier ; 
script_0 -> ·class 
class -> ·class_0_list class identifier class_1_opt { class_2_list } 
class_0_list -> ·class_0+ 
class_0+ -> ·class_0+ class_0 
class_0+ -> ·class_0 
class_0 -> ·shared 
class_0 -> ·abstract 
class_0 -> ·final 
script_0 -> ·mixin 
mixin -> ·mixin class 
script_0 -> ·interface 
interface -> ·interface_0_opt interface identifier interface_1_opt { interface_2_list } 
interface_0_opt -> ·shared 
script_0 -> ·funcdef 
funcdef -> ·funcdef type funcdef_0_opt identifier paramlist ; 
script_0 -> ·virtprop 
virtprop -> ·virtprop_0_opt type virtprop_1_opt identifier { virtprop_2_list } 
virtprop_0_opt -> ·private 
virtprop_0_opt -> ·protected 
script_0 -> ·func 
func -> ·func_0_opt func_1_opt identifier paramlist func_2_opt func_3_list statblock 
func_0_opt -> ·private 
func_0_opt -> ·protected 
func_0_opt -> ·shared 
script_0 -> ·var 
var -> ·var_0_opt type identifier var_1_opt var_2_list ; 
var_0_opt -> ·private 
var_0_opt -> ·protected 
script_0 -> ·namespace 
namespace -> ·namespace identifier { script } 
script_0 -> ·;

减少项目:

代码语言:javascript
复制
script_0_list -> · [EOF]
enum_0_opt -> · [enum]
class_0_list -> · [class]
interface_0_opt -> · [interface]
virtprop_0_opt -> · [const identifier void int8 int16 int32 int64 int uint8 uint16 uint32 uint64 uint float double bool ? auto ::]
func_0_opt -> · [const ~ identifier void int8 int16 int32 int64 int uint8 uint16 uint32 uint64 uint float double bool ? auto ::]
var_0_opt -> · [const identifier void int8 int16 int32 int64 int uint8 uint16 uint32 uint64 uint float double bool ? auto ::]

转换:

代码语言:javascript
复制
script->S1, script_0_list->S2, script_0+->S3, script_0->S4, import->S5, import->S6, enum->S7, enum_0_opt->S8, shared->S9, typedef->S10, typedef->S11, class->S12, class_0_list->S13, class_0+->S14, class_0->S15, abstract->S16, final->S17, mixin->S18, mixin->S19, interface->S20, interface_0_opt->S21, funcdef->S22, funcdef->S23, virtprop->S24, virtprop_0_opt->S25, private->S26, protected->S27, func->S28, func_0_opt->S29, var->S30, var_0_opt->S31, namespace->S32, namespace->S33, ;->S34
EN

回答 1

Stack Overflow用户

发布于 2015-06-15 21:27:19

冲突意味着你的语法是模棱两可的,有两种或更多的方法来解析相同的东西。

reduce reduce冲突意味着不同的非终结符可以应用于相同的输入。在你的例子中,我认为这是因为像"5“这样的数字可以是int8,int16等。

提示: GNU Bison使用与Irony类似的解析算法,它的帮助页面在处理这类错误时非常有帮助。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30793308

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档