-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrammar.txt
More file actions
44 lines (29 loc) · 1.13 KB
/
grammar.txt
File metadata and controls
44 lines (29 loc) · 1.13 KB
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
SCAML BNF
<program> ::= <top_level>
| <program> <top_level>
<top_level> ::= <global def> | <expr>;;
<global def> ::= let <var> (<var1>:<type1> <varn>:<typen>):<type> = <expr>;; (n >= 0)
| let <var>:<type> = <expr>;; Variable definition
<local def> ::= let <var> (<var1>:<type1> <varn>:<typen>):<type> = <expr> in <expr>
| let <var>:<type> = <expr> in <expr> Variable definition
<expr> ::= <aexpr> Atomic expression
| <local def>
| <conditional>
| (<expr> <list aexpr>) Function application
<aexpr> ::= (<expr>) Parenthesized expression
| <var>
| <set> Set or language
| <int>
| <string>
| <built in> Built-in functions
<list aexpr> ::= <aexpr1> <aexpr2> <aexprn> (n >= 0)
<conditional> ::= if <aexpr> then <aexpr> else <aexpr>
<var> ::= <alpha1><alpha2><alphan> (n >= 1) & (<var> must not be in <keyword>)
<word> ::= <alpha1><alpha2><alphan>
| : Empty word
<set> ::= {<word1>, <wordn>} (n >= 0) & (all words are different)
<type> ::= int | string | set | bool
<built in> ::= cons | head | tail | == | + | - | strcomp | strapp
<keyword> ::= <built in>
| if | then | else | let | in
| <type>