Generate BNF diagrams from an antlr grammar?

家住魔仙堡 提交于 2019-12-10 10:41:34

问题


I may well be asking something not achievable here.. Maybe someone can point out either

(a) What would be some steps (/tools?) to at least partially achieve creation of bnf diagrams from a (rather complex) antlr grammar

(b) why (if it were the case) this simply can not be achieved. E.g. maybe since antlr is extended BNF and its recursive structure differs from bnf requirements.. Along those lines.


回答1:


ANTLRWorks 1 works for generating diagrams, one at a time, for rule.

for v4, ANTLRWorks 2 also generates them though I'm not sure it can save them to disk.

Ter




回答2:


If it is an ANTLR 3 grammar, you could

  • use http://bottlecaps.de/convert to convert it to W3C notation,
  • with the result, proceed to http://bottlecaps.de/rr/ui for generating syntax diagrams.



回答3:


Grako has an ANTLR3-to-EBNF translator in its examples. You can customize it to the BNF style you require (or to ANTLR4).



来源:https://stackoverflow.com/questions/18436796/generate-bnf-diagrams-from-an-antlr-grammar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!