ANTLR3 运行时元数据

发布于 2024-08-24 00:49:43 字数 109 浏览 3 评论 0原文

在解析过程中如何知道当前匹配的是哪条规则? 我想使用规则名称自动构建表示解析输入的 XML(或其他对象层次结构),而不需要使用语法操作或树。

这可能吗?

非常感谢, 雅科夫

How can I know during parsing which rule is currently matched?
I'd like to automatically build an XML (or other objectal hierarchy) representing the parsed input, using rule names, without the need of using grammar actions or trees.

Is this possible?

Many thanks,
Yaakov

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沫离伤花 2024-08-31 00:49:43

AFAIK,那是不可能的。但为什么不使用 ANTLR 的内置树结构呢?在语法的 options{ } 部分中,添加 output=AST; 并在适用的情况下使用重写规则。请参阅: http:// /www.antlr.org/wiki/display/~admin/2008/11/30/Example+tree+rewriting+with+patterns

AFAIK, that is not possible. But why don't you use ANTLR's built in tree construction? In the options{ } part of your grammar, add output=AST; and use rewrite rules where applicable. See: http://www.antlr.org/wiki/display/~admin/2008/11/30/Example+tree+rewriting+with+patterns

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文