Skip to content
/ Mu Public

A small demonstration how to use ANTLR 4's visitor feature.

Notifications You must be signed in to change notification settings

bkiers/Mu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Mu

A small expression parser, using ANTLR 4. It supports most basic operators and while- and log- (print) statements. It is just a basic demonstration of how to use the -visitor functionality of ANTLR 4.

To run the demo script:

n = 9;

while n > 0 {

  # expressions can be surrounded by parenthesis, of course
  if (n % 2 == 0) {
    log n + " -> even";
  }
  else {
    log n + " -> odd";
  }

  n = n - 1;
}

do:

git clone git://github.com/bkiers/Mu.git
mvn clean install
mvn -q exec:java

which will print the following to your console:

9.0 -> odd
8.0 -> even
7.0 -> odd
6.0 -> even
5.0 -> odd
4.0 -> even
3.0 -> odd
2.0 -> even
1.0 -> odd

Also see this stackoverflow Q&A.

@w3b-net-au made a fork including for- statements: https://github.com/w3b-net-au/Mu

About

A small demonstration how to use ANTLR 4's visitor feature.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published