英文:
Simple Example of Modifying ANTLR4 Behaviour
问题
我们正在使用antlr4来解析一个特定设计的语言。我们已经成功创建了语法,现在正在使用它来生成我们所需的图表。
不过,我需要更多一些内容。我需要为同质AST添加行号,并将结果输出到一个文本文件中。我看到有很多关于这个问题的问答,但由于这是我们第一次在antlr中进行添加,是否有一个简单、完整的示例?我们有这方面的书籍,但它们假设读者对这个过程更加熟悉。
是否有一个带有简单扩展示例的资源,我们可以在此基础上构建?我认为我们可以相对快速地完成它,但我们需要一个入门指南。
谢谢
英文:
We are using antlr4 to parse a purpose designed language. We have been able to create a grammar, and we are now using it to generate the diagrams we need.
Unfortunately, I need a bit more. I need to add line numbers to a homogeneous AST and get the results in a text file. I see a lot of questions/answers to this but since this is our first time adding to antlr, is there a simple, complete example of this ? We have both books but they assume a lot more familiarity with the process than we have.
Is there a source with a simple extension that we could build from ? I think we can complete it reasonably quickly, but we need a starter guide.
Thanks
专注分享java语言的经验与见解,让所有开发者获益!
评论