-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGRAMMAR.txt
94 lines (73 loc) · 1.45 KB
/
GRAMMAR.txt
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
## Evaluation grammar for cfl
x ::= ( a | b | ... | z )
( a | b | ... | z
| A | B | ... | Z
| 0 | 1 | ... | 9
| _ )* (')*
c ::= (c, c, ..., c)
| _
| x
v ::= x
| true | false
| 0 | 1 | -1 | 2 | -2 | ...
| function c -> e
| [e, e, ..., e]
| (e, e, ..., e)
e ::= v
| "(" e ")"
| e && e | e "||" e | !e
| e "+" e | e "*" e | e / e
| e == e | e < e
| e e
| if e then e else e
| let rec x c = e in e
| e : e | e ++ e
| case e of [] -> e "|" (c : x) -> e
## Parseable grammar for cfl
x ::= ( a | b | ... | z )
( a | b | ... | z
| A | B | ... | Z
| 0 | 1 | ... | 9
| _ )* (')*
c ::= (c, c, ..., c)
| _
| x
a ::= x
| true | false
| 0 | 1 | -1 | 2 | -2 | ...
| !a
| (e)
| [e, e, ..., e]
| (e, e, ..., e)
m ::= a a
| a
f ::= m * f | m / f | m % f
| m
r ::= f + r | f - r
| f
p ::= r == r | r != r
| r < r | r <= r | r > r | r >= r |
| r
l ::= p : l
| p
g ::= l ++ g |
| l
b ::= g "&&" b
| g
n ::= b "||" n
| b
s ::= n . s
| n
e ::= function c -> e
| if e then e else e
| let c = e in e
| let x c ... c = e in e
| case e of [] -> e "|" (x : x) -> e
| s $ e
| s
s ::= c = e
| x c ... c = e
d ::= s
| s ; d
p ::= d ; main = e
| main = e