-
Notifications
You must be signed in to change notification settings - Fork 21
/
js-core-syntax.k
86 lines (74 loc) · 3.05 KB
/
js-core-syntax.k
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
require "builtins/bool.k"
require "builtins/int.k"
require "builtins/float.k"
require "builtins/string.k"
module JS-CORE-SYNTAX
imports BOOL-SYNTAX-HOOKS
imports INT-SYNTAX-HOOKS
imports FLOAT-SYNTAX-HOOKS
imports STRING-SYNTAX-HOOKS
syntax Pgm ::= Stmt
syntax Stmt ::= "%fdecl" "(" Var "," Exps "," Stmt ")"
| "%vdecl" "(" Var ")"
| "%seq" "(" Stmt "," Stmt ")"
| "%exp" "(" Exp ")"
| "%if" "(" Exp "," Stmt "," Stmt ")"
| "%do" "(" Stmt "," Exp ")"
| "%while" "(" Exp "," Stmt ")"
| "%for" "(" Stmt "," Exp "," Exp "," Stmt ")" // for ( _ ; _ ; _ ) _
| "%forin" "(" Stmt "," Exp "," Exp "," Stmt ")" // for ( _ _ in _ ) _
| "%continue" "(" Var ")"
| "%break" "(" Var ")"
| "%label" "(" Var "," Stmt ")"
| "%return" "(" Exp ")"
| "%throw" "(" Exp ")"
| "%try" "(" Stmt "," Var "," Stmt "," Stmt ")" // try _ catch ( _ ) _ finally _
| "%try" "(" Stmt "," Stmt ")" // try _ finally _ // NOTE: this is hard to be represented in the above general form
| "%with" "(" Exp "," Stmt ")"
| "%emptyStmt"
| "%switch" "(" Exp "," Stmt "," Stmt "," Stmt ")" // switch ( _ ) { _ _ _ }
| "%case" "(" Exp "," Stmt ")" // case _ : _
| "%default" "(" Stmt ")" // default : _
| "%debugger"
syntax Exp ::= "%con" "(" Const ")"
| "%var" "(" Var ")"
| "%arr" "(" Exps ")"
| "%obj" "(" Exps ")"
| "%prop" "(" Var "," Exp ")"
| "%get" "(" Var "," Stmt ")"
| "%set" "(" Var "," Var "," Stmt ")"
| "%mem" "(" Exp "," Exp ")"
| "%new" "(" Exp "," Exps ")"
| "%call" "(" Exp "," Exps ")"
| "%comma" "(" Exp "," Exp ")"
| "%pre" "(" Op "," Exp ")"
| "%post" "(" Exp "," Op ")"
| "%bop" "(" Op "," Exp "," Exp ")"
| "%bopassign" "(" Op "," Exp "," Exp ")"
| "%cond" "(" Exp "," Exp "," Exp ")"
| "%emptyExp"
| "%fun" "(" Var "," Exps "," Stmt ")"
| "%fun" "(" Exps "," Stmt ")"
syntax Exps ::= "%cons" "(" Exp "," Exps ")"
| "%nil"
syntax Const ::= "%this"
| "%null"
| Bool
| Int
| Float
| String
syntax Var ::= String
syntax Op ::= "%inc" | "%dec"
| OpNormal
| OpShortcut
| "%assign"
syntax OpNormal ::= "%plus" | "%minus" | "%tilde" | "%bang"
| "%delete" | "%void" | "%typeof"
| "%times" | "%div" | "%mod"
| "%lshift" | "%rshift" | "%rshiftshift"
| "%lt" | "%gt" | "%le" | "%ge"
| "%instanceof" | "%in"
| "%eq" | "%neq" | "%eqs" | "%neqs"
| "%amp" | "%caret" | "%bar"
syntax OpShortcut ::= "%and" | "%or"
endmodule