## lustrec / src / parser_lustre.mly @ 71513f0e

History | View | Annotate | Download (15.4 KB)

1 |
/* ---------------------------------------------------------------------------- |
---|---|

2 |
* SchedMCore - A MultiCore Scheduling Framework |

3 |
* Copyright (C) 2009-2011, ONERA, Toulouse, FRANCE - LIFL, Lille, FRANCE |

4 |
* |

5 |
* This file is part of Prelude |

6 |
* |

7 |
* Prelude is free software; you can redistribute it and/or |

8 |
* modify it under the terms of the GNU Lesser General Public License |

9 |
* as published by the Free Software Foundation ; either version 2 of |

10 |
* the License, or (at your option) any later version. |

11 |
* |

12 |
* Prelude is distributed in the hope that it will be useful, but |

13 |
* WITHOUT ANY WARRANTY ; without even the implied warranty of |

14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |

15 |
* Lesser General Public License for more details. |

16 |
* |

17 |
* You should have received a copy of the GNU Lesser General Public |

18 |
* License along with this program ; if not, write to the Free Software |

19 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |

20 |
* USA |

21 |
*---------------------------------------------------------------------------- */ |

22 | |

23 |
%{ |

24 |
open LustreSpec |

25 |
open Corelang |

26 |
open Dimension |

27 |
open Utils |

28 | |

29 |
let mktyp x = mktyp (Location.symbol_rloc ()) x |

30 |
let mkclock x = mkclock (Location.symbol_rloc ()) x |

31 |
let mkvar_decl x = mkvar_decl (Location.symbol_rloc ()) x |

32 |
let mkexpr x = mkexpr (Location.symbol_rloc ()) x |

33 |
let mkeq x = mkeq (Location.symbol_rloc ()) x |

34 |
let mkassert x = mkassert (Location.symbol_rloc ()) x |

35 |
let mktop_decl x = mktop_decl (Location.symbol_rloc ()) x |

36 |
let mkpredef_call x = mkpredef_call (Location.symbol_rloc ()) x |

37 |
let mkpredef_unary_call x = mkpredef_unary_call (Location.symbol_rloc ()) x |

38 | |

39 |
let mkdim_int i = mkdim_int (Location.symbol_rloc ()) i |

40 |
let mkdim_bool b = mkdim_bool (Location.symbol_rloc ()) b |

41 |
let mkdim_ident id = mkdim_ident (Location.symbol_rloc ()) id |

42 |
let mkdim_appl f args = mkdim_appl (Location.symbol_rloc ()) f args |

43 |
let mkdim_ite i t e = mkdim_ite (Location.symbol_rloc ()) i t e |

44 | |

45 |
%} |

46 | |

47 |
%token <int> INT |

48 |
%token <string> REAL |

49 |
%token <float> FLOAT |

50 |
%token AUTOMATON STATE UNTIL UNLESS RESTART RESUME LAST |

51 |
%token STATELESS ASSERT OPEN QUOTE FUNCTION |

52 |
%token <string> IDENT |

53 |
%token <LustreSpec.expr_annot> ANNOT |

54 |
%token <LustreSpec.node_annot> NODESPEC |

55 |
%token LBRACKET RBRACKET LCUR RCUR LPAR RPAR SCOL COL COMMA COLCOL |

56 |
%token AMPERAMPER BARBAR NOT POWER |

57 |
%token IF THEN ELSE |

58 |
%token UCLOCK DCLOCK PHCLOCK TAIL |

59 |
%token MERGE FBY WHEN WHENNOT EVERY |

60 |
%token NODE LET TEL RETURNS VAR IMPORTED SENSOR ACTUATOR WCET TYPE CONST |

61 |
%token STRUCT ENUM |

62 |
%token TINT TFLOAT TREAL TBOOL TCLOCK |

63 |
%token RATE DUE |

64 |
%token EQ LT GT LTE GTE NEQ |

65 |
%token AND OR XOR IMPL |

66 |
%token MULT DIV MOD |

67 |
%token MINUS PLUS UMINUS |

68 |
%token PRE ARROW |

69 | |

70 |
%token EOF |

71 | |

72 |
%nonassoc COMMA |

73 |
%left MERGE IF |

74 |
%nonassoc ELSE |

75 |
%right ARROW FBY |

76 |
%left WHEN WHENNOT UCLOCK DCLOCK PHCLOCK |

77 |
%right COLCOL |

78 |
%right IMPL |

79 |
%left OR XOR BARBAR |

