使用Parsekit构建解析树
我在 XCode 中使用 Parsekit,但这个问题很可能适用于大多数解析器生成器。我用 gammer 解析了一个脚本,效果很好。但是我在下一步中遇到了问题。考虑 grmmer:
@start = line+; 线=树;
树 = '树' 水果树枝;
Fruits = 'with' '水果' 数量; 分支 = 'with' '分支' 数量;
并传递脚本:
树与水果 8 带树枝 12
如果我然后实现匹配方法,水果和树枝将匹配一次,这是预期的。
但是树会匹配两次,为什么呢?这阻止了我构建我想要的解析树。
感谢您的帮助!
I'm using Parsekit for XCode but this problem may well apply to most parser generators. I parse a script with a gammer and it works fine. However I'm running into problems with the next step. Consider the grmmer:
@start = line+;
line = tree;
tree = 'tree' fruits branches;
fruits = 'with' 'fruits' Number;
branches = 'with' 'branches' Number;
And the script to pass:
tree with fruits 8 with branches 12
If I then implemenet methods to match, fruits and branches will be matched once, this is expected.
However tree will be matched twice, why? This stops me from building the parse tree I want.
Thanks for any help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ParseKit 的开发者在这里。我认为您实际上可能会问与此相同的问题:
parsekit给予意外的调用选择器
如果你仔细阅读我对这个问题的评论,我想你会找到答案。如果没有请告诉我。
Developer of ParseKit here. I think you might actually be asking the same question as this:
parsekit given unexpected calls to selectors
If you read through the comments I made on that question, I think you will find the answer. Let me know if not.