-
Notifications
You must be signed in to change notification settings - Fork 0
/
syntax7
101 lines (70 loc) · 2.09 KB
/
syntax7
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
95
96
97
<id> := <set-id>
| <val-id>
<val-id> := <cons-id>
| <fun-id>
| <arg-id>
<value> := <constant>
| <prim>
| <val-id>
| <cons-id>( <vals> )
<vals> := epsilon
| <value> { , <value> }*
<defn> := <set-id> = <expr>
| <fun-id> ( <formals> ) = <expr>
| <cons-id> ( <selectors> ) : <fun-id>
<formals> := epsilon
| <arg-id> { , <arg-id> }*
<selectors> := epsilon
| <fun-id> { , <fun-id> }*
<inits> := epsilon
| <arg-id> = <expr> { , <arg-id> = <expr> }*
<seq> := <expr> { , <expr> }*
<args> := epsilon
| <seq>
<lval> := <set-id>
| <expr> [ <seq> ]
<expr> := <value>
| <set-id>
| <expr> ( <args> )
| <expr> [ <seq> ]
| <prim> ( <args> )
| if <expr> then <expr> { elseif <expr> then <expr> }*
( { else <expr> } | { endif } )
| let <defn>* in <expr>
| do <args> and <expr>
| set <lval> to <expr>
| call <fun-id> ( <inits> ) <expr>
| <uop> <expr>
| <expr> <bop> <expr>
| [ <seq> { ; <seq> }* ] ;; we need a rep for all tuples and arrays
| ( <expr> )
<uop> := - | + | ~
<bop> := + | - | * | / | ^ | = | <= | >= | =/= | < | > | & | |
<prim> := tuple? | tabulate | size(?)
| array? | makearray | size(?)
| symbol?
| number? | zero? | positive? | add1 | sub1 | odd? | sqrt | log
| sin | cos | tan | atan
| function?
| equal?
<constant> := true | false
| <symbol>
| <string>
| <number>
<symbol> := ` <char>* '
<string> := " <char>* "
<char> := <charset> \ { \ , ` , ' , " , tab , newline}
| \\ | \` | \'| \" | \n | \t
<number> := <real>
| <imag>
<imag> := <real> i
<real> := <sign> <ureal>
<sign> := epsilon | + | -
<ureal> := <int>
| . <digit>+ <suffix>
| <digit>+ . <digit>* <suffix>
<int> := <digit>+ <suffix>
<suffix> := epsilon
| e <sign> <digit>+
<digit> := 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
where <charset> is currently left unspecified.