8

Anybody know of a tool, that generates EBNF from ANTLR? ANTLR is already close to EBNF, but for documentation purpose I would like to have a clean EBNF description (without the Code in between).

With antlrworks and this its already nice to get the syntax diagrams:

java -cp antlrworks-1.1.4.jar org.antlr.works.Console -f yql.g -o output/ -sd eps

but it would like to have a bare textual description, preferable text, tex, html, xml, or similar.

flolo
  • 15,148
  • 4
  • 32
  • 57
  • 2
    Not quite what you're looking for, but there is `org.antlr.tool.Strip` which can be used to strip embedded code and some predicates from your grammar file, but it's still an ANTLR grammar it produces, not EBNF. – Bart Kiers Mar 29 '12 at 09:25

1 Answers1

20

I have an online tool that converts foreign grammars to W3C grammar notation. It has an ANTLR3 grammar parser, so maybe this gets close to what you were looking for. W3C notation is also useful for generating syntax diagrams.

Gunther
  • 5,146
  • 1
  • 24
  • 35
  • Doesn't seem to work very well for ANTLR4. Tried some simple examples from the documentation, but they produced errors. – adius Nov 05 '17 at 16:12
  • 2
    @adius When you tried it, only ANTLR3 was supported, but meanwhile support for ANTLR4 has been added. – Gunther Dec 27 '18 at 08:44
  • Many thanks for the tool! Would be great to have it not only as an online service, but as a software package, which I can integrate into my software. – yegor256 Jul 03 '23 at 07:39