Generate EBNF from ANTLR
Asked Answered
C

1

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.

Calyx answered 29/3, 2012 at 8:38 Comment(1)
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.Dewberry
C
21

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.

Caloyer answered 29/3, 2012 at 20:33 Comment(3)
Doesn't seem to work very well for ANTLR4. Tried some simple examples from the documentation, but they produced errors.Geralyngeraniaceous
@Geralyngeraniaceous When you tried it, only ANTLR3 was supported, but meanwhile support for ANTLR4 has been added.Caloyer
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.Otisotitis

© 2022 - 2024 — McMap. All rights reserved.