80 |
%left AND AMPERAMPER |

81 |
%left NOT |

82 |
%nonassoc INT |

83 |
%nonassoc EQ LT GT LTE GTE NEQ |

84 |
%left MINUS PLUS |

85 |
%left MULT DIV MOD |

86 |
%left UMINUS |

87 |
%left POWER |

88 |
%left PRE LAST |

89 |
%nonassoc RBRACKET |

90 |
%nonassoc LBRACKET |

91 | |

92 |
%start prog |

93 |
%type <Corelang.top_decl list> prog |

94 |
%start header |

95 |
%type <Corelang.top_decl list> header |

96 | |

97 |
%% |

98 | |

99 |
prog: |

100 |
typ_def_list top_decl_list EOF {$1;(List.rev $2)} |

101 | |

102 |
header: |

103 |
typ_def_list top_decl_header_list EOF {$1;(List.rev $2)} |

104 | |

105 |
top_decl_list: |

106 |
top_decl {[$1]} |

107 |
| top_decl_list top_decl {$2::$1} |

108 | |

109 | |

110 |
top_decl_header_list: |

111 |
top_decl_header {[$1]} |

112 |
| top_decl_header_list top_decl_header {$2::$1} |

113 | |

114 | |

115 |
top_decl_header: |

116 |
| NODE IDENT LPAR vdecl_list SCOL_opt RPAR RETURNS LPAR vdecl_list SCOL_opt RPAR stateless_opt SCOL |

117 |
{let nd = mktop_decl (ImportedNode |

118 |
{nodei_id = $2; |

119 |
nodei_type = Types.new_var (); |

120 |
nodei_clock = Clocks.new_var true; |

121 |
nodei_inputs = List.rev $4; |

122 |
nodei_outputs = List.rev $9; |

123 |
nodei_stateless = $12; |

124 |
nodei_spec = None}) |

125 |
in |

126 |
Hashtbl.add node_table $2 nd; nd} |

127 | |

128 |
| nodespec_list NODE IDENT LPAR vdecl_list SCOL_opt RPAR RETURNS LPAR vdecl_list SCOL_opt RPAR stateless_opt SCOL |

129 |
{let nd = mktop_decl (ImportedNode |

130 |
{nodei_id = $3; |

131 |
nodei_type = Types.new_var (); |

132 |
nodei_clock = Clocks.new_var true; |

133 |
nodei_inputs = List.rev $5; |

134 |
nodei_outputs = List.rev $10; |

135 |
nodei_stateless = $13; |

136 |
nodei_spec = Some $1}) |

137 |
in |

138 |
Hashtbl.add node_table $3 nd; nd} |

139 | |

140 |
| FUNCTION IDENT LPAR vdecl_list SCOL_opt RPAR RETURNS LPAR vdecl_list SCOL_opt RPAR SCOL |

141 |
{let nd = mktop_decl (ImportedNode |

142 |
{nodei_id = $2; |

143 |
nodei_type = Types.new_var (); |

144 |
nodei_clock = Clocks.new_var true; |

145 |
nodei_inputs = List.rev $4; |

146 |
nodei_outputs = List.rev $9; |

147 |
nodei_stateless = true; |

148 |
nodei_spec = None}) |

149 |
in |

150 |
Hashtbl.add node_table $2 nd; nd} |

151 | |

152 |
| nodespec_list FUNCTION IDENT LPAR vdecl_list SCOL_opt RPAR RETURNS LPAR vdecl_list SCOL_opt RPAR SCOL |

153 |
{let nd = mktop_decl (ImportedNode |

154 |
{nodei_id = $3; |

155 |
nodei_type = Types.new_var (); |

156 |
nodei_clock = Clocks.new_var true; |

157 |
nodei_inputs = List.rev $5; |

158 |
nodei_outputs = List.rev $10; |

159 |
nodei_stateless = true; |

160 |
nodei_spec = Some $1}) |

161 |
in |

162 |
Hashtbl.add node_table $3 nd; nd} |

163 | |

164 |
top_decl: |

165 |
| CONST cdecl_list { mktop_decl (Consts (List.rev $2)) } |

166 | |

167 |
| NODE IDENT LPAR vdecl_list SCOL_opt RPAR RETURNS LPAR vdecl_list SCOL_opt RPAR SCOL_opt locals LET eq_list TEL |

