8 |
|
|
9 |
%tokens |
%tokens |
10 |
: KW_actor ("actor") |
: KW_actor ("actor") |
11 |
|
| KW_bool ("bool") |
12 |
| KW_die ("die") |
| KW_die ("die") |
13 |
|
| KW_else ("else") |
14 |
| KW_field ("field") |
| KW_field ("field") |
15 |
|
| KW_if ("if") |
16 |
| KW_image ("image") |
| KW_image ("image") |
17 |
|
| KW_input ("input") |
18 |
|
| KW_int ("int") |
19 |
|
| KW_kernel ("kernel") |
20 |
| KW_new ("new") |
| KW_new ("new") |
21 |
| KW_stabelize ("stabelize") |
| KW_real ("real") |
22 |
| KW_eq ("=") |
| KW_stabilize ("stabilize") |
23 |
|
| KW_string ("string") |
24 |
|
| KW_tensor ("tensor") |
25 |
|
| KW_vec ("vec") |
26 |
|
| OP_eq ("=") |
27 |
| OP_orelse ("||") |
| OP_orelse ("||") |
28 |
| OP_andalso ("&&") |
| OP_andalso ("&&") |
29 |
| OP_lt ("<") |
| OP_lt ("<") |
43 |
| RB ("]") |
| RB ("]") |
44 |
| LCB ("{") |
| LCB ("{") |
45 |
| RCB ("}") |
| RCB ("}") |
46 |
|
| COMMA (",") |
47 |
|
| SEMICOLON (";") |
48 |
|
| HASH ("#") |
49 |
| INT of IntInf.int |
| INT of IntInf.int |
50 |
| FLOAT of FloatLit.float |
| FLOAT of FloatLit.float |
51 |
| STRING of string |
| STRING of string |
52 |
| ID of Atom.atom |
| ID of Atom.atom |
53 |
; |
; |
54 |
|
|
55 |
|
%defs ( |
56 |
|
(* apply a mark constructor to a span and a tree *) |
57 |
|
fun mark cons (span : AntlrStreamPos.span, tr) = cons{span = span, tree = tr} |
58 |
|
|
59 |
|
); |
60 |
|
|
61 |
File |
File |
62 |
: Decl+ |
: Decl+ |
63 |
; |
; |
105 |
; |
; |
106 |
|
|
107 |
Block |
Block |
108 |
: "{" Statement* "}" |
: "{" Stmt* "}" |
109 |
|
=> (markStmt(FULL_SPAN, PT.S_Block Stmt)) |
110 |
; |
; |
111 |
|
|
112 |
Statement |
Stmt |
113 |
: Type ID "=" Expr ";" |
: AtomicStmt |
114 |
|
=> (AtomicStmt) |
115 |
|
| %try "if" "(" Expr ")" Stmt "else" Stmt |
116 |
|
=> (markStmt(FULL_SPAN, PT.S_IfThenElse(Expr, Stmt1, Stmt2))) |
117 |
|
| %try "if" "(" Expr ")" Stmt |
118 |
|
=> (markStmt(FULL_SPAN, PT.S_IfThen(Expr, Stmt))) |
119 |
|
; |
120 |
|
|
121 |
|
AtomicStmt |
122 |
|
: Block |
123 |
|
=> (Block) |
124 |
|
| "stabilize" ";" |
125 |
|
=> (markStmt(FULL_SPAN, PT.S_Stabilize)) |
126 |
|
| "die" ";" |
127 |
|
=> (markStmt(FULL_SPAN, PT.S_Die)) |
128 |
|
| "new" ID "(" Arguments ")" ";" |
129 |
|
=> (markStmt(FULL_SPAN, PT.S_New(ID, Arguments))) |
130 |
|
| Type ID "=" Expr ";" |
131 |
|
=> (markStmt(FULL_SPAN, PT.S_Decl(Type, ID, Expr))) |
132 |
| ID "=" Expr ";" |
| ID "=" Expr ";" |
133 |
| "if" "(" Expr ")" Statement ("else" Statement)? |
=> (markStmt(FULL_SPAN, PT.S_Assign(ID, Expr))) |
|
| Block |
|
|
| "stable" |
|
|
| "die" |
|
|
| "new" ID "(" Arguments ")" |
|
134 |
; |
; |
135 |
|
|
136 |
Arguments |
Arguments |
156 |
; |
; |
157 |
|
|
158 |
Dimension |
Dimension |
159 |
: POSINT |
: INT |
160 |
; |
; |
161 |
|
|
162 |
(***** Expressions *****) |
(***** Expressions *****) |
173 |
: Expr3 ( CmpOp Expr3 )* |
: Expr3 ( CmpOp Expr3 )* |
174 |
; |
; |
175 |
|
|
176 |
CmpExp |
CmpOp |
177 |
: "<" | "<=" | "==" | ">=" | ">" |
: "<" | "<=" | "==" | ">=" | ">" |
178 |
; |
; |
179 |
|
|
197 |
: Expr6 ( "@" Expr6 | "[" Expr "]" )* |
: Expr6 ( "@" Expr6 | "[" Expr "]" )* |
198 |
; |
; |
199 |
|
|
200 |
|
Expr6 |
201 |
|
: AtomExp |
202 |
|
| "-" AtomExp |
203 |
|
; |
204 |
|
|
205 |
AtomExp |
AtomExp |
206 |
: ID |
: ID |
207 |
| INT |
| INT |