Java 表达式求值
我正在尝试开发一个解析器来解析简单的逻辑关系表达式,其中包括“(”,“)”,“>”,“<”,“,”作为标记。一个例子可能是:
a < (b > c > (x, y, z))
从上面的表达式,我可以推断:
- a 依赖 b
- b 是 c 的前提
- x、y 和 z 独立依赖于
- c a 和 c 之间没有关系
- a 和 x 之间没有关系, y 和 z
有没有工具支持这种解析?
谢谢, 绿色的
I am trying to develop a parser to parse simple logical relationship expressions, which includes "(", ")", ">", "<", "," as token. An example might be:
a < (b > c > (x, y, z))
From the above expression, I would deduct that:
- a relies on b
- b is a precondition of c
- x, y and z depend on c independently
- there is no relationship between a and c
- there is no relationship between a, x, y and z
Is there any tool to support this kind of parsing?
thanks,
Green
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试 JavaCC .. 习惯它有点棘手,但是一旦您掌握了它,您就可以轻松构建这样的解析器。您可以按照此教程开始。还可以使用 eclipse 插件,这有助于使用它来生成所需的文件等。
You can try JavaCC .. It is a bit tricky to get used to it but once you get it you can easily build such parsers. You can start by following this tutorial. An eclipse plugin is also available which facilitates its use to generate the required files and so on.
我猜,最著名的此类工具是 ANTLR。
The most famous tool for such things, I guess, is ANTLR.