简体   繁体   English

Antlr图形规则表示

[英]Antlr graphical rule representation

Is there a tool to create a graphical representation of one's antlr4 grammar that means the parser/lexer rules eg as a graphical representation of a finite state machine? 有没有一种工具可以创建一个人的antlr4语法的图形表示,这意味着解析器/词法分析器规则,例如作为有限状态机的图形表示?

It should be the case that it can be represented since it has backus naur form. 应该是可以表示的,因为它具有backus naur形式。

Example: 例:

plus: INT '+' INT | plus '+' INT
INT: [0-9]+

A corresponding finite-state machine would be 相应的有限状态机将是

start -> INT <-> plus
          |
          v
        exit

There may also be other graphical representations but a finite-state machine. 除有限状态机外,可能还存在其他图形表示形式。 The goal is to provide a different perspective in order to make debugging/understanding the grammar easier. 目的是提供不同的观点,以便使调试/理解语法更加容易。

You probably want something like this: https://github.com/bkiers/rrd-antlr4 . 您可能想要这样的东西: https : //github.com/bkiers/rrd-antlr4 These types of graphics are called railroad diagrams. 这些类型的图形称为铁路图。

Another solution is to use ANTLRWorks 2.1. 另一个解决方案是使用ANTLRWorks 2.1。 There's a view called "Syntax Diagram" included that can generate railroad diagrams of your parser rules and your lexer rules. 其中包含一个名为“语法图”的视图,该视图可以生成解析器规则词法分析器规则的铁路图。

I'm using those images for my master thesis and the process works fine so far. 我正在使用这些图像作为我的硕士论文,并且到目前为止该过程运行良好。

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

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