Skip to content

Latest commit

 

History

History
24 lines (18 loc) · 1.02 KB

README.md

File metadata and controls

24 lines (18 loc) · 1.02 KB

ANTLR test project

Simple example project showing how to include ANTLR 4.5 into a Java application, using SBT for the build with the sbt-antlr4 plugin to automatically compile the grammar file under src/main/antlr.

This sample uses a grammar (starter/ArrayInit.g4) from the book "The Definitive ANTLR 4 Reference", the code samples used in the book are available online for free here.

Setup

# get dependencies and compile
./sbt clean update compile

# run to parse input string "{4,3,2,1,0}", should output parsed LISP-style tree
./sbt "run {4,3,2,1,0}"
# output -> (init { (value 4) , (value 3) , (value 2) , (value 1) , (value 0) })

Intellij

Configuration: alt text

Alt text