title: Simple Maths Expression Parser ## Aim Parse each of the following lines ``` 1 + 2 (1 + 2) * 3 4 * (5 - 6) 7 + 8 + 9 5 / (3 + 1) ``` ## Notes Antlr4 has the mandatory convention that [lexer](../../lexers) patterns begin with a Capital Letter and syntactic patterns start with a lowercase letter. ## Example Grammar This is my first attempt. ```antlr grammar Expr; DIGIT: [0-9] ; NUMBER: DIGIT+ ; expr: expr ('+'|'-') term | term ; term: term ('*'|'/') NUMBER | NUMBER | '(' expr ')'; ``` Problems: 1. It doesn't handle whitespace (probably want `WHITESPACE: [ \t\r\n] -> skip;`).