| 1 |
// Simple grammar that provides has increasing number of options for each |
| 2 |
// position in its declaration type. The first token has to be "var", |
| 3 |
// the second can be an idetifier or "_', the third could be "=", ":=" or |
| 4 |
// ";", and so on. |
| 5 |
|
| 6 |
!_whitespace : ' ' ; |
| 7 |
|
| 8 |
_letter : 'a'-'z' | 'A'-'Z' | '_' ; |
| 9 |
_digit : '0'-'9' ; |
| 10 |
|
| 11 |
identifier : _letter { _letter } ; |
| 12 |
|
| 13 |
float : _digit { _digit } '.' { _digit } ; |
| 14 |
integer : _digit { _digit } ; |
| 15 |
|
| 16 |
|
| 17 |
Declaration |
| 18 |
: "var" Name Equal Default ";" |
| 19 |
| "var" Name ";" |
| 20 |
; |
| 21 |
|
| 22 |
|
| 23 |
Name |
| 24 |
: identifier |
| 25 |
| "_" |
| 26 |
; |
| 27 |
|
| 28 |
Equal |
| 29 |
: "=" | ":=" |
| 30 |
; |
| 31 |
|
| 32 |
Default |
| 33 |
: identifier | "_" | float | integer |
| 34 |
; |
| 35 |
|