开发者

ANTLR3 runtime metadata

开发者 https://www.devze.com 2022-12-22 02:26 出处:网络
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, with开发者_运维问答

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, with开发者_运维问答out the need of using grammar actions or trees.

Is this possible?

Many thanks, Yaakov


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号