简体   繁体   English

Antlr4访客和成员

[英]Antlr4 visitors and members

I'm currently investigating ANTLR4 , and I'm struggling a bit to find information on how the visitors are used. 我目前正在研究ANTLR4,并且正在努力寻找有关如何使用访客的信息。 The following page: http://www.antlr.org/wiki/display/ANTLR4/Parser+Rules and reading though the ANTLR generaged files in my little dummy project, leaves me with the following questions 下一页: http ://www.antlr.org/wiki/display/ANTLR4/Parser+Rules并阅读我的小虚拟项目中的ANTLR生成的文件,这给我带来了以下问题

  • how do I access the fields of the parser in the listener? 如何在侦听器中访问解析器的字段? For example, if i use @members {int mynumber = 0;} in the grammer, how can I access this within a method of the listener implementation? 例如,如果我在语法中使用@members {int mynumber = 0;} ,如何在侦听器实现的方法中访问它?

  • Can anybody point me to a small example, targeted at somebody fairly new to antlr which uses visitors? 有人能给我指出一个小例子,针对使用访客的antlr刚起步的人吗?

This example by Bart Kiers really helped me: If/else statements in ANTLR using listeners Bart Kiers的这个示例确实帮助了我: 使用侦听器的ANTLR中的if / else语句

There's more info if you grab the example source files: https://github.com/bkiers/Mu 如果获取示例源文件,则有更多信息: https : //github.com/bkiers/Mu

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM