Introduction
Being able to build a grammar from a short description or exemplar is an important skill for language tools developer to have. In these exercises you will build a variety of grammars in order to get use to doing this. Use ANTLRWorks and tester grammars with either the interpreter or the debugger.
Expressions
Build an expression evaluator that has integers as atoms with the following mythical binary operators and precedence.
| operator |
precendence |
| # |
highest |
| _ $ |
2nd highest |
| @ |
lowest |
Allow parentheses to group expressions. Examples: 2 $ 3 # x and (2$3)#x.
Function lists
f()
g(3)
h(3,4)
f(g(3,4), 5)