lustreParser.opp.exp 21.3 KB
Newer Older
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 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397
Warning: you are using the standard library and/or the %inline keyword. We
recommend switching on --infer in order to avoid obscure type error messages.
%{

module I = LustreIdent
module A = LustreAst

let mk_pos = Lib.position_of_lexing 

%}
%start main
%token WITH
%token VAR
%token TYPE
%token TRUE
%token THEN
%token TEL
%token <string> SYM
%token SUBRANGE
%token STRUCT
%token SEMICOLON
%token RSQBRACKET
%token RPAREN
%token RPARAMBRACKET
%token RETURNS
%token REQUIRES
%token RCURLYBRACKET
%token PROPERTY
%token OF
%token <string> NUMERAL
%token NODE
%token MAIN
%token LSQBRACKET
%token LPAREN
%token LPARAMBRACKET
%token LET
%token LCURLYBRACKET
%token IF
%token HASH
%token FUNCTION
%token FBY
%token FALSE
%token EOF
%token ENUM
%token ENSURES
%token DOTDOT
%token DOT
%token <string> DECIMAL
%token CONST
%token CONDACT
%token COMMA
%token COLON
%token BOOL
%token ASSERT
%token PIPE
%token ELSE
%token ARROW
%token IMPL
%token XOR
%token OR
%token AND
%token NEQ
%token LTE
%token LT
%token GTE
%token GT
%token EQUALS
%token PLUS
%token MINUS
%token MULT
%token MOD
%token INTDIV
%token DIV
%token WHEN
%token NOT
%token CURRENT
%token PRE
%token CARET
%token REAL
%token INT
%left PIPE 
%nonassoc ELSE 
%right ARROW 
%right IMPL 
%left XOR OR 
%left AND 
%left NEQ LTE LT GTE GT EQUALS 
%left PLUS MINUS 
%left MULT MOD INTDIV DIV 
%nonassoc WHEN 
%nonassoc NOT 
%nonassoc CURRENT 
%nonassoc PRE 
%left CARET 
%nonassoc REAL INT 
%type <LustreAst.t> main
%%

main:
| p = list_decl_ _2 = EOF
    {                         ( List.flatten p )}

decl:
| d = const_decl
    {                   ( List.map 
                       (function e -> A.ConstDecl (mk_pos _startpos, e)) 
                       d )}
| d = type_decl
    {                  ( List.map 
                      (function e -> A.TypeDecl (mk_pos _startpos, e)) 
                      d )}
| d = node_decl
    {                  ( [A.NodeDecl (mk_pos _startpos, d)] )}
| d = func_decl
    {                  ( [A.FuncDecl (mk_pos _startpos, d)] )}
| d = node_param_inst
    {                        ( [A.NodeParamInst (mk_pos _startpos, d)] )}

const_decl:
| _1 = CONST l = nonempty_list_const_decl_body_
    {                                                      ( List.flatten l )}

const_decl_body:
| h = ident _2 = COLON t = lustre_type _4 = SEMICOLON
    {    ( [A.FreeConst (mk_pos _startpos, h, t)] )}
| h = ident _2 = COMMA l = ident_list _4 = COLON t = lustre_type _6 = SEMICOLON
    {    ( List.map (function e -> A.FreeConst (mk_pos _startpos, e, t)) (h :: l) )}
| s = ident _2 = EQUALS e = expr _4 = SEMICOLON
    {    ( [A.UntypedConst (mk_pos _startpos, s, e)] )}
| c = typed_ident _2 = EQUALS e = expr _4 = SEMICOLON
    {    ( let (s, t) = c in [A.TypedConst (mk_pos _startpos, s, e, t)] )}

array_type:
| t = lustre_type _2 = CARET s = expr
    {                                     ( t, s )}

enum_type:
| _1 = ENUM _2 = LCURLYBRACKET l = ident_list _4 = RCURLYBRACKET
    {                                                             ( l )}

func_decl:
| _1 = FUNCTION n = ident i = tlist_LPAREN_SEMICOLON_RPAREN_typed_idents_ _4 = RETURNS o = tlist_LPAREN_SEMICOLON_RPAREN_typed_idents_ _6 = SEMICOLON
    {    ( (n, List.flatten i, List.flatten o)  )}

node_decl:
| _1 = NODE n = ident p = loption_static_params_ i = tlist_LPAREN_SEMICOLON_RPAREN_const_clocked_typed_idents_ _5 = RETURNS o = tlist_LPAREN_SEMICOLON_RPAREN_clocked_typed_idents_ _7 = SEMICOLON r = contract l = list_node_local_decl_ _10 = LET e = list_node_equation_ _12 = TEL _13 = option_node_sep_
    {    ( (n, 
       p,
       List.flatten i, 
       List.flatten o, 
       (List.flatten l), 
       e,
       r)  )}

node_param_inst:
| _1 = NODE n = ident _3 = EQUALS s = ident p = tlist_LPARAMBRACKET_SEMICOLON_RPARAMBRACKET_node_call_static_param_ _6 = SEMICOLON
    {    ( (n, s, p) )}

contract:
| l = list_contract_clause_
    {                              ( l )}

loption_static_params_:
| 
    {    ( [] )}
| x = static_params
    {    ( x )}

loption_separated_nonempty_list_COMMA_expr__:
| 
    {    ( [] )}
| x = separated_nonempty_list_COMMA_expr_
    {    ( x )}

list_node_local_decl_:
| 
    {    ( [] )}
| x = node_local_decl xs = list_node_local_decl_
    {    ( x :: xs )}

list_node_equation_:
| 
    {    ( [] )}
| x = node_equation xs = list_node_equation_
    {    ( x :: xs )}

list_decl_:
| 
    {    ( [] )}
| x = decl xs = list_decl_
    {    ( x :: xs )}

list_contract_clause_:
| 
    {    ( [] )}
| x = contract_clause xs = list_contract_clause_
    {    ( x :: xs )}

nonempty_list_one_index_:
| x = one_index
    {    ( [ x ] )}
| x = one_index xs = nonempty_list_one_index_
    {    ( x :: xs )}

nonempty_list_const_decl_body_:
| x = const_decl_body
    {    ( [ x ] )}
| x = const_decl_body xs = nonempty_list_const_decl_body_
    {    ( x :: xs )}

type_decl:
| _1 = TYPE l = ident_list _3 = SEMICOLON
    {     ( List.map (function e -> A.FreeType (mk_pos _startpos, e)) l )}
| _1 = TYPE l = ident_list _3 = EQUALS t = lustre_type _5 = SEMICOLON
    {     ( List.map (function e -> A.AliasType (mk_pos _startpos, e, t)) l )}
| _1 = TYPE l = ident_list _3 = EQUALS t = record_type _5 = SEMICOLON
    {     ( List.map 
         (function e -> 
           A.AliasType (mk_pos _startpos, 
                        e, 
                        A.RecordType (mk_pos _startpos, t))) 
         l )}

lustre_type:
| _1 = BOOL
    {         ( A.Bool (mk_pos _startpos) )}
| _1 = INT
    {        ( A.Int (mk_pos _startpos))}
| _1 = REAL
    {         ( A.Real (mk_pos _startpos))}
| _1 = SUBRANGE _2 = LSQBRACKET l = expr _4 = COMMA u = expr _6 = RSQBRACKET _7 = OF _8 = INT
    {    ( A.IntRange (mk_pos _startpos, l, u))}
| s = ident
    {              ( A.UserType (mk_pos _startpos, s) )}
| t = tuple_type
    {                   ( A.TupleType (mk_pos _startpos, t) )}
| t = array_type
    {                   ( A.ArrayType (mk_pos _startpos, t) )}
| t = enum_type
    {                  ( A.EnumType (mk_pos _startpos, t) )}

tuple_type:
| _1 = LSQBRACKET l = lustre_type_list _3 = RSQBRACKET
    {                                                 ( l )}

record_type:
| _1 = option_STRUCT_ f = tlist_LCURLYBRACKET_SEMICOLON_RCURLYBRACKET_typed_idents_
    {    ( List.flatten f  )}

node_sep:
| _1 = DOT
    {                          ( )}
| _1 = SEMICOLON
    {                          ( )}

contract_clause:
| _1 = REQUIRES e = expr _3 = SEMICOLON
    {                                  ( A.Requires (mk_pos _startpos, e) )}
| _1 = ENSURES e = expr _3 = SEMICOLON
    {                                 ( A.Ensures (mk_pos _startpos, e) )}

static_param:
| _1 = TYPE t = ident
    {                    ( A.TypeParam t )}

static_params:
| l = tlist_LPARAMBRACKET_SEMICOLON_RPARAMBRACKET_static_param_
    {    ( l )}

node_local_decl:
| c = const_decl
    {                   ( List.map 
                       (function e -> A.NodeConstDecl (mk_pos _startpos, e))
                       c )}
| v = var_decls
    {                  ( List.map 
                      (function e -> A.NodeVarDecl (mk_pos _startpos, e)) 
                      v )}

var_decls:
| _1 = VAR l = nonempty_list_var_decl_
    {                                     ( List.flatten l )}

var_decl:
| l = clocked_typed_idents _2 = SEMICOLON
    {                                        ( l )}

node_equation:
| _1 = ASSERT e = expr _3 = SEMICOLON
    {    ( A.Assert (mk_pos _startpos, e) )}
| l = left_side _2 = EQUALS e = expr _4 = SEMICOLON
    {    ( A.Equation (mk_pos _startpos, l, e) )}
| _1 = MAIN
    {         ( A.AnnotMain )}
| _1 = PROPERTY e = expr _3 = SEMICOLON
    {                                  ( A.AnnotProperty (mk_pos _startpos, e) )}

left_side:
| l = struct_item_list
    {                         ( l )}
| _1 = LPAREN l = struct_item_list _3 = RPAREN
    {                                         ( l )}
| _1 = LPAREN _2 = RPAREN
    {                   ( [] )}

struct_item:
| s = ident
    {     ( A.SingleIdent (mk_pos _startpos, s) )}
| s = ident l = nonempty_list_one_index_
    {     ( A.IndexedIdent (mk_pos _startpos, s, l))}

struct_item_list:
| l = separated_nonempty_list_COMMA_struct_item_
    {                                                   ( l )}

expr:
| s = ident
    {              ( A.Ident (mk_pos _startpos, s) )}
| _1 = TRUE
    {         ( A.True (mk_pos _startpos) )}
| _1 = FALSE
    {          ( A.False (mk_pos _startpos) )}
| s = NUMERAL
    {                ( A.Num (mk_pos _startpos, s) )}
| s = DECIMAL
    {                ( A.Dec (mk_pos _startpos, s) )}
| _1 = INT e = expr
    {                  ( A.ToInt (mk_pos _startpos, e) )}
| _1 = REAL e = expr
    {                   ( A.ToReal (mk_pos _startpos, e) )}
| _1 = LPAREN e = expr _3 = RPAREN
    {                             ( e )}
| _1 = LPAREN h = expr _3 = COMMA l = expr_list _5 = RPAREN
    {    ( A.ExprList (mk_pos _startpos, h :: l) )}
| _1 = LSQBRACKET l = expr_list _3 = RSQBRACKET
    {                                          ( A.TupleExpr (mk_pos _startpos, l) )}
| e1 = expr _2 = CARET e2 = expr
    {                                ( A.ArrayConstr (mk_pos _startpos, e1, e2) )}
| e = ident _2 = LSQBRACKET i = expr _4 = RSQBRACKET
    {    ( A.TupleProject (mk_pos _startpos, e, i) )}
| e = ident _2 = LSQBRACKET l = array_slice_list _4 = RSQBRACKET
    {    ( A.ArraySlice (mk_pos _startpos, e, l) )}
| s = ident _2 = DOT t = ident
    {    ( A.RecordProject (mk_pos _startpos, s, I.index_of_ident t) )}
| t = ident f = tlist_LCURLYBRACKET_SEMICOLON_RCURLYBRACKET_record_field_assign_
    {    ( A.RecordConstruct (mk_pos _startpos, t, f) )}
| e1 = expr _2 = PIPE e2 = expr
    {                               ( A.ArrayConcat (mk_pos _startpos, e1, e2) )}
| e1 = expr _2 = MINUS e2 = expr
    {                                ( A.Minus (mk_pos _startpos, e1, e2) )}
| _1 = MINUS e = expr
    {                    ( A.Uminus (mk_pos _startpos, e) )}
| e1 = expr _2 = PLUS e2 = expr
    {                               ( A.Plus (mk_pos _startpos, e1, e2) )}
| e1 = expr _2 = MULT e2 = expr
    {                               ( A.Times (mk_pos _startpos, e1, e2) )}
| e1 = expr _2 = DIV e2 = expr
    {                              ( A.Div (mk_pos _startpos, e1, e2) )}
| e1 = expr _2 = INTDIV e2 = expr
    {                                 ( A.IntDiv (mk_pos _startpos, e1, e2) )}
| e1 = expr _2 = MOD e2 = expr
    {                              ( A.Mod (mk_pos _startpos, e1, e2) )}
| _1 = NOT e = expr
    {                  ( A.Not (mk_pos _startpos, e) )}
| e1 = expr _2 = AND e2 = expr
    {                              ( A.And (mk_pos _startpos, e1, e2) )}
| e1 = expr _2 = OR e2 = expr
    {                             ( A.Or (mk_pos _startpos, e1, e2) )}
| e1 = expr _2 = XOR e2 = expr
    {                              ( A.Xor (mk_pos _startpos, e1, e2) )}
| e1 = expr _2 = IMPL e2 = expr
    {                               ( A.Impl (mk_pos _startpos, e1, e2) )}
| _1 = HASH _2 = LPAREN e = expr_list _4 = RPAREN
    {                                        ( A.OneHot (mk_pos _startpos, e) )}
| e1 = expr _2 = LT e2 = expr
    {                             ( A.Lt (mk_pos _startpos, e1, e2) )}
| e1 = expr _2 = GT e2 = expr
    {                             ( A.Gt (mk_pos _startpos, e1, e2) )}
| e1 = expr _2 = LTE e2 = expr
    {                              ( A.Lte (mk_pos _startpos, e1, e2) )}
| e1 = expr _2 = GTE e2 = expr
    {                              ( A.Gte (mk_pos _startpos, e1, e2) )}
| e1 = expr _2 = EQUALS e2 = expr
    {                                 ( A.Eq (mk_pos _startpos, e1, e2) )}
| e1 = expr _2 = NEQ e2 = expr
    {                              ( A.Neq (mk_pos _startpos, e1, e2) )}
| _1 = IF e1 = expr _3 = THEN e2 = expr _5 = ELSE e3 = expr
    {    ( A.Ite (mk_pos _startpos, e1, e2, e3) )}
| _1 = WITH e1 = expr _3 = THEN e2 = expr _5 = ELSE e3 = expr
    {    ( A.With (mk_pos _startpos, e1, e2, e3) )}
| e1 = expr _2 = WHEN e2 = expr
    {                               ( A.When (mk_pos _startpos, e1, e2) )}
| _1 = CURRENT e = expr
    {                      ( A.Current (mk_pos _startpos, e) )}
| _1 = CONDACT _2 = LPAREN e1 = expr _4 = COMMA s = ident _6 = LPAREN xs0 = loption_separated_nonempty_list_COMMA_expr__ _8 = RPAREN _9 = COMMA v = expr_list _11 = RPAREN
    {let a =
  let xs = xs0 in
398
      ( xs )
399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417
in
    ( A.Condact (mk_pos _startpos, e1, s, a, v) )}
| _1 = PRE e = expr
    {                  ( A.Pre (mk_pos _startpos, e) )}
| _1 = FBY _2 = LPAREN e1 = expr _4 = COMMA s = NUMERAL _6 = COMMA e2 = expr _8 = RPAREN
    {    ( A.Fby (mk_pos _startpos, e2, (int_of_string s), e2) )}
| e1 = expr _2 = ARROW e2 = expr
    {                                ( A.Arrow (mk_pos _startpos, e1, e2) )}
| e = node_call
    {                  ( e )}

node_call_static_param:
| t = lustre_type
    {                    ( t )}

node_call:
| s = ident _2 = LPAREN xs0 = loption_separated_nonempty_list_COMMA_expr__ _4 = RPAREN
    {let a =
  let xs = xs0 in
418
      ( xs )
419 420 421 422 423
in
    ( A.Call (mk_pos _startpos, s, a) )}
| s = ident p = tlist_LPARAMBRACKET_SEMICOLON_RPARAMBRACKET_node_call_static_param_ _3 = LPAREN xs0 = loption_separated_nonempty_list_COMMA_expr__ _5 = RPAREN
    {let a =
  let xs = xs0 in
424
      ( xs )
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667
in
    ( A.CallParam (mk_pos _startpos, s, p, a) )}

expr_list:
| l = separated_nonempty_list_COMMA_expr_
    {                                                    ( l )}

array_slice:
| il = expr _2 = DOTDOT iu = expr
    {                                          ( il, iu )}

array_slice_list:
| l = separated_nonempty_list_COMMA_array_slice_
    {                                                                  ( l )}

record_field_assign:
| s = ident _2 = EQUALS e = expr
    {                                                 ( (s, e) )}

lustre_type_list:
| l = separated_nonempty_list_COMMA_lustre_type_
    {                                                    ( l )}

const_typed_idents:
| o = boption_CONST_ l = typed_idents
    {    ( List.map (function (e, t) -> (e, t, o)) l )}

boption_CONST_:
| 
    {    ( false )}
| _1 = CONST
    {    ( true )}

clock_expr:
| c = ident
    {              ( A.ClockPos c )}
| _1 = NOT c = ident
    {                   ( A.ClockNeg c )}
| _1 = NOT _2 = LPAREN c = ident _4 = RPAREN
    {                                   ( A.ClockNeg c )}
| _1 = TRUE
    {         ( A.ClockTrue )}

ident:
| s = SYM
    {               ( I.mk_string_ident s )}

typed_ident:
| s = ident _2 = COLON t = lustre_type
    {                                               ( (s, t) )}

ident_list:
| l = separated_nonempty_list_COMMA_ident_
    {                                              ( l )}

typed_idents:
| l = separated_nonempty_list_COMMA_ident_ _2 = COLON t = lustre_type
    {    ( List.map (function e -> (e, t)) l )}

tlist_tail_SEMICOLON_RPAREN_typed_idents_:
| x = typed_idents _2 = option_SEMICOLON_ _3 = RPAREN
    {                                      ( [ x ] )}
| x = typed_idents _2 = SEMICOLON xs = tlist_tail_SEMICOLON_RPAREN_typed_idents_
    {    ( x :: xs )}

tlist_tail_SEMICOLON_RPAREN_const_typed_idents_:
| x = const_typed_idents _2 = option_SEMICOLON_ _3 = RPAREN
    {                                      ( [ x ] )}
| x = const_typed_idents _2 = SEMICOLON xs = tlist_tail_SEMICOLON_RPAREN_const_typed_idents_
    {    ( x :: xs )}

tlist_tail_SEMICOLON_RPAREN_const_clocked_typed_idents_:
| x = const_clocked_typed_idents _2 = option_SEMICOLON_ _3 = RPAREN
    {                                      ( [ x ] )}
| x = const_clocked_typed_idents _2 = SEMICOLON xs = tlist_tail_SEMICOLON_RPAREN_const_clocked_typed_idents_
    {    ( x :: xs )}

tlist_tail_SEMICOLON_RPAREN_clocked_typed_idents_:
| x = clocked_typed_idents _2 = option_SEMICOLON_ _3 = RPAREN
    {                                      ( [ x ] )}
| x = clocked_typed_idents _2 = SEMICOLON xs = tlist_tail_SEMICOLON_RPAREN_clocked_typed_idents_
    {    ( x :: xs )}

tlist_tail_SEMICOLON_RPARAMBRACKET_static_param_:
| x = static_param _2 = option_SEMICOLON_ _3 = RPARAMBRACKET
    {                                      ( [ x ] )}
| x = static_param _2 = SEMICOLON xs = tlist_tail_SEMICOLON_RPARAMBRACKET_static_param_
    {    ( x :: xs )}

tlist_tail_SEMICOLON_RPARAMBRACKET_node_call_static_param_:
| x = node_call_static_param _2 = option_SEMICOLON_ _3 = RPARAMBRACKET
    {                                      ( [ x ] )}
| x = node_call_static_param _2 = SEMICOLON xs = tlist_tail_SEMICOLON_RPARAMBRACKET_node_call_static_param_
    {    ( x :: xs )}

tlist_tail_SEMICOLON_RCURLYBRACKET_typed_idents_:
| x = typed_idents _2 = option_SEMICOLON_ _3 = RCURLYBRACKET
    {                                      ( [ x ] )}
| x = typed_idents _2 = SEMICOLON xs = tlist_tail_SEMICOLON_RCURLYBRACKET_typed_idents_
    {    ( x :: xs )}

tlist_tail_SEMICOLON_RCURLYBRACKET_record_field_assign_:
| x = record_field_assign _2 = option_SEMICOLON_ _3 = RCURLYBRACKET
    {                                      ( [ x ] )}
| x = record_field_assign _2 = SEMICOLON xs = tlist_tail_SEMICOLON_RCURLYBRACKET_record_field_assign_
    {    ( x :: xs )}

tlist_LPAREN_SEMICOLON_RPAREN_typed_idents_:
| _1 = LPAREN l = tlist_tail_SEMICOLON_RPAREN_typed_idents_
    {                                                   ( l )}
| _1 = LPAREN _2 = RPAREN
    {                     ( [ ] )}

tlist_LPAREN_SEMICOLON_RPAREN_const_clocked_typed_idents_:
| _1 = LPAREN l = tlist_tail_SEMICOLON_RPAREN_const_clocked_typed_idents_
    {                                                   ( l )}
| _1 = LPAREN _2 = RPAREN
    {                     ( [ ] )}

tlist_LPAREN_SEMICOLON_RPAREN_clocked_typed_idents_:
| _1 = LPAREN l = tlist_tail_SEMICOLON_RPAREN_clocked_typed_idents_
    {                                                   ( l )}
| _1 = LPAREN _2 = RPAREN
    {                     ( [ ] )}

tlist_LPARAMBRACKET_SEMICOLON_RPARAMBRACKET_static_param_:
| _1 = LPARAMBRACKET l = tlist_tail_SEMICOLON_RPARAMBRACKET_static_param_
    {                                                   ( l )}
| _1 = LPARAMBRACKET _2 = RPARAMBRACKET
    {                     ( [ ] )}

tlist_LPARAMBRACKET_SEMICOLON_RPARAMBRACKET_node_call_static_param_:
| _1 = LPARAMBRACKET l = tlist_tail_SEMICOLON_RPARAMBRACKET_node_call_static_param_
    {                                                   ( l )}
| _1 = LPARAMBRACKET _2 = RPARAMBRACKET
    {                     ( [ ] )}

tlist_LCURLYBRACKET_SEMICOLON_RCURLYBRACKET_typed_idents_:
| _1 = LCURLYBRACKET l = tlist_tail_SEMICOLON_RCURLYBRACKET_typed_idents_
    {                                                   ( l )}
| _1 = LCURLYBRACKET _2 = RCURLYBRACKET
    {                     ( [ ] )}

tlist_LCURLYBRACKET_SEMICOLON_RCURLYBRACKET_record_field_assign_:
| _1 = LCURLYBRACKET l = tlist_tail_SEMICOLON_RCURLYBRACKET_record_field_assign_
    {                                                   ( l )}
| _1 = LCURLYBRACKET _2 = RCURLYBRACKET
    {                     ( [ ] )}

option_node_sep_:
| 
    {    ( None )}
| x = node_sep
    {    ( Some x )}

option_STRUCT_:
| 
    {    ( None )}
| x = STRUCT
    {    ( Some x )}

option_SEMICOLON_:
| 
    {    ( None )}
| x = SEMICOLON
    {    ( Some x )}

nonempty_list_var_decl_:
| x = var_decl
    {    ( [ x ] )}
| x = var_decl xs = nonempty_list_var_decl_
    {    ( x :: xs )}

separated_nonempty_list_COMMA_struct_item_:
| x = struct_item
    {    ( [ x ] )}
| x = struct_item _2 = COMMA xs = separated_nonempty_list_COMMA_struct_item_
    {    ( x :: xs )}

separated_nonempty_list_COMMA_lustre_type_:
| x = lustre_type
    {    ( [ x ] )}
| x = lustre_type _2 = COMMA xs = separated_nonempty_list_COMMA_lustre_type_
    {    ( x :: xs )}

separated_nonempty_list_COMMA_ident_:
| x = ident
    {    ( [ x ] )}
| x = ident _2 = COMMA xs = separated_nonempty_list_COMMA_ident_
    {    ( x :: xs )}

separated_nonempty_list_COMMA_expr_:
| x = expr
    {    ( [ x ] )}
| x = expr _2 = COMMA xs = separated_nonempty_list_COMMA_expr_
    {    ( x :: xs )}

separated_nonempty_list_COMMA_array_slice_:
| x = array_slice
    {    ( [ x ] )}
| x = array_slice _2 = COMMA xs = separated_nonempty_list_COMMA_array_slice_
    {    ( x :: xs )}

clocked_typed_idents:
| l = typed_idents
    {    ( List.map (function (e, t) -> (mk_pos _startpos, e, t, A.ClockTrue)) l )}
| l = typed_idents _2 = WHEN c = clock_expr
    {    ( List.map (function (e, t) -> (mk_pos _startpos, e, t, c)) l )}
| _1 = LPAREN l = typed_idents _3 = RPAREN _4 = WHEN c = clock_expr
    {    ( List.map (function (e, t) -> (mk_pos _startpos, e, t, c)) l )}
| _1 = LPAREN h = typed_idents _3 = SEMICOLON l = tlist_tail_SEMICOLON_RPAREN_typed_idents_ _5 = WHEN c = clock_expr
    {    ( List.map
        (function (e, t) -> (mk_pos _startpos, e, t, c)) 
        (h @ (List.flatten l)) )}

const_clocked_typed_idents:
| l = const_typed_idents
    {    ( List.map
        (function (e, t, o) -> (mk_pos _startpos, e, t, A.ClockTrue, o)) 
        l )}
| l = const_typed_idents _2 = WHEN c = clock_expr
    {    ( List.map
        (function (e, t, o) -> (mk_pos _startpos, e, t, c, o)) 
        l )}
| _1 = LPAREN l = const_typed_idents _3 = RPAREN _4 = WHEN c = clock_expr
    {    ( List.map
        (function (e, t, o) -> (mk_pos _startpos, e, t, c, o)) 
        l )}
| _1 = LPAREN h = const_typed_idents _3 = SEMICOLON l = tlist_tail_SEMICOLON_RPAREN_const_typed_idents_ _5 = WHEN c = clock_expr
    {    ( List.map (function (e, t, o) -> (mk_pos _startpos, e, t, c, o)) (h @ (List.flatten l)) )}

one_index:
| _1 = DOT i = ident
    {     ( A.FieldIndex (mk_pos _startpos, i) )}
| _1 = LSQBRACKET i = ident _3 = RSQBRACKET
    {     ( A.VarIndex (mk_pos _startpos, i) )}
| _1 = LSQBRACKET s = NUMERAL _3 = RSQBRACKET
    {     ( A.NumIndex (mk_pos _startpos, int_of_string s) )}

%%