ANN: antlr-format, your flexible friend

35 views
Skip to first unread message

Mike Lischke

unread,
Nov 25, 2023, 10:53:15 AM11/25/23
to 'ANTLR announcements
What is this about?

I'm pleased to announce another little tool in the ANTLR family: antlr-format, a small library written in TypeScript to format ANTLR4 grammars. It is available in the Github repo https://github.com/mike-lischke/antlr-format and as Node.js package https://www.npmjs.com/package/antlr-format.

Even more useful is probably a command line interface for this package, called antlr-format-cli, which provides a terminal application for grammar formatting, available in the same repo, in the cli/ subfolder and as separate Node.js package https://www.npmjs.com/package/antlr-format-cli. All necessary details how to use both can be read in their respective readme files.

As test case I opened a pull request in the ANTLR4 grammar repository (https://github.com/antlr/grammars-v4/pull/3843) that reformats most of the grammars there (~500 g4 files). 

The command line tool can be used independently of what your preferred programming languages are. The only prerequisite is that a recent Node.js version is installed on your box.

Some more details

The formatter class was originally part of my ANTLR4 extension for VS Code (https://marketplace.visualstudio.com/items?itemName=mike-lischke.vscode-antlr4), from where I extracted it to create the new Node.js package.

I hope you like it and find it useful.
Reply all
Reply to author
Forward
0 new messages