forked from linkrope/gamma
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathebnf.eag
50 lines (41 loc) · 942 Bytes
/
ebnf.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// This EAG shows the use of EBNF expressions for group, option, and repetition
// with corresponding parameters.
// The meaning is defined by the lowering in the related example/bnf/ebnf.eag.
S = S ',' S | L.
S <+ L1 ',' L2 ',' L3: S>:
Group <L1> ',' Option <L2> ',' Repetition <L3>
| GroupSubrule <L1> ',' OptionSubrule <L2> ',' RepetitionSubrule <L3>.
L = 'a' L | 'b' L | .
Group:
( <+ 'a': L> 'a'
| <+ 'b': L> 'b'
).
Option:
[ <+ 'a': L> 'a'
| <+ 'b': L> 'b'
] <+ : L>.
Repetition:
{ <+ 'a' L: L> 'a' <L>
| <+ 'b' L: L> 'b' <L>
} <+ : L>.
GroupSubrule <+ L>:
'"'
<L>
( <+ 'a': L> 'a'
| <+ 'b': L> 'b'
)
'"'.
OptionSubrule <+ L>:
'"'
<L>
[ <+ 'a': L> 'a'
| <+ 'a': L> 'b'
] <+ : L>
'"'.
RepetitionSubrule <+L>:
'"'
<L>
{ <+ 'a' L: L> 'a' <L>
| <+ 'b' L: L> 'b' <L>
} <+ : L>
'"'.