Calc in ANTLR

Feb. 3, 2013, 12:21 p.m.

This is a sequence of calculators which can be used to dive into ANTLR.


Write down the grammar. (source code)

calc 1.5

Add the main subroutine to use generated lexer and parser. (source code)

calc 2

Add actions and returns to actually calculate. (source code)

calc 3

Move from int to double. (source code)

calc 4

Add custom error reporting. (source code)

calc 5

Generate AST and then use TreeWalker. (source code)

calc 6

Replace System.out.println with string templates. (source code)

comments powered by Disqus