168 |
{let eqs, asserts, annots = $15 in |

169 |
let nd = mktop_decl (Node |

170 |
{node_id = $2; |

171 |
node_type = Types.new_var (); |

172 |
node_clock = Clocks.new_var true; |

173 |
node_inputs = List.rev $4; |

174 |
node_outputs = List.rev $9; |

175 |
node_locals = List.rev $13; |

176 |
node_gencalls = []; |

177 |
node_checks = []; |

178 |
node_asserts = asserts; |

179 |
node_eqs = eqs; |

180 |
node_spec = None; |

181 |
node_annot = match annots with [] -> None | _ -> Some annots}) |

182 |
in |

183 |
Hashtbl.add node_table $2 nd; nd} |

184 | |

185 |
| nodespec_list NODE IDENT LPAR vdecl_list SCOL_opt RPAR RETURNS LPAR vdecl_list SCOL_opt RPAR SCOL_opt locals LET eq_list TEL |

186 |
{let eqs, asserts, annots = $16 in |

187 |
let nd = mktop_decl (Node |

188 |
{node_id = $3; |

189 |
node_type = Types.new_var (); |

190 |
node_clock = Clocks.new_var true; |

191 |
node_inputs = List.rev $5; |

192 |
node_outputs = List.rev $10; |

193 |
node_locals = List.rev $14; |

194 |
node_gencalls = []; |

195 |
node_checks = []; |

196 |
node_asserts = asserts; |

197 |
node_eqs = eqs; |

198 |
node_spec = Some $1; |

199 |
node_annot = match annots with [] -> None | _ -> Some annots}) |

200 |
in |

201 |
Hashtbl.add node_table $3 nd; nd} |

202 | |

203 |
| OPEN QUOTE IDENT QUOTE { mktop_decl (Open $3) } |

204 | |

205 |
nodespec_list: |

206 |
NODESPEC { $1 } |

207 |
| NODESPEC nodespec_list { LustreSpec.merge_node_annot $1 $2 } |

208 | |

209 |
stateless_opt: |

210 |
{ false } |

211 |
| STATELESS {true} |

212 | |

213 |
typ_def_list: |

214 |
/* empty */ {} |

215 |
| typ_def SCOL typ_def_list {$1;$3} |

216 | |

217 |
typ_def: |

218 |
TYPE IDENT EQ typeconst { |

219 |
try |

220 |
Hashtbl.add type_table (Tydec_const $2) (Corelang.get_repr_type $4) |

221 |
with Not_found-> raise (Corelang.Unbound_type ($4, Location.symbol_rloc())) } |

222 |
| TYPE IDENT EQ ENUM LCUR tag_list RCUR { Hashtbl.add type_table (Tydec_const $2) (Tydec_enum ($6 (Tydec_const $2))) } |

223 |
| TYPE IDENT EQ STRUCT LCUR field_list RCUR { Hashtbl.add type_table (Tydec_const $2) Tydec_any } |

224 | |

225 |
array_typ_decl: |

226 |
{ fun typ -> typ } |

227 |
| POWER dim array_typ_decl { fun typ -> $3 (Tydec_array ($2, typ)) } |

228 | |

229 |
typeconst: |

230 |
TINT array_typ_decl { $2 Tydec_int } |

231 |
| TBOOL array_typ_decl { $2 Tydec_bool } |

232 |
| TREAL array_typ_decl { $2 Tydec_real } |

233 |
| TFLOAT array_typ_decl { $2 Tydec_float } |

234 |
| IDENT array_typ_decl { $2 (Tydec_const $1) } |

235 |
| TBOOL TCLOCK { Tydec_clock Tydec_bool } |

236 |
| IDENT TCLOCK { Tydec_clock (Tydec_const $1) } |

237 | |

238 |
tag_list: |

239 |
IDENT |

240 |
{ (fun t -> if Hashtbl.mem tag_table $1 |

241 |
then raise (Corelang.Already_bound_label ($1, t, Location.symbol_rloc ())) |

242 |
else (Hashtbl.add tag_table $1 t; $1 :: [])) } |

243 |
| tag_list COMMA IDENT |

244 |
{ (fun t -> if Hashtbl.mem tag_table $3 |

245 |
then raise (Corelang.Already_bound_label ($3, t, Location.symbol_rloc ())) |

246 |
else (Hashtbl.add tag_table $3 t; $3 :: ($1 t))) } |

247 | |

248 |
field_list: |

249 |
{ [] } |

250 |
| IDENT COL typeconst SCOL field_list { ($1, $3) :: $5 } |

251 | |

252 |
eq_list: |

253 |
{ [], [], [] } |

254 |
| eq eq_list {let eql, assertl, annotl = $2 in ($1::eql), assertl, annotl} |

