Tokens
SEMI: ";"
OPEN: "("
CLOSE: ")"
ADD: "+"
SUB: "-"
DIV: "/"
MUL: "*"
ASN: "="
ADDASN: "+="
SUBASN: "-="
IDENT: [a-z]+
NUMLIT: [0-9]+
| Grammar
1. statements: assign statements
2. statements: assign
3. assign: IDENT assignop addexpr SEMI
4. assignop: ASN
5. assignop: ADDASN
6. assignop: SUBASN
7. addexpr: addexpr addop multexpr
8. addexpr: multexpr
9. multexpr: multexpr multop brackexpr
10. multexpr: brackexpr
11. brackexpr: OPEN addexpr CLOSE
12. brackexpr: value
13. value: NUMLIT
14. value: IDENT
15. addop: ADD
16. addop: SUB
17. multop: MUL
18. multop: DIV
*rules numbered to allow easier referencing in discussions
|