Are there tools to convert between ANTLR and other forms of BNF?

I wrote a translator for this purpose. Universal-transpiler is able to convert ANTLR grammars into PEG.js, nearley, ABNF, XBNF, and several other grammar notations. It is not yet able to translate ANTLR into W3C-BNF, but I will try to add this feature in a future version.

This translator is only compatible with a small subset of the ANTLR language, but I hope it will still be useful.


# Grammar Syntax

|                               | BNF                           | ISO EBNF                      | ABNF                          | ANTLR                         |
|:-----------------------------:|:-----------------------------:|:-----------------------------:|:-----------------------------:|:-----------------------------:|
| rule definition               | `<name> ::= ...`              | `name = ... ;`                | `name = ...`                  | `name : ... ;`                |
| terminal items                | `...`                         | `'...'` or `"..."`            | integer or `"..."`            | `'...'`                       |
| non-terminal items            | `<...>`                       | `...`                         | `...` or `<...>`              | `...`                         |
| concatenation                 | (space)                       | `,`                           | (space)                       | (space)                       |
| choice                        | `|`                           | `|`                           | `/`                           | `|`                           |
| optional                      | requires choice syntax[^1]    | `[...]`                       | `*1...` or `[...]`            | `...?`                        |
| 0 or more repititions         | requires choice syntax[^2]    | `{...}`                       | `*...`                        | `...*`                        |
| 1 or more repititions         | requires choice syntax[^3]    | `{...}-`                      | `1*...`                       | `...+`                        |
| n repititions                 |                               | `n*...`                       | `n*n...`                      |                               |
| n to m repititions            |                               |                               | `n*m...`                      |                               |
| grouping                      |                               | `(...)`                       | `(...)`                       | `(...)`                       |
| comment                       |                               | `(*...*)`                     | `;...`                        | `// ...` or `/* ... */`       |


[^1]: `optionalb ::= a b c d | a c d`

[^2]: `list ::= | listitem list`

[^3]: `list ::= listitem | listitem list`