255 |
| assert_ eq_list {let eql, assertl, annotl = $2 in eql, ($1::assertl), annotl} |

256 |
| ANNOT eq_list {let eql, assertl, annotl = $2 in eql, assertl, $1@annotl} |

257 |
| automaton eq_list {let eql, assertl, annotl = $2 in ($1::eql), assertl, annotl} |

258 | |

259 |
automaton: |

260 |
AUTOMATON IDENT handler_list { failwith "not implemented" } |

261 | |

262 |
handler_list: |

263 |
{ [] } |

264 |
| handler handler_list { $1::$2 } |

265 | |

266 |
handler: |

267 |
STATE IDENT ARROW unless_list locals LET eq_list TEL until_list { () } |

268 | |

269 |
unless_list: |

270 |
{ [] } |

271 |
| unless unless_list { $1::$2 } |

272 | |

273 |
until_list: |

274 |
{ [] } |

275 |
| until until_list { $1::$2 } |

276 | |

277 |
unless: |

278 |
UNLESS expr RESTART IDENT { } |

279 |
| UNLESS expr RESUME IDENT { } |

280 | |

281 |
until: |

282 |
UNTIL expr RESTART IDENT { } |

283 |
| UNTIL expr RESUME IDENT { } |

284 | |

285 |
assert_: |

286 |
| ASSERT expr SCOL {mkassert ($2)} |

287 | |

288 |
eq: |

289 |
ident_list EQ expr SCOL {mkeq (List.rev $1,$3)} |

290 |
| LPAR ident_list RPAR EQ expr SCOL {mkeq (List.rev $2,$5)} |

291 | |

292 |
tuple_expr: |

293 |
expr COMMA expr {[$3;$1]} |

294 |
| tuple_expr COMMA expr {$3::$1} |

295 | |

296 |
// Same as tuple expr but accepting lists with single element |

297 |
array_expr: |

298 |
expr {[$1]} |

299 |
| expr COMMA array_expr {$1::$3} |

300 | |

301 |
dim_list: |

302 |
dim RBRACKET { fun base -> mkexpr (Expr_access (base, $1)) } |

303 |
| dim RBRACKET LBRACKET dim_list { fun base -> $4 (mkexpr (Expr_access (base, $1))) } |

304 | |

305 |
expr: |

306 |
/* constants */ |

307 |
INT {mkexpr (Expr_const (Const_int $1))} |

308 |
| REAL {mkexpr (Expr_const (Const_real $1))} |

309 |
| FLOAT {mkexpr (Expr_const (Const_float $1))} |

310 |
/* Idents or type enum tags */ |

311 |
| IDENT { |

312 |
if Hashtbl.mem tag_table $1 |

313 |
then mkexpr (Expr_const (Const_tag $1)) |

314 |
else mkexpr (Expr_ident $1)} |

315 |
| LPAR ANNOT expr RPAR |

316 |
{update_expr_annot $3 $2} |

317 |
| LPAR expr RPAR |

318 |
{$2} |

319 |
| LPAR tuple_expr RPAR |

320 |
{mkexpr (Expr_tuple (List.rev $2))} |

321 | |

322 |
/* Array expressions */ |

323 |
| LBRACKET array_expr RBRACKET { mkexpr (Expr_array $2) } |

324 |
| expr POWER dim { mkexpr (Expr_power ($1, $3)) } |

325 |
| expr LBRACKET dim_list { $3 $1 } |

326 | |

327 |
/* Temporal operators */ |

328 |
| PRE expr |

329 |
{mkexpr (Expr_pre $2)} |

330 |
| expr ARROW expr |

331 |
{mkexpr (Expr_arrow ($1,$3))} |

332 |
| expr FBY expr |

333 |
{(*mkexpr (Expr_fby ($1,$3))*) |

334 |
mkexpr (Expr_arrow ($1, mkexpr (Expr_pre $3)))} |

335 |
| expr WHEN IDENT |

336 |
{mkexpr (Expr_when ($1,$3,tag_true))} |

337 |
| expr WHENNOT IDENT |

338 |
{mkexpr (Expr_when ($1,$3,tag_false))} |

339 |
| expr WHEN IDENT LPAR IDENT RPAR |

340 |
{mkexpr (Expr_when ($1, $5, $3))} |

341 |
| MERGE IDENT handler_expr_list |

342 |
{mkexpr (Expr_merge ($2,$3))} |

343 | |

344 |
/* Applications */ |

