-
Notifications
You must be signed in to change notification settings - Fork 1
/
Haskal.cf
77 lines (55 loc) · 1.66 KB
/
Haskal.cf
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
comment "//" ;
comment "/*" "*/" ;
BoolT. Boolean ::= "True" ;
BoolF. Boolean ::= "False" ;
-- EXPRESSIONS
EEq. Exp ::= Exp "==" Exp ;
ENeq. Exp ::= Exp "!=" Exp ;
ELsr. Exp ::= Exp "<" Exp ;
EGtr. Exp ::= Exp ">" Exp ;
ELeq. Exp ::= Exp "<=" Exp ;
EGeq. Exp ::= Exp ">=" Exp ;
EAdd. Exp1 ::= Exp1 "+" Exp1 ;
ESub. Exp1 ::= Exp1 "-" Exp1 ;
EMul. Exp2 ::= Exp2 "*" Exp2 ;
EDiv. Exp2 ::= Exp2 "/" Exp2 ;
EInt. Exp4 ::= Integer ;
EOr. Exp1 ::= Exp1 "||" Exp1 ;
EAnd. Exp2 ::= Exp2 "&&" Exp2 ;
ENot. Exp3 ::= "!" Exp3 ;
EBool. Exp4 ::= Boolean ;
EVar. Exp4 ::= Ident ;
coercions Exp 4 ;
-- STATEMENTS
separator Stmt ";" ;
separator Arg "," ;
SIf. Stmt ::= "if" "(" Exp ")" Stmt ;
SIfElse. Stmt ::= "if" "(" Exp ")" Stmt "else" Stmt ;
SPrint. Stmt ::= "print" Exp ;
SWhile. Stmt ::= "while" "(" Exp ")" Stmt ;
SAssign. Stmt ::= Ident AssignOp Exp ;
SIter. Stmt ::= Ident IterOp ;
SCompound. Stmt ::= "{" [Stmt] "}" ;
SProcCall. Stmt ::= Ident "(" [Arg] ")" ;
Assign. AssignOp ::= "=" ;
AssignMul. AssignOp ::= "*=" ;
AssignDiv. AssignOp ::= "/=" ;
AssignAdd. AssignOp ::= "+=" ;
AssignSub. AssignOp ::= "-=" ;
AssignAnd. AssignOp ::= "&=" ;
AssignOr. AssignOp ::= "|=" ;
IterInc. IterOp ::= "++" ;
IterDec. IterOp ::= "--" ;
-- DECLARATIONS
terminator Decl ";" ;
separator Param "," ;
TBool. TypeSpec ::= "bool" ;
TInt. TypeSpec ::= "int" ;
PVar. ParamSpec ::= "var" ;
PVal. ParamSpec ::= "val" ;
ExpArg. Arg ::= Exp ;
ParamDecl. Param ::= ParamSpec TypeSpec Ident ;
VarDecl. Decl ::= "var" TypeSpec Ident ;
ProcDecl. Decl ::= "proc" Ident "(" [Param] ")" Block ;
-- BLOCK
ScopeBlock. Block ::= [Decl] Stmt ;