New ANTLR Development Tool : live-coding with boot-clj

34 views
Skip to first unread message

Fred Eisele

unread,
Oct 19, 2017, 12:30:35 PM10/19/17
to antlr-discussion
https://github.com/babeloff/boot-antlr4/wiki

This tool is a candidate for http://www.antlr.org/tools.html

Rather than being included as a plug-in to a specific IDE it provides tasks for boot-clj.
Boot is tooling that performs arbitrary tasks, tasks may be composed of other tasks.
This project specifically provides the tasks `antlr4` and `test-rig` which are light wrappers around the `org.antlr.v4.Tool` and `org.antlr.v4.runtime.misc.TestRig` classes.

The intent is to provide a "live-coding" experience without depending on a specific IDE.
This works so long as the IDE has the ability to respond to file updates.
I have used this successfully with: Visual Studio Code, Atom.io and Vim.

Included in the project is a demo application which parses the Antlr4 grammar itself.
I plan on demonstrating how the Antlr grammar may be extended to include literate programming elements.
The following composite task watches a prescribed set of files and when they change it automatically performs a workflow.

(deftask build
[]
(comp
(watch)
(antlr4 :grammar "ANTLRv4Lexer.g4"
:package "org.antlr.parser.antlr4")
(antlr4 :grammar "ANTLRv4LiterateParser.g4"
:package "org.antlr.parser.antlr4"
:visitor true)
(javac)
(test-rig :parser "org.antlr.parser.antlr4.ANTLRv4LiterateParser"
:lexer "org.antlr.parser.antlr4.ANTLRv4Lexer"
:start-rule "literaryGrammarSpec"
:input ["src/antlr4/ANTLRv4Lexer.g4"
"src/antlr4/ANTLRv4Parser.g4"]
:tree true
:postscript true
:tokens true)
(target :dir #{"target"})))


Note that the Lexer contains channels which cause problems with the interpreted parser.
Note also that the test-rig :tree option produces  Clojure EDN style lisp the other options should be obvious as they merely wrap their respective classes.



Reply all
Reply to author
Forward
0 new messages