345 |
| IDENT LPAR expr RPAR |

346 |
{mkexpr (Expr_appl ($1, $3, None))} |

347 |
| IDENT LPAR expr RPAR EVERY IDENT |

348 |
{mkexpr (Expr_appl ($1, $3, Some ($6, tag_true)))} |

349 |
| IDENT LPAR expr RPAR EVERY IDENT LPAR IDENT RPAR |

350 |
{mkexpr (Expr_appl ($1, $3, Some ($8, $6))) } |

351 |
| IDENT LPAR tuple_expr RPAR |

352 |
{mkexpr (Expr_appl ($1, mkexpr (Expr_tuple (List.rev $3)), None))} |

353 |
| IDENT LPAR tuple_expr RPAR EVERY IDENT |

354 |
{mkexpr (Expr_appl ($1, mkexpr (Expr_tuple (List.rev $3)), Some ($6, tag_true))) } |

355 |
| IDENT LPAR tuple_expr RPAR EVERY IDENT LPAR IDENT RPAR |

356 |
{mkexpr (Expr_appl ($1, mkexpr (Expr_tuple (List.rev $3)), Some ($8, $6))) } |

357 | |

358 |
/* Boolean expr */ |

359 |
| expr AND expr |

360 |
{mkpredef_call "&&" [$1;$3]} |

361 |
| expr AMPERAMPER expr |

362 |
{mkpredef_call "&&" [$1;$3]} |

363 |
| expr OR expr |

364 |
{mkpredef_call "||" [$1;$3]} |

365 |
| expr BARBAR expr |

366 |
{mkpredef_call "||" [$1;$3]} |

367 |
| expr XOR expr |

368 |
{mkpredef_call "xor" [$1;$3]} |

369 |
| NOT expr |

370 |
{mkpredef_unary_call "not" $2} |

371 |
| expr IMPL expr |

372 |
{mkpredef_call "impl" [$1;$3]} |

373 | |

374 |
/* Comparison expr */ |

375 |
| expr EQ expr |

376 |
{mkpredef_call "=" [$1;$3]} |

377 |
| expr LT expr |

378 |
{mkpredef_call "<" [$1;$3]} |

379 |
| expr LTE expr |

380 |
{mkpredef_call "<=" [$1;$3]} |

381 |
| expr GT expr |

382 |
{mkpredef_call ">" [$1;$3]} |

383 |
| expr GTE expr |

384 |
{mkpredef_call ">=" [$1;$3]} |

385 |
| expr NEQ expr |

386 |
{mkpredef_call "!=" [$1;$3]} |

387 | |

388 |
/* Arithmetic expr */ |

389 |
| expr PLUS expr |

390 |
{mkpredef_call "+" [$1;$3]} |

391 |
| expr MINUS expr |

392 |
{mkpredef_call "-" [$1;$3]} |

393 |
| expr MULT expr |

394 |
{mkpredef_call "*" [$1;$3]} |

395 |
| expr DIV expr |

396 |
{mkpredef_call "/" [$1;$3]} |

397 |
| MINUS expr %prec UMINUS |

398 |
{mkpredef_unary_call "uminus" $2} |

399 |
| expr MOD expr |

400 |
{mkpredef_call "mod" [$1;$3]} |

401 | |

402 |
/* If */ |

403 |
| IF expr THEN expr ELSE expr |

404 |
{mkexpr (Expr_ite ($2, $4, $6))} |

405 | |

406 |
handler_expr_list: |

407 |
{ [] } |

408 |
| handler_expr handler_expr_list { $1 :: $2 } |

409 | |

410 |
handler_expr: |

411 |
LPAR IDENT ARROW expr RPAR { ($2, $4) } |

412 | |

413 |
signed_const_array: |

414 |
| signed_const { [$1] } |

415 |
| signed_const COMMA signed_const_array { $1 :: $3 } |

416 | |

417 |
signed_const: |

418 |
INT {Const_int $1} |

419 |
| REAL {Const_real $1} |

420 |
| FLOAT {Const_float $1} |

421 |
| IDENT {Const_tag $1} |

422 |
| MINUS INT {Const_int (-1 * $2)} |

423 |
| MINUS REAL {Const_real ("-" ^ $2)} |

424 |
| MINUS FLOAT {Const_float (-1. *. $2)} |

425 |
| LBRACKET signed_const_array RBRACKET { Const_array $2 } |

426 | |

427 |
dim: |

428 |
INT { mkdim_int $1 } |

429 |
| LPAR dim RPAR { $2 } |

