-
Notifications
You must be signed in to change notification settings - Fork 0
/
grammar
62 lines (50 loc) · 807 Bytes
/
grammar
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
51
52
53
54
55
56
57
58
59
60
61
62
simplified version:
t := fun t -> t
let t = t in t
let rec t = t in t
if t then t else t
var
const
true
false
()
op t
t op t
t t
(t)
(t,t)
t;t
t;
Non-terminal symbols: {E, F, G, H}
Terminal symbols: {var, const, let, in, if, then, else, fun, ->, op0, op1, op2, (, ), rec, true, false}
Starting symbol: E
Priority from highest to lowest:
{>,>=,<,<=,=}
{+,-}
{%,/,*}
{fst,snd,-;print} (prefix)
Applications share the same priority as prefixes.
Derivations:
E -> | F_0
| E op F
| E;E
F_0 -> | F_1
| F_0 op F_1
...
(1 <= k < n)
F_k -> | F_(k+1)
| F_k op F_(k+1)
...
F_n -> | G
| op F_n
| H I // Application
G ->| let var = E in E
| if E then E else E
| fun var -> E
| let rec var = E in E
| const
| var
| true
| false
| (E)
| (E,E)