-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnumber.eag
27 lines (21 loc) · 854 Bytes
/
number.eag
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// A simple example referenced in the tutorial for showing how the optional EBNF operator works.
Number <+ sign digits: number>:
<sign> [ <+ 'PLUS': sign> '+' | <+ 'MINUS': sign> '-' ] <+ 'PLUS': sign>
Digits <digits>.
sign = 'PLUS' | 'MINUS'.
number = sign digits .
digits* = | digit digits.
digit = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' .
Digits <+ digits: digits>:
<digits>
{ <+ '0' digits: digits> '0' <digits>
| <+ '1' digits: digits> '1' <digits>
| <+ '2' digits: digits> '2' <digits>
| <+ '3' digits: digits> '3' <digits>
| <+ '4' digits: digits> '4' <digits>
| <+ '5' digits: digits> '5' <digits>
| <+ '6' digits: digits> '6' <digits>
| <+ '7' digits: digits> '7' <digits>
| <+ '8' digits: digits> '8' <digits>
| <+ '9' digits: digits> '9' <digits>
} <+ :digits>.