430 |
| IDENT { mkdim_ident $1 } |

431 |
| dim AND dim |

432 |
{mkdim_appl "&&" [$1;$3]} |

433 |
| dim AMPERAMPER dim |

434 |
{mkdim_appl "&&" [$1;$3]} |

435 |
| dim OR dim |

436 |
{mkdim_appl "||" [$1;$3]} |

437 |
| dim BARBAR dim |

438 |
{mkdim_appl "||" [$1;$3]} |

439 |
| dim XOR dim |

440 |
{mkdim_appl "xor" [$1;$3]} |

441 |
| NOT dim |

442 |
{mkdim_appl "not" [$2]} |

443 |
| dim IMPL dim |

444 |
{mkdim_appl "impl" [$1;$3]} |

445 | |

446 |
/* Comparison dim */ |

447 |
| dim EQ dim |

448 |
{mkdim_appl "=" [$1;$3]} |

449 |
| dim LT dim |

450 |
{mkdim_appl "<" [$1;$3]} |

451 |
| dim LTE dim |

452 |
{mkdim_appl "<=" [$1;$3]} |

453 |
| dim GT dim |

454 |
{mkdim_appl ">" [$1;$3]} |

455 |
| dim GTE dim |

456 |
{mkdim_appl ">=" [$1;$3]} |

457 |
| dim NEQ dim |

458 |
{mkdim_appl "!=" [$1;$3]} |

459 | |

460 |
/* Arithmetic dim */ |

461 |
| dim PLUS dim |

462 |
{mkdim_appl "+" [$1;$3]} |

463 |
| dim MINUS dim |

464 |
{mkdim_appl "-" [$1;$3]} |

465 |
| dim MULT dim |

466 |
{mkdim_appl "*" [$1;$3]} |

467 |
| dim DIV dim |

468 |
{mkdim_appl "/" [$1;$3]} |

469 |
| MINUS dim %prec UMINUS |

470 |
{mkdim_appl "uminus" [$2]} |

471 |
| dim MOD dim |

472 |
{mkdim_appl "mod" [$1;$3]} |

473 |
/* If */ |

474 |
| IF dim THEN dim ELSE dim |

475 |
{mkdim_ite $2 $4 $6} |

476 | |

477 |
locals: |

478 |
{[]} |

479 |
| VAR vdecl_list SCOL {$2} |

480 | |

481 |
vdecl_list: |

482 |
vdecl {$1} |

483 |
| vdecl_list SCOL vdecl {$3 @ $1} |

484 | |

485 |
vdecl: |

486 |
/* Useless no ?*/ ident_list |

487 |
{List.map mkvar_decl |

488 |
(List.map (fun id -> (id, mktyp Tydec_any, mkclock Ckdec_any, false)) $1)} |

489 | |

490 |
| ident_list COL typeconst clock |

491 |
{List.map mkvar_decl (List.map (fun id -> (id, mktyp $3, $4, false)) $1)} |

492 |
| CONST ident_list COL typeconst /* static parameters don't have clocks */ |

493 |
{List.map mkvar_decl (List.map (fun id -> (id, mktyp $4, mkclock Ckdec_any, true)) $2)} |

494 | |

495 |
cdecl_list: |

496 |
cdecl SCOL { [$1] } |

497 |
| cdecl_list cdecl SCOL { $2::$1 } |

498 | |

499 |
cdecl: |

500 |
IDENT EQ signed_const { |

501 |
let c = { |

502 |
const_id = $1; |

503 |
const_loc = Location.symbol_rloc (); |

504 |
const_type = Types.new_var (); |

505 |
const_value = $3; |

506 |
} in |

507 |
Hashtbl.add consts_table $1 c; c |

508 |
} |

509 | |

510 |
clock: |

511 |
{mkclock Ckdec_any} |

512 |
| when_list |

513 |
{mkclock (Ckdec_bool (List.rev $1))} |

514 | |

515 |
when_cond: |

516 |
WHEN IDENT {($2, tag_true)} |

517 |
| WHENNOT IDENT {($2, tag_false)} |

518 |
| WHEN IDENT LPAR IDENT RPAR {($4, $2)} |

519 | |

520 |
when_list: |

521 |
when_cond {[$1]} |

522 |
| when_list when_cond {$2::$1} |

523 | |

524 |
ident_list: |

525 |
IDENT {[$1]} |

526 |
| ident_list COMMA IDENT {$3::$1} |

527 | |

528 |
SCOL_opt: |

529 |
SCOL {} | {} |