如何定义ε当我用解析代码编写语法规则时?
我正在尝试为我定义的特定语法编写编译器程序。
语法中有一些ε,因为一些迭代和递归规则。我试图通过创建一个空的令牌来定义ε:
tokens = (
'EMPTY'
)
t_EMPTY = r'\ '
这引起了一些解析问题,因此我在Lexer代码中早些时候忽略了空间:
t_ignore = ' \t'
描述定义ε的其他方法是什么?
单击在这里查看项目文件
I'm trying to write a compiler program for a specific grammar I defined.
There are a few ε in the grammar because of some iterative and recursive rules. I tried to define ε by creating an empty token:
tokens = (
'EMPTY'
)
t_EMPTY = r'\ '
That caused some parsing problems, therefore I ignored spaces earlier in the lexer code:
t_ignore = ' \t'
What are other ways to describe define ε?
Click here to see the project files
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
已解决的。这是代码的语法部分中的空定义:
Solved.The yacc.py module I used includes a special
<empty>
value for ε. Here is empty defining in the grammar part of the code: