You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In some blog posts
I wrote a while ago, I demonstrated how to create a small dynamically typed programming language
called Tiny Language using ANTLR 3.
However, ANTLR 4 is now the leaner (and meaner) version of the popular parser generator. Since the
changes from v3 to v4 are significant, making Tiny Language work using ANTLR 4 is non trivial.
Most notably, ANTLR 4 does not have any tree rewriting anymore. The new version generates listeners
(and/or visitors) that can be used to walk the plain parse tree.
Get up and running
First, clone this repository:
git clone https://github.com/bkiers/tiny-language-antlr4.git
cd tiny-language-antlr4
Then generate the lexer, parser and visitor classes using the antlr4 Maven plugin:
mvn antlr4:antlr4
Compile all classes:
mvn install
and finally run the Main class (which executes the test.tl file):
mvn -q exec:java
Or, combine all the previous commands in a single liner:
mvn -q antlr4:antlr4 install exec:java
which should print:
All Assertions have passed.
No Maven?
If you're unfamiliar with Maven, and are reluctant to install it, here's how
to perform all the steps from the (*nix) command line (assuming you're in the
root folder of the project tiny-language-antlr4):