jocaml.opp.exp 58.9 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
File "jocaml.mly", line 257, characters 7-16:
Warning: the token BARRBRACE is unused.
File "jocaml.mly", line 256, characters 7-16:
Warning: the token LBRACEBAR is unused.
File "jocaml.mly", line 258, characters 7-29:
Warning: the token LESSLESSGREATERGREATER is unused.
File "jocaml.mly", line 291, characters 6-15:
Warning: the token prec_expr is unused.
File "jocaml.mly", line 292, characters 6-15:
Warning: the token prec_proc is unused.
File "jocaml.mly", line 718, characters 0-14:
Warning: symbol def_parameters is unreachable from any of the start symbol(s).
%{
open Location
open Asttypes
open Longident
open Parsetree

let mktyp d =
  { ptyp_desc = d; ptyp_loc = symbol_loc() }
let mkpat d =
  { ppat_desc = d; ppat_loc = symbol_loc() }
let mkexp d =
  { pexp_desc = d; pexp_loc = symbol_loc() }
let mkmty d =
  { pmty_desc = d; pmty_loc = symbol_loc() }
let mksig d =
  { psig_desc = d; psig_loc = symbol_loc() }
let mkmod d =
  { pmod_desc = d; pmod_loc = symbol_loc() }
let mkstr d =
  { pstr_desc = d; pstr_loc = symbol_loc() }
let mkfield d =
  { pfield_desc = d; pfield_loc = symbol_loc() }

let mkoperator name pos =
  { pexp_desc = Pexp_ident(Lident name); pexp_loc = rhs_loc pos }

let void () = mkexp (Pexp_construct (Lident "()", None, false))
let void_pat () = mkpat (Ppat_construct (Lident "()", None, false))

let mkassert e =
  let {loc_start = st; loc_end = en} = symbol_loc () in
  let triple = mkexp (Pexp_tuple
                       [mkexp (Pexp_constant (Const_string !input_name));
                        mkexp (Pexp_constant (Const_int st));
                        mkexp (Pexp_constant (Const_int en))]) in
  let ex = Ldot (Lident "Pervasives", "Assert_failure") in
  let bucket = mkexp (Pexp_construct (ex, Some triple, false)) in
  let ra = Ldot (Lident "Pervasives", "raise") in
  let raiser = mkexp (Pexp_apply (mkexp (Pexp_ident ra), [bucket])) in
  let un = mkexp (Pexp_construct (Lident "()", None, false)) in
  match e with
  | {pexp_desc = Pexp_construct (Lident "false", None, false) } -> raiser
  | _ -> if !Clflags.noassert
         then un
         else mkexp (Pexp_ifthenelse (e, un, Some raiser))
;;
let mklazy e =
  let void_pat = mkpat (Ppat_construct (Lident "()", None, false)) in
  let f = mkexp (Pexp_function ([void_pat, e])) in
  let delayed = Ldot (Lident "Lazy", "Delayed") in
  let df = mkexp (Pexp_construct (delayed, Some f, false)) in
  let r = mkexp (Pexp_ident (Ldot (Lident "Pervasives", "ref"))) in
  mkexp (Pexp_apply (r, [df]))
;;

let mkinfix arg1 name arg2 =
  mkexp(Pexp_apply(mkoperator name 2, [arg1; arg2]))

let mkuminus name arg =
  match arg.pexp_desc with
    Pexp_constant(Const_int n) ->
      mkexp(Pexp_constant(Const_int(-n)))
  | Pexp_constant(Const_float f) ->
      mkexp(Pexp_constant(Const_float("-" ^ f)))
  | _ ->
      mkexp(Pexp_apply(mkoperator ("~" ^ name) 1, [arg]))

let rec mklistexp = function
    [] ->
      mkexp(Pexp_construct(Lident "[]", None, false))
  | e1 :: el ->
      mkexp(Pexp_construct(Lident "::",
                           Some(mkexp(Pexp_tuple[e1; mklistexp el])),
                           false))
let rec mklistpat = function
    [] ->
      mkpat(Ppat_construct(Lident "[]", None, false))
  | p1 :: pl ->
      mkpat(Ppat_construct(Lident "::",
                           Some(mkpat(Ppat_tuple[p1; mklistpat pl])),
                           false))

let mkstrexp e =
  { pstr_desc = Pstr_eval e; pstr_loc = e.pexp_loc }

let array_function str name =
  Ldot(Lident str, (if !Clflags.fast then "unsafe_" ^ name else name))

let rec mkrangepat c1 c2 =
  if c1 > c2 then mkrangepat c2 c1 else
  if c1 = c2 then mkpat(Ppat_constant(Const_char c1)) else
  mkpat(Ppat_or(mkpat(Ppat_constant(Const_char c1)),
                mkrangepat (Char.chr(Char.code c1 + 1)) c2))

let syntax_error () =
  raise Syntaxerr.Escape_error

let unclosed opening_name opening_num closing_name closing_num =
  raise(Syntaxerr.Error(Syntaxerr.Unclosed(rhs_loc opening_num, opening_name,
                                           rhs_loc closing_num, closing_name)))

let join_def ()=
  mkexp (Pexp_apply 
           (mkexp (Pexp_ident (Ldot (Lident "Join", "definition"))),
            [void ()]))
    
let mkloc l = 
  let r = mkexp (Pexp_ident (Ldot (Lident "Join", "create_location"))) in 
  mkexp (Pexp_apply (r, [mkexp Pexp_thismodule;  
                                mkexp (Pexp_function [void_pat (),l])]))

let pexp_add list = function
    { pexp_desc= Pexp_par l } -> l@list
  | { pexp_desc= Pexp_null } -> list
  | p -> p::list


let deconstr_record exp f =
 match exp.pexp_desc with
   Pexp_construct(lid,Some arg,_) ->
              (* un deconstructeur *)
     mkexp (Pexp_let
              (Nonrecursive,
               [mkpat(Ppat_construct
                        (lid,
                         Some (mkpat(Ppat_var "*match*")),
                         false)),
                 arg],
               f (mkexp(Pexp_ident(Lident "*match*")))))
          | _ -> f exp
          

%}
%start implementation
%start interface
%start toplevel_phrase
%start use_file
%token WITH
%token WHILE
%token WHEN
%token VIRTUAL
%token VARTYPE
%token VAL
%token UNDERSCORE
%token <string> UIDENT
%token TYPE
%token TRY
%token TRUE
%token TO
%token THEN
%token STRUCT
%token <string> STRING
%token SPAWN
%token SIG
%token SEMISEMI
%token RPAREN
%token REPLY
%token RELOCINFO
%token REC
%token RBRACKET
%token RBRACE
%token QUOTE
%token QUESTION
%token PROTECTED
%token PRIVATE
%token PARSER
%token OR
%token OPEN
%token OF
%token NEW
%token MUTABLE
%token MODULE
%token MINUSGREATER
%token METHOD
%token MATCH
%token LPAREN
%token LOC
%token <string> LIDENT
%token LET
%token LESSLESSGREATERGREATER
%token LESSLESS
%token LBRACKETLESS
%token LBRACKETBAR
%token LBRACKET
%token LBRACERBRACE
%token LBRACELESS
%token LBRACEBAR
%token LBRACE
%token LAZY
%token JOINDEF
%token <int> INT
%token INHERIT
%token INCLUDE
%token IN
%token IF
%token GREATERRBRACKET
%token GREATERRBRACE
%token GREATERGREATER
%token FUNCTOR
%token FUNCTION
%token FUN
%token FOR
%token <string> FLOAT
%token FALSE
%token EXTERNAL
%token EXCEPTION
%token EOF
%token END
%token ELSE
%token DOWNTO
%token DOTDOT
%token DONE
%token DO
%token CONSTRAINT
%token COLONGREATER
%token COLON
%token CLOSED
%token CLASS
%token <char> CHAR
%token BEGIN
%token BARRBRACKET
%token BARRBRACE
%token ASSERT
%token AND
%token SEMI
%token LESSMINUS
%token COLONEQUAL
%token AS
%token BAR
%token COMMA
%token BARBAR
%token AMPERSAND
%token AMPERAMPER
%token LESSGREATER
%token LESS
%token <string> INFIXOP0
%token GREATER
%token EQUAL
%token <string> INFIXOP1
%token COLONCOLON
%token <string> SUBTRACTIVE
%token <string> INFIXOP2
%token STAR
%token <string> INFIXOP3
%token <string> INFIXOP4
%token SHARP
%token DOT
%token <string> PREFIXOP
%right prec_let 
%right prec_type_def 
%right SEMI 
%right prec_try prec_match prec_fun 
%right prec_list 
%right prec_if 
%right LESSMINUS COLONEQUAL 
%left AS 
%left BAR 
%left COMMA 
%right prec_type_arrow 
%right BARBAR 
%right AMPERSAND AMPERAMPER 
%left LESSGREATER LESS INFIXOP0 GREATER EQUAL 
%right INFIXOP1 
%right COLONCOLON 
%left SUBTRACTIVE INFIXOP2 
%left STAR INFIXOP3 
%right INFIXOP4 
%right prec_unary_minus 
%left prec_appl 
%right prec_constr_appl 
%left SHARP 
%left DOT 
%right PREFIXOP 
%left prec_expr 
%left prec_proc 
%type <Parsetree.structure> implementation
%type <Parsetree.signature> interface
%type <Parsetree.toplevel_phrase> toplevel_phrase
%type <Parsetree.toplevel_phrase list> use_file
%%

implementation:
295 296
| _1 = structure _2 = EOF
    {                                         ( _1 )}
297 298

interface:
299 300
| _1 = signature _2 = EOF
    {                                         ( List.rev _1 )}
301 302

toplevel_phrase:
303 304 305 306 307 308 309 310
| _1 = top_structure _2 = SEMISEMI
    {                                         ( Ptop_def _1 )}
| _1 = seq_expr _2 = SEMISEMI
    {                                         ( Ptop_def[mkstrexp _1] )}
| _1 = toplevel_directive _2 = SEMISEMI
    {                                         ( _1 )}
| _1 = EOF
    {                                         ( raise End_of_file )}
311 312

top_structure:
313 314 315 316 317 318
| _1 = structure_item
    {                                         ( [_1] )}
| _1 = structure_item _2 = top_structure
    {                                         ( _1 :: _2 )}
| _1 = LET _2 = LOC _3 = loc_bindings
    {                                         ( [mkstr (Pstr_location _3)] )}
319 320

use_file:
321 322 323 324
| _1 = use_file_tail
    {                                         ( _1 )}
| _1 = seq_expr _2 = use_file_tail
    {                                         ( Ptop_def[mkstrexp _1] :: _2 )}
325 326

use_file_tail:
327 328 329 330 331 332 333 334 335 336 337 338 339 340
| _1 = EOF
    {                                                ( [] )}
| _1 = SEMISEMI _2 = EOF
    {                                                ( [] )}
| _1 = SEMISEMI _2 = seq_expr _3 = use_file_tail
    {                                                ( Ptop_def[mkstrexp _2] :: _3 )}
| _1 = SEMISEMI _2 = structure_item _3 = use_file_tail
    {                                                ( Ptop_def[_2] :: _3 )}
| _1 = SEMISEMI _2 = toplevel_directive _3 = use_file_tail
    {                                                ( _2 :: _3 )}
| _1 = structure_item _2 = use_file_tail
    {                                                ( Ptop_def[_1] :: _2 )}
| _1 = toplevel_directive _2 = use_file_tail
    {                                                ( _1 :: _2 )}
341 342

module_expr:
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362
| _1 = mod_longident
    {      ( mkmod(Pmod_ident _1) )}
| _1 = STRUCT _2 = structure _3 = END
    {      ( mkmod(Pmod_structure(_2)) )}
| _1 = STRUCT _2 = structure _3 = error
    {      ( unclosed "struct" 1 "end" 3 )}
| _1 = FUNCTOR _2 = LPAREN _3 = UIDENT _4 = COLON _5 = module_type _6 = RPAREN _7 = MINUSGREATER _8 = module_expr %prec prec_fun
    {      ( mkmod(Pmod_functor(_3, _5, _8)) )}
| _1 = module_expr _2 = LPAREN _3 = module_expr _4 = RPAREN
    {      ( mkmod(Pmod_apply(_1, _3)) )}
| _1 = module_expr _2 = LPAREN _3 = module_expr _4 = error
    {      ( unclosed "(" 2 ")" 4 )}
| _1 = LPAREN _2 = module_expr _3 = COLON _4 = module_type _5 = RPAREN
    {      ( mkmod(Pmod_constraint(_2, _4)) )}
| _1 = LPAREN _2 = module_expr _3 = COLON _4 = module_type _5 = error
    {      ( unclosed "(" 1 ")" 5 )}
| _1 = LPAREN _2 = module_expr _3 = RPAREN
    {      ( _2 )}
| _1 = LPAREN _2 = module_expr _3 = error
    {      ( unclosed "(" 1 ")" 3 )}
363 364

lident_comma_list:
365 366 367 368
| _1 = LIDENT
    {           ([_1])}
| _1 = LIDENT _2 = COMMA _3 = lident_comma_list
    {                                   ( _1::_3 )}
369 370

structure:
371 372 373 374
| _1 = structure_tail
    {                                                ( _1 )}
| _1 = seq_expr _2 = structure_tail
    {                                                ( mkstrexp _1 :: _2 )}
375 376 377

structure_tail:
| 
378 379 380 381 382 383 384 385 386 387 388 389 390
    {                                                ( [] )}
| _1 = SEMISEMI
    {                                                ( [] )}
| _1 = SEMISEMI _2 = seq_expr _3 = structure_tail
    {                                                ( mkstrexp _2 :: _3 )}
| _1 = SEMISEMI _2 = structure_item _3 = structure_tail
    {                                                ( _2 :: _3 )}
| _1 = structure_item _2 = structure_tail
    {                                                ( _1 :: _2 )}
| _1 = LET _2 = LOC _3 = loc_bindings _4 = structure_tail
    {      ( (mkstr (Pstr_location _3)):: _4 )}
| _1 = SEMISEMI _2 = LET _3 = LOC _4 = loc_bindings _5 = structure_tail
    {      ( (mkstr (Pstr_location _4)):: _5 )}
391 392

structure_item:
393 394 395 396
| _1 = LET _2 = JOINDEF _3 = def_bindings
    {      (  mkstr(Pstr_def(List.rev _3)) )}
| _1 = LET _2 = rec_flag _3 = let_bindings
    {      ( match _3 with
397
          [{ppat_desc = Ppat_any}, exp] -> mkstr(Pstr_eval exp)
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414
        | _ -> mkstr(Pstr_value(_2, List.rev _3)) )}
| _1 = EXTERNAL _2 = val_ident _3 = COLON _4 = core_type _5 = EQUAL _6 = primitive_declaration
    {      ( mkstr(Pstr_primitive(_2, {pval_type = _4; pval_prim = _6})) )}
| _1 = TYPE _2 = type_declarations
    {      ( mkstr(Pstr_type(List.rev _2)) )}
| _1 = EXCEPTION _2 = UIDENT _3 = constructor_arguments
    {      ( mkstr(Pstr_exception(_2, _3)) )}
| _1 = MODULE _2 = UIDENT _3 = module_binding
    {      ( mkstr(Pstr_module(_2, _3)) )}
| _1 = MODULE _2 = TYPE _3 = ident _4 = EQUAL _5 = module_type
    {      ( mkstr(Pstr_modtype(_3, _5)) )}
| _1 = OPEN _2 = mod_longident
    {      ( mkstr(Pstr_open _2) )}
| _1 = CLASS _2 = class_list _3 = END
    {      ( mkstr(Pstr_class (List.rev _2)) )}
| _1 = CLASS _2 = class_list _3 = error
    {      ( unclosed "class" 1 "end" 3 )}
415 416

module_binding:
417 418 419 420 421 422
| _1 = EQUAL _2 = module_expr
    {      ( _2 )}
| _1 = COLON _2 = module_type _3 = EQUAL _4 = module_expr
    {      ( mkmod(Pmod_constraint(_4, _2)) )}
| _1 = LPAREN _2 = UIDENT _3 = COLON _4 = module_type _5 = RPAREN _6 = module_binding
    {      ( mkmod(Pmod_functor(_2, _4, _6)) )}
423 424

module_type:
425 426 427 428 429 430 431 432 433 434 435 436 437 438
| _1 = mty_longident
    {      ( mkmty(Pmty_ident _1) )}
| _1 = SIG _2 = signature _3 = END
    {      ( mkmty(Pmty_signature(List.rev _2)) )}
| _1 = SIG _2 = signature _3 = error
    {      ( unclosed "sig" 1 "end" 3 )}
| _1 = FUNCTOR _2 = LPAREN _3 = UIDENT _4 = COLON _5 = module_type _6 = RPAREN _7 = MINUSGREATER _8 = module_type %prec prec_fun
    {      ( mkmty(Pmty_functor(_3, _5, _8)) )}
| _1 = module_type _2 = WITH _3 = with_constraints
    {      ( mkmty(Pmty_with(_1, List.rev _3)) )}
| _1 = LPAREN _2 = module_type _3 = RPAREN
    {      ( _2 )}
| _1 = LPAREN _2 = module_type _3 = error
    {      ( unclosed "(" 1 ")" 3 )}
439 440 441

signature:
| 
442 443 444 445 446
    {                                                ( [] )}
| _1 = signature _2 = signature_item
    {                                                ( _2 :: _1 )}
| _1 = signature _2 = signature_item _3 = SEMISEMI
    {                                                ( _2 :: _1 )}
447 448

signature_item:
449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468
| _1 = VAL _2 = val_ident _3 = COLON _4 = core_type
    {      ( mksig(Psig_value(_2, {pval_type = _4; pval_prim = []})) )}
| _1 = EXTERNAL _2 = val_ident _3 = COLON _4 = core_type _5 = EQUAL _6 = primitive_declaration
    {      ( mksig(Psig_value(_2, {pval_type = _4; pval_prim = _6})) )}
| _1 = TYPE _2 = type_declarations
    {      ( mksig(Psig_type(List.rev _2)) )}
| _1 = EXCEPTION _2 = UIDENT _3 = constructor_arguments
    {      ( mksig(Psig_exception(_2, _3)) )}
| _1 = MODULE _2 = UIDENT _3 = module_declaration
    {      ( mksig(Psig_module(_2, _3)) )}
| _1 = MODULE _2 = TYPE _3 = ident
    {      ( mksig(Psig_modtype(_3, Pmodtype_abstract)) )}
| _1 = MODULE _2 = TYPE _3 = ident _4 = EQUAL _5 = module_type
    {      ( mksig(Psig_modtype(_3, Pmodtype_manifest _5)) )}
| _1 = OPEN _2 = mod_longident
    {      ( mksig(Psig_open _2) )}
| _1 = INCLUDE _2 = module_type
    {      ( mksig(Psig_include _2) )}
| _1 = CLASS _2 = class_type_list _3 = END
    {      ( mksig(Psig_class (List.rev _2)) )}
469 470

module_declaration:
471 472 473 474
| _1 = COLON _2 = module_type
    {      ( _2 )}
| _1 = LPAREN _2 = UIDENT _3 = COLON _4 = module_type _5 = RPAREN _6 = module_declaration
    {      ( mkmty(Pmty_functor(_2, _4, _6)) )}
475 476

seq_expr:
477 478 479 480 481 482
| _1 = expr
    {                                  ( _1 )}
| _1 = expr _2 = SEMI
    {                                  ( _1 )}
| _1 = expr _2 = SEMI _3 = seq_expr
    {                                  ( mkexp(Pexp_sequence(_1, _3)) )}
483 484

expr:
485 486 487 488
| _1 = expr0
    {           ( _1 )}
| _1 = expr_comma_list
    {      ( mkexp(Pexp_tuple(List.rev _1)) )}
489 490

expr0:
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
| _1 = simple_expr
    {      ( _1 )}
| _1 = simple_expr _2 = simple_expr_list %prec prec_appl
    {      ( mkexp(Pexp_apply(_1, List.rev _2)) )}
| _1 = LET _2 = JOINDEF _3 = def_bindings _4 = IN _5 = error %prec prec_let
    {      ( syntax_error() )}
| _1 = LET _2 = JOINDEF _3 = def_bindings _4 = error %prec prec_let
    {      ( unclosed "def" 1 "in" 4  )}
| _1 = LET _2 = JOINDEF _3 = def_bindings _4 = IN _5 = seq_expr %prec prec_let
    {      ( mkexp(Pexp_def(List.rev _3, _5)) )}
| _1 = LET _2 = LOC _3 = loc_bindings _4 = IN _5 = error %prec prec_let
    {      ( syntax_error() )}
| _1 = LET _2 = LOC _3 = loc_bindings _4 = error %prec prec_let
    {      ( unclosed "let" 1 "in" 4  )}
| _1 = LET _2 = LOC _3 = loc_bindings _4 = IN _5 = seq_expr %prec prec_let
    {      ( mkexp (Pexp_location (_3,_5)) )}
| _1 = LET _2 = rec_flag _3 = let_bindings _4 = IN _5 = seq_expr %prec prec_let
    {      ( mkexp(Pexp_let(_2, List.rev _3, _5)) )}
| _1 = LET _2 = rec_flag _3 = let_bindings _4 = IN _5 = error %prec prec_let
    {      ( syntax_error() )}
| _1 = LET _2 = rec_flag _3 = let_bindings _4 = error %prec prec_let
    {      ( unclosed "let" 1 "in" 4  )}
| _1 = SPAWN _2 = LBRACE _3 = error
    {      ( syntax_error () )}
| _1 = SPAWN _2 = LBRACE _3 = process _4 = RBRACE
    {      ( mkexp(Pexp_process _3) )}
| _1 = LBRACE _2 = BAR _3 = process _4 = RBRACE
    {      ( mkexp(Pexp_process _3) )}
| _1 = SPAWN _2 = LBRACE _3 = process _4 = error
    {      ( unclosed "{" 2 "}" 4 )}
| _1 = PARSER _2 = opt_pat _3 = opt_bar _4 = parser_cases %prec prec_fun
    {      ( Pstream.cparser (_2, List.rev _4) )}
| _1 = FUNCTION _2 = opt_bar _3 = match_cases %prec prec_fun
    {      ( mkexp(Pexp_function(List.rev _3)) )}
| _1 = FUN _2 = simple_pattern _3 = fun_def %prec prec_fun
    {      ( mkexp(Pexp_function([_2, _3])) )}
| _1 = MATCH _2 = seq_expr _3 = WITH _4 = opt_bar _5 = match_cases %prec prec_match
    {      ( mkexp(Pexp_match(_2, List.rev _5)) )}
| _1 = MATCH _2 = seq_expr _3 = WITH _4 = PARSER _5 = opt_pat _6 = opt_bar _7 = parser_cases %prec prec_match
    {      ( mkexp(Pexp_apply(Pstream.cparser (_5, List.rev _7), [_2])) )}
| _1 = TRY _2 = seq_expr _3 = WITH _4 = opt_bar _5 = match_cases %prec prec_try
    {      ( mkexp(Pexp_try(_2, List.rev _5)) )}
| _1 = TRY _2 = seq_expr _3 = WITH _4 = error %prec prec_try
    {      ( syntax_error() )}
| _1 = TRY _2 = seq_expr _3 = error %prec prec_try
    {      ( unclosed "try" 1 "with" 3 )}
| _1 = constr_longident _2 = simple_expr %prec prec_constr_appl
    {      ( mkexp(Pexp_construct(_1, Some _2, false)) )}
| _1 = IF _2 = seq_expr _3 = THEN _4 = expr _5 = ELSE _6 = expr %prec prec_if
    {      ( mkexp(Pexp_ifthenelse(_2, _4, Some _6)) )}
| _1 = IF _2 = seq_expr _3 = THEN _4 = expr %prec prec_if
    {      ( mkexp(Pexp_ifthenelse(_2, _4, None)) )}
| _1 = WHILE _2 = seq_expr _3 = DO _4 = seq_expr _5 = DONE
    {      ( mkexp(Pexp_while(_2, _4)) )}
| _1 = WHILE _2 = seq_expr _3 = DO _4 = seq_expr _5 = error
    {      ( unclosed "while" 1 "done" 5 )}
| _1 = FOR _2 = val_ident _3 = EQUAL _4 = seq_expr _5 = direction_flag _6 = seq_expr _7 = DO _8 = seq_expr _9 = DONE
    {      ( mkexp(Pexp_for(_2, _4, _6, _5, _8)) )}
| _1 = FOR _2 = val_ident _3 = EQUAL _4 = seq_expr _5 = direction_flag _6 = seq_expr _7 = DO _8 = seq_expr _9 = error
    {      ( unclosed "for" 1 "done" 9 )}
| _1 = expr0 _2 = COLONCOLON _3 = expr0
    {      ( mkexp(Pexp_construct(Lident "::", Some(mkexp(Pexp_tuple[_1;_3])), false)) )}
| _1 = expr0 _2 = INFIXOP0 _3 = expr0
    {      ( mkinfix _1 _2 _3 )}
| _1 = expr0 _2 = LESSGREATER _3 = expr0
    {      ( mkinfix _1 "<>" _3 )}
| _1 = expr0 _2 = INFIXOP1 _3 = expr0
    {      ( mkinfix _1 _2 _3 )}
| _1 = expr0 _2 = INFIXOP2 _3 = expr0
    {      ( mkinfix _1 _2 _3 )}
| _1 = expr0 _2 = INFIXOP3 _3 = expr0
    {      ( mkinfix _1 _2 _3 )}
| _1 = expr0 _2 = INFIXOP4 _3 = expr0
    {      ( mkinfix _1 _2 _3 )}
| _1 = expr0 _2 = SUBTRACTIVE _3 = expr0
    {      ( mkinfix _1 _2 _3 )}
| _1 = expr0 _2 = STAR _3 = expr0
    {      ( mkinfix _1 "*" _3 )}
| _1 = expr0 _2 = EQUAL _3 = expr0
    {      ( mkinfix _1 "=" _3 )}
| _1 = expr0 _2 = LESS _3 = expr0
    {      ( mkinfix _1 "<" _3 )}
| _1 = expr0 _2 = GREATER _3 = expr0
    {      ( mkinfix _1 ">" _3 )}
| _1 = expr0 _2 = BARBAR _3 = expr0
    {      ( mkinfix _1 "||" _3 )}
| _1 = expr0 _2 = AMPERSAND _3 = expr0
    {      ( mkinfix _1 "&" _3 )}
| _1 = expr0 _2 = AMPERAMPER _3 = expr0
    {      ( mkinfix _1 "&&" _3 )}
| _1 = expr0 _2 = COLONEQUAL _3 = expr0
    {      ( mkinfix _1 ":=" _3 )}
| _1 = SUBTRACTIVE _2 = expr0 %prec prec_unary_minus
    {      ( mkuminus _1 _2 )}
| _1 = simple_expr _2 = DOT _3 = label_longident _4 = LESSMINUS _5 = expr
    {      ( deconstr_record _1 (fun exp -> mkexp(Pexp_setfield(exp, _3, _5))) )}
| _1 = simple_expr _2 = DOT _3 = LPAREN _4 = seq_expr _5 = RPAREN _6 = LESSMINUS _7 = expr
    {      ( mkexp(Pexp_apply(mkexp(Pexp_ident(array_function "Array" "set")),
                         [_1; _4; _7])) )}
| _1 = simple_expr _2 = DOT _3 = LBRACKET _4 = seq_expr _5 = RBRACKET _6 = LESSMINUS _7 = expr
    {      ( mkexp(Pexp_apply(mkexp(Pexp_ident(array_function "String" "set")),
                         [_1; _4; _7])) )}
| _1 = label _2 = LESSMINUS _3 = expr
    {      ( mkexp(Pexp_setinstvar(_1, _3)) )}
| _1 = ASSERT _2 = simple_expr %prec prec_appl
    {      ( mkassert _2 )}
| _1 = LAZY _2 = simple_expr %prec prec_appl
    {      ( mklazy _2 )}
599 600

simple_expr:
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
| _1 = val_longident
    {      ( mkexp(Pexp_ident _1) )}
| _1 = constant
    {      ( mkexp(Pexp_constant _1) )}
| _1 = constr_longident
    {      ( mkexp(Pexp_construct(_1, None, false)) )}
| _1 = VARTYPE
    {      ( mkexp Pexp_vartype )}
| _1 = RELOCINFO
    {      ( mkexp(Pexp_thismodule) )}
| _1 = LPAREN _2 = seq_expr _3 = RPAREN
    {      ( _2 )}
| _1 = LPAREN _2 = seq_expr _3 = error
    {      ( unclosed "(" 1 ")" 3 )}
| _1 = BEGIN _2 = seq_expr _3 = END
    {      ( _2 )}
| _1 = BEGIN _2 = seq_expr _3 = error
    {      ( unclosed "begin" 1 "end" 3 )}
| _1 = LPAREN _2 = seq_expr _3 = type_constraint _4 = RPAREN
    {      ( let (t, t') = _3 in mkexp(Pexp_constraint(_2, t, t')) )}
| _1 = simple_expr _2 = DOT _3 = label_longident
    {      ( deconstr_record _1 (fun exp -> mkexp(Pexp_field(exp, _3))) )}
| _1 = simple_expr _2 = DOT _3 = LPAREN _4 = seq_expr _5 = RPAREN
    {      ( mkexp(Pexp_apply(mkexp(Pexp_ident(array_function "Array" "get")),
                         [_1; _4])) )}
| _1 = simple_expr _2 = DOT _3 = LPAREN _4 = seq_expr _5 = error
    {      ( unclosed "(" 3 ")" 5 )}
| _1 = simple_expr _2 = DOT _3 = LBRACKET _4 = seq_expr _5 = RBRACKET
    {      ( mkexp(Pexp_apply(mkexp(Pexp_ident(array_function "String" "get")),
                         [_1; _4])) )}
| _1 = simple_expr _2 = DOT _3 = LBRACKET _4 = seq_expr _5 = error
    {      ( unclosed "[" 3 "]" 5 )}
| _1 = LBRACE _2 = lbl_expr_list _3 = opt_semi _4 = RBRACE
    {      ( mkexp(Pexp_record(0,List.rev _2)) )}
| _1 = LBRACE _2 = LBRACKET _3 = LIDENT _4 = RBRACKET _5 = lbl_expr_list _6 = opt_semi _7 = RBRACE
    {      ( 
637 638
       let tag = 
         try
639
           List.assoc _3 Tag.list
640 641 642
         with
           Not_found -> syntax_error()
       in
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 668 669 670 671 672 673 674 675 676
       mkexp(Pexp_record(tag,List.rev _5)) )}
| _1 = LBRACE _2 = lbl_expr_list _3 = opt_semi _4 = error
    {      ( unclosed "{" 1 "}" 4 )}
| _1 = LBRACKETLESS _2 = stream_expr _3 = opt_semi _4 = GREATERRBRACKET
    {      ( Pstream.cstream (List.rev _2) )}
| _1 = LBRACKETLESS _2 = stream_expr _3 = opt_semi _4 = error
    {      ( unclosed "[<" 1 ">]" 4 )}
| _1 = LBRACKETLESS _2 = GREATERRBRACKET
    {      ( Pstream.cstream [] )}
| _1 = LBRACKETBAR _2 = expr_semi_list _3 = opt_semi _4 = BARRBRACKET
    {      ( mkexp(Pexp_array(List.rev _2)) )}
| _1 = LBRACKETBAR _2 = expr_semi_list _3 = opt_semi _4 = error
    {       ( unclosed "[|" 1 "|]" 4 )}
| _1 = LBRACKETBAR _2 = BARRBRACKET
    {      ( mkexp(Pexp_array []) )}
| _1 = LBRACKET _2 = expr_semi_list _3 = opt_semi _4 = RBRACKET
    {      ( mklistexp(List.rev _2) )}
| _1 = LBRACKET _2 = expr_semi_list _3 = opt_semi _4 = error
    {      ( unclosed "[" 1 "]" 4 )}
| _1 = PREFIXOP _2 = simple_expr
    {      ( mkexp(Pexp_apply(mkoperator _1 1, [_2])) )}
| _1 = simple_expr _2 = SHARP _3 = label
    {      ( mkexp(Pexp_send(_1, _3)) )}
| _1 = NEW _2 = class_longident
    {      ( mkexp(Pexp_new(_2)) )}
| _1 = LBRACELESS _2 = label_expr_list _3 = opt_semi _4 = GREATERRBRACE
    {      ( mkexp(Pexp_override(List.rev _2)) )}
| _1 = LBRACELESS _2 = label_expr_list _3 = opt_semi _4 = error
    {      ( unclosed "{<" 1 ">}" 4 )}
| _1 = LBRACELESS _2 = GREATERRBRACE
    {      ( mkexp(Pexp_override []) )}
| _1 = LPAREN _2 = SHARP _3 = label _4 = RPAREN
    {      ( mkexp(Pexp_function [mkpat(Ppat_var "x"),
                mkexp(Pexp_send(mkexp(Pexp_ident (Lident"x")), _3))]) )}
677 678

simple_expr_list:
679 680 681 682
| _1 = simple_expr
    {      ( [_1] )}
| _1 = simple_expr_list _2 = simple_expr
    {      ( _2 :: _1 )}
683 684

def_bindings:
685 686 687 688
| _1 = def_binding
    {                                                   ( [_1] )}
| _1 = def_bindings _2 = AND _3 = def_binding
    {                                                ( _3 :: _1 )}
689 690

def_binding:
691 692 693 694 695 696
| _1 = LIDENT _2 = LBRACKET _3 = lident_comma_list _4 = RBRACKET _5 = LBRACE _6 = simple_def_binding _7 = loc_init _8 = RBRACE
    {    ( (Some (_1, _7, Some _3)), List.rev _6 )}
| _1 = LIDENT _2 = LBRACE _3 = simple_def_binding _4 = loc_init _5 = RBRACE
    {    ( (Some (_1, _4, None)), List.rev _3 )}
| _1 = simple_def_binding
    {                                            ( None, List.rev _1 )}
697 698

simple_def_binding:
699 700 701 702
| _1 = def_pattern
    {                           ( [_1] )}
| _1 = simple_def_binding _2 = OR _3 = def_pattern
    {                                                 ( _3 :: _1 )}
703 704

def_pattern:
705 706
| _1 = join_pattern _2 = EQUAL _3 = process
    {                                    ( (_1,_3) )}
707 708

join_pattern:
709 710 711 712 713 714 715 716 717 718
| _1 = LIDENT _2 = simple_pattern
    {                               ( mkpat(Ppat_channel (_1,_2,Sync)) )}
| _1 = LIDENT _2 = PREFIXOP _3 = simple_pattern
    {           ( match _2 with
             "!" -> mkpat(Ppat_channel (_1,_3,Async))
           | _ -> syntax_error () )}
| _1 = UIDENT _2 = simple_pattern
    {                            ( mkpat(Ppat_construct(Lident _1,Some _2,false)))}
| _1 = join_pattern _2 = BAR _3 = join_pattern
    {                                       ( mkpat(Ppat_or(_1,_3)) )}
719 720

loc_bindings:
721 722 723 724
| _1 = loc_binding
    {                                    ( [_1] )}
| _1 = loc_binding _2 = AND _3 = loc_bindings
    {                                   ( _1::_3 )}
725 726

loc_init:
727 728
| _1 = DO _2 = process0
    {                   ( _2 )}
729
| 
730
    {                    ( mkexp(Pexp_null) )}
731 732

loc_binding:
733 734
| _1 = LIDENT _2 = loc_modules _3 = loc_defs _4 = loc_init
    {                                         ( _1, mklistexp _2, _3, _4 )}
735 736

list_of_modules:
737 738 739 740
| _1 = UIDENT
    {                ( [ mkexp(Pexp_module _1) ] )}
| _1 = UIDENT _2 = SEMI _3 = list_of_modules
    {                                   ( (mkexp(Pexp_module _1))::_3 )}
741 742 743

loc_modules:
| 
744 745 746 747 748
    {                  ( [] )}
| _1 = LBRACKET _2 = list_of_modules _3 = RBRACKET
    {                                      ( _2 )}
| _1 = LBRACKET _2 = RBRACKET
    {                      ( [] )}
749 750

loc_defs:
751 752
| _1 = JOINDEF _2 = def_bindings
    {                         ( _2 )}
753
| 
754
    {                         ( [] )}
755 756

to_ident:
757 758
| _1 = TO _2 = LIDENT
    {                ( Some _2 )}
759
| 
760
    {                  ( None )}
761 762 763

process:
| 
764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783
    {                                             ( mkexp(Pexp_null))}
| _1 = process0
    {                                             ( _1 )}
| _1 = process0 _2 = BAR _3 = process
    {     ( mkexp(Pexp_par(pexp_add (pexp_add [] _1) _3)) )}
| _1 = LET _2 = JOINDEF _3 = def_bindings _4 = IN _5 = process %prec prec_let
    {      ( mkexp(Pexp_def(List.rev _3, _5)) )}
| _1 = LET _2 = LOC _3 = loc_bindings _4 = IN _5 = process %prec prec_let
    {      ( mkexp (Pexp_location (_3,_5)) )}
| _1 = LET _2 = rec_flag _3 = let_bindings _4 = IN _5 = process %prec prec_let
    {      ( mkexp(Pexp_let(_2, List.rev _3, _5)) )}
| _1 = IF _2 = expr _3 = THEN _4 = process0 %prec prec_if
    {      ( mkexp(Pexp_ifthenelse(_2,_4,None)) )}
| _1 = SPAWN _2 = LBRACE _3 = process _4 = RBRACE _5 = SEMI _6 = process
    {      ( mkexp(Pexp_par(pexp_add (pexp_add [] _3) _6)) )}
| _1 = LBRACE _2 = BAR _3 = process _4 = RBRACE _5 = SEMI _6 = process
    {      ( mkexp(Pexp_par(pexp_add (pexp_add [] _3) _6)) )}
| _1 = proc_expr _2 = SEMI _3 = process
    {      ( 
    match (_3).pexp_desc with
784
      Pexp_reply( { pexp_desc = Pexp_construct(Lident "()",_,_) },channel) ->
785
        mkexp( Pexp_reply(_1,channel) )
786
    | _ ->
787 788
        mkexp( Pexp_sequence(_1,_3) ) 
  )}
789 790

join_match_cases:
791 792 793 794
| _1 = pattern _2 = join_match_action
    {                                                     ( [_1, _2] )}
| _1 = join_match_cases _2 = BAR _3 = pattern _4 = join_match_action
    {                                                          ( (_3, _4) :: _1 )}
795 796

join_match_action:
797 798 799 800
| _1 = MINUSGREATER _2 = process0
    {                                                ( _2 )}
| _1 = WHEN _2 = seq_expr _3 = MINUSGREATER _4 = process0
    {                                                ( mkexp(Pexp_when(_2, _4)) )}
801 802

proc_expr:
803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836
| _1 = simple_chan_expr
    {      ( _1 )}
| _1 = simple_chan_expr _2 = simple_expr_list %prec prec_appl
    {      ( mkexp(Pexp_apply(_1, List.rev _2)) )}
| _1 = WHILE _2 = seq_expr _3 = DO _4 = seq_expr _5 = DONE
    {      ( mkexp(Pexp_while(_2, _4)) )}
| _1 = WHILE _2 = seq_expr _3 = DO _4 = seq_expr _5 = error
    {      ( unclosed "while" 1 "done" 5 )}
| _1 = IF _2 = seq_expr _3 = THEN _4 = proc_expr _5 = ELSE _6 = proc_expr %prec prec_if
    {      ( mkexp(Pexp_ifthenelse(_2, _4, Some _6)) )}
| _1 = IF _2 = seq_expr _3 = THEN _4 = proc_expr %prec prec_if
    {      ( mkexp(Pexp_ifthenelse(_2, _4, None)) )}
| _1 = FOR _2 = val_ident _3 = EQUAL _4 = seq_expr _5 = direction_flag _6 = seq_expr _7 = DO _8 = seq_expr _9 = DONE
    {      ( mkexp(Pexp_for(_2, _4, _6, _5, _8)) )}
| _1 = FOR _2 = val_ident _3 = EQUAL _4 = seq_expr _5 = direction_flag _6 = seq_expr _7 = DO _8 = seq_expr _9 = error
    {      ( unclosed "for" 1 "done" 9 )}
| _1 = simple_chan_expr _2 = DOT _3 = label_longident _4 = LESSMINUS _5 = expr
    {      ( deconstr_record _1 (fun exp -> mkexp(Pexp_setfield(exp, _3, _5))) )}
| _1 = simple_chan_expr _2 = DOT _3 = LPAREN _4 = seq_expr _5 = RPAREN _6 = LESSMINUS _7 = expr
    {      ( mkexp(Pexp_apply(mkexp(Pexp_ident(array_function "Array" "set")),
                         [_1; _4; _7])) )}
| _1 = simple_chan_expr _2 = DOT _3 = LBRACKET _4 = seq_expr _5 = RBRACKET _6 = LESSMINUS _7 = expr
    {      ( mkexp(Pexp_apply(mkexp(Pexp_ident(array_function "String" "set")),
        [_1; _4; _7])) )}
| _1 = simple_chan_expr _2 = SHARP _3 = label _4 = simple_expr
    {      ( mkexp(Pexp_apply(mkexp(Pexp_send(_1, _3)), [_4])) )}
| _1 = proc_expr _2 = COLONEQUAL _3 = expr
    {      ( mkinfix _1 ":=" _3 )}
| _1 = label _2 = LESSMINUS _3 = expr
    {      ( mkexp(Pexp_setinstvar(_1, _3)) )}
| _1 = ASSERT _2 = simple_expr %prec prec_appl
    {      ( mkassert _2 )}
| _1 = LAZY _2 = simple_expr %prec prec_appl
    {      ( mklazy _2 )}
837 838

simple_chan_expr:
839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854
| _1 = val_longident
    {      ( mkexp(Pexp_ident _1) )}
| _1 = constant
    {      ( mkexp(Pexp_constant _1) )}
| _1 = LPAREN _2 = seq_expr _3 = RPAREN
    {      ( _2 )}
| _1 = LPAREN _2 = seq_expr _3 = error
    {      ( unclosed "(" 1 ")" 3 )}
| _1 = BEGIN _2 = seq_expr _3 = END
    {      ( _2 )}
| _1 = BEGIN _2 = seq_expr _3 = error
    {      ( unclosed "begin" 1 "end" 3 )}
| _1 = LPAREN _2 = seq_expr _3 = type_constraint _4 = RPAREN
    {      ( let (t, t') = _3 in mkexp(Pexp_constraint(_2, t, t')) )}
| _1 = simple_chan_expr _2 = DOT _3 = label_longident
    {      ( deconstr_record _1 (fun exp -> mkexp(Pexp_field(exp, _3))) )}
855 856

process0:
857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878
| _1 = REPLY _2 = expr _3 = to_ident
    {      ( mkexp(Pexp_reply(_2,_3)))}
| _1 = REPLY _2 = to_ident
    {      ( mkexp(Pexp_reply(void (),_2)))}
| _1 = simple_chan_expr _2 = simple_expr
    {      ( mkexp(Pexp_call(_1,_2,false)) )}
| _1 = simple_chan_expr _2 = SHARP _3 = label _4 = simple_expr
    {    ( mkexp(Pexp_call(mkexp(Pexp_send(_1, _3)), _4, false)) )}
| _1 = IF _2 = expr _3 = THEN _4 = process0 _5 = ELSE _6 = process0 %prec prec_if
    {      ( mkexp(Pexp_ifthenelse(_2,_4,Some _6)) )}
| _1 = MATCH _2 = seq_expr _3 = WITH _4 = opt_bar _5 = join_match_cases %prec prec_match
    {      ( mkexp(Pexp_match(_2, List.rev _5)) )}
| _1 = LBRACERBRACE
    {                            ( mkexp(Pexp_null) )}
| _1 = LBRACE _2 = process _3 = RBRACE
    {                          ( _2 )}
| _1 = LBRACE _2 = process _3 = error
    {                         ( unclosed "{" 1 "}" 3 )}
| _1 = LBRACE _2 = error
    {                 ( syntax_error () )}
| _1 = LOC _2 = loc_bindings
    {                     ( mkexp(Pexp_location(_2, mkexp(Pexp_null))) )}
879 880

let_bindings:
881 882 883 884
| _1 = let_binding
    {                                                ( [_1] )}
| _1 = let_bindings _2 = AND _3 = let_binding
    {                                                ( _3 :: _1 )}
885 886

let_binding:
887 888 889 890 891 892 893
| _1 = val_ident _2 = fun_binding
    {      ( ({ppat_desc = Ppat_var _1; ppat_loc = rhs_loc 1}, _2) )}
| _1 = pattern _2 = EQUAL _3 = seq_expr %prec prec_let
    {      ( (_1,_3) )}
| _1 = pattern _2 = COLONEQUAL _3 = seq_expr %prec prec_let
    {      (  let r = mkexp (Pexp_ident (Ldot (Lident "Pervasives", "ref"))) in
	    (_1, mkexp (Pexp_apply (r, [_3]))) )}
894 895

fun_binding:
896 897 898 899 900 901
| _1 = EQUAL _2 = seq_expr %prec prec_let
    {      ( _2 )}
| _1 = type_constraint _2 = EQUAL _3 = seq_expr %prec prec_let
    {      ( let (t, t') = _1 in mkexp(Pexp_constraint(_3, t, t')) )}
| _1 = simple_pattern _2 = fun_binding
    {      ( mkexp(Pexp_function[_1,_2]) )}
902 903

parser_cases:
904 905 906 907
| _1 = parser_case
    {                                                ( [_1] )}
| _1 = parser_cases _2 = BAR _3 = parser_case
    {                                                ( _3 :: _1 )}
908 909

parser_case:
910 911 912 913 914 915
| _1 = LBRACKETLESS _2 = stream_pattern _3 = opt_semi _4 = GREATERRBRACKET _5 = opt_pat _6 = MINUSGREATER _7 = seq_expr
    {      ( (List.rev _2, _5, _7) )}
| _1 = LBRACKETLESS _2 = stream_pattern _3 = opt_semi _4 = error
    {      ( unclosed "[<" 1 ">]" 4 )}
| _1 = LBRACKETLESS _2 = GREATERRBRACKET _3 = opt_pat _4 = MINUSGREATER _5 = seq_expr
    {      ( ([], _3, _5) )}
916 917

stream_pattern:
918 919 920 921
| _1 = stream_pattern_component _2 = opt_err
    {                                                         ( [(_1, _2)] )}
| _1 = stream_pattern _2 = SEMI _3 = stream_pattern_component _4 = opt_err
    {                                                         ( (_3, _4) :: _1 )}
922 923

stream_pattern_component:
924 925 926 927 928 929 930 931
| _1 = QUOTE _2 = pattern
    {      ( Pstream.Spat_term (_2, None) )}
| _1 = QUOTE _2 = pattern _3 = WHEN _4 = expr %prec prec_list
    {      ( Pstream.Spat_term (_2, Some _4) )}
| _1 = pattern _2 = EQUAL _3 = expr
    {      ( Pstream.Spat_nterm (_1, _3) )}
| _1 = pattern
    {      ( Pstream.Spat_sterm _1 )}
932 933 934

opt_pat:
| 
935 936 937
    {                                                ( None )}
| _1 = simple_pattern
    {                                                ( Some _1 )}
938 939 940

opt_err:
| 
941 942 943
    {                                                ( None )}
| _1 = QUESTION _2 = expr %prec prec_list
    {                                                ( Some _2 )}
944 945

stream_expr:
946 947 948 949
| _1 = stream_expr_component
    {                                                ( [_1] )}
| _1 = stream_expr _2 = SEMI _3 = stream_expr_component
    {                                                ( _3 :: _1 )}
950 951

stream_expr_component:
952 953 954 955
| _1 = QUOTE _2 = expr %prec prec_list
    {                                                ( Pstream.Sexp_term _2 )}
| _1 = expr %prec prec_list
    {                                                ( Pstream.Sexp_nterm _1 )}
956 957

match_cases:
958 959 960 961
| _1 = pattern _2 = match_action
    {                                                ( [_1, _2] )}
| _1 = match_cases _2 = BAR _3 = pattern _4 = match_action
    {                                                ( (_3, _4) :: _1 )}
962 963

fun_def:
964 965 966 967
| _1 = match_action
    {                                                ( _1 )}
| _1 = simple_pattern _2 = fun_def
    {                                                ( mkexp(Pexp_function[_1,_2]) )}
968 969

match_action:
970 971 972 973
| _1 = MINUSGREATER _2 = seq_expr
    {                                                ( _2 )}
| _1 = WHEN _2 = seq_expr _3 = MINUSGREATER _4 = seq_expr
    {                                                ( mkexp(Pexp_when(_2, _4)) )}
974 975

expr_comma_list:
976 977 978 979
| _1 = expr_comma_list _2 = COMMA _3 = expr
    {                                                ( _3 :: _1 )}
| _1 = expr _2 = COMMA _3 = expr
    {                                                ( [_3; _1] )}
980 981

lbl_expr_list:
982 983 984 985
| _1 = label_longident _2 = EQUAL _3 = expr %prec prec_list
    {      ( [_1,_3] )}
| _1 = lbl_expr_list _2 = SEMI _3 = label_longident _4 = EQUAL _5 = expr %prec prec_list
    {      ( (_3, _5) :: _1 )}
986 987

label_expr_list:
988 989 990 991
| _1 = label _2 = EQUAL _3 = expr %prec prec_list
    {      ( [_1,_3] )}
| _1 = label_expr_list _2 = SEMI _3 = label _4 = EQUAL _5 = expr %prec prec_list
    {      ( (_3, _5) :: _1 )}
992 993

expr_semi_list:
994 995 996 997
| _1 = expr %prec prec_list
    {                                                ( [_1] )}
| _1 = expr_semi_list _2 = SEMI _3 = expr %prec prec_list
    {                                                ( _3 :: _1 )}
998 999

type_constraint:
1000 1001 1002 1003 1004 1005 1006 1007 1008 1009
| _1 = COLON _2 = core_type
    {                                                ( (Some _2, None) )}
| _1 = COLON _2 = core_type _3 = COLONGREATER _4 = core_type
    {                                                ( (Some _2, Some _4) )}
| _1 = COLONGREATER _2 = core_type
    {                                                ( (None, Some _2) )}
| _1 = COLON _2 = error
    {                                                ( syntax_error() )}
| _1 = COLONGREATER _2 = error
    {                                                ( syntax_error() )}
1010 1011

pattern:
1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024
| _1 = simple_pattern
    {      ( _1 )}
| _1 = pattern _2 = AS _3 = val_ident
    {      ( mkpat(Ppat_alias(_1, _3)) )}
| _1 = pattern_comma_list
    {      ( mkpat(Ppat_tuple(List.rev _1)) )}
| _1 = constr_longident _2 = pattern %prec prec_constr_appl
    {      ( mkpat(Ppat_construct(_1, Some _2, false)) )}
| _1 = pattern _2 = COLONCOLON _3 = pattern
    {      ( mkpat(Ppat_construct(Lident "::", Some(mkpat(Ppat_tuple[_1;_3])),
                             false)) )}
| _1 = pattern _2 = BAR _3 = pattern
    {      ( mkpat(Ppat_or(_1, _3)) )}
1025 1026

simple_pattern:
1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052
| _1 = val_ident
    {      ( mkpat(Ppat_var _1) )}
| _1 = UNDERSCORE
    {      ( mkpat(Ppat_any) )}
| _1 = signed_constant
    {      ( mkpat(Ppat_constant _1) )}
| _1 = CHAR _2 = DOTDOT _3 = CHAR
    {      ( mkrangepat _1 _3 )}
| _1 = constr_longident
    {      ( mkpat(Ppat_construct(_1, None, false)) )}
| _1 = LBRACE _2 = lbl_pattern_list _3 = opt_semi _4 = RBRACE
    {      ( mkpat(Ppat_record(List.rev _2)) )}
| _1 = LBRACE _2 = lbl_pattern_list _3 = opt_semi _4 = error
    {      ( unclosed "{" 1 "}" 4 )}
| _1 = LBRACKET _2 = pattern_semi_list _3 = opt_semi _4 = RBRACKET
    {      ( mklistpat(List.rev _2) )}
| _1 = LBRACKET _2 = pattern_semi_list _3 = opt_semi _4 = error
    {      ( unclosed "{" 1 "}" 4 )}
| _1 = LPAREN _2 = pattern _3 = RPAREN
    {      ( _2 )}
| _1 = LPAREN _2 = pattern _3 = error
    {      ( unclosed "(" 1 ")" 3 )}
| _1 = LPAREN _2 = pattern _3 = COLON _4 = core_type _5 = RPAREN
    {      ( mkpat(Ppat_constraint(_2, _4)) )}
| _1 = LPAREN _2 = pattern _3 = COLON _4 = core_type _5 = error
    {      ( unclosed "(" 1 ")" 5 )}
1053 1054

pattern_comma_list:
1055 1056 1057 1058
| _1 = pattern_comma_list _2 = COMMA _3 = pattern
    {                                                ( _3 :: _1 )}
| _1 = pattern _2 = COMMA _3 = pattern
    {                                                ( [_3; _1] )}
1059 1060

pattern_semi_list:
1061 1062 1063 1064
| _1 = pattern
    {                                                ( [_1] )}
| _1 = pattern_semi_list _2 = SEMI _3 = pattern
    {                                                ( _3 :: _1 )}
1065 1066

lbl_pattern_list:
1067 1068 1069 1070
| _1 = label_longident _2 = EQUAL _3 = pattern
    {                                                ( [(_1, _3)] )}
| _1 = lbl_pattern_list _2 = SEMI _3 = label_longident _4 = EQUAL _5 = pattern
    {                                                        ( (_3, _5) :: _1 )}
1071 1072

primitive_declaration:
1073 1074 1075 1076
| _1 = STRING
    {                                                ( [_1] )}
| _1 = STRING _2 = primitive_declaration
    {                                                ( _1 :: _2 )}
1077 1078

class_list:
1079 1080 1081 1082
| _1 = class_list _2 = AND _3 = class_def
    {                                                ( _3 :: _1 )}
| _1 = class_def
    {                                                ( [_1] )}
1083 1084

class_def:
1085 1086 1087 1088 1089 1090
| _1 = virtual_flag _2 = closed_flag _3 = class_type_parameters _4 = LIDENT _5 = simple_pattern_list _6 = self _7 = self_type _8 = EQUAL _9 = constraints _10 = class_fields
    {          ( { pcl_name = _4; pcl_param = _3; pcl_args = List.rev _5;
              pcl_self = _6; pcl_self_ty = _7; pcl_cstr = List.rev _9;
              pcl_field = List.rev _10;
              pcl_kind = _1; pcl_closed = _2;
              pcl_loc = symbol_loc () } )}
1091 1092

class_type_parameters:
1093 1094
| _1 = type_parameters
    {                                                ( _1, symbol_loc () )}
1095 1096

simple_pattern_list:
1097 1098 1099 1100
| _1 = simple_pattern
    {                                                ( [_1] )}
| _1 = simple_pattern_list _2 = simple_pattern
    {                                                ( _2::_1 )}
1101 1102

self:
1103 1104
| _1 = AS _2 = LIDENT
    {                                                ( Some _2 )}
1105
| 
1106
    {                                                ( None )}
1107 1108 1109

class_fields:
| 
1110 1111 1112 1113 1114 1115 1116 1117 1118
    {                                                ( [] )}
| _1 = class_fields _2 = INHERIT _3 = ancestor
    {                                                ( Pcf_inher _3 :: _1 )}
| _1 = class_fields _2 = VAL _3 = value
    {                                                ( Pcf_val _3 :: _1 )}
| _1 = class_fields _2 = virtual_method
    {                                                ( Pcf_virt _2 :: _1 )}
| _1 = class_fields _2 = method_def
    {                                                ( Pcf_meth _2 :: _1 )}
1119 1120

ancestor:
1121 1122 1123 1124 1125 1126
| _1 = LPAREN _2 = core_type_comma_list _3 = RPAREN _4 = class_longident _5 = simple_expr_list _6 = self
    {          ( _4, List.rev _2, List.rev _5, _6, symbol_loc () )}
| _1 = LPAREN _2 = core_type _3 = RPAREN _4 = class_longident _5 = simple_expr_list _6 = self
    {          ( _4, [_2], List.rev _5, _6, symbol_loc () )}
| _1 = class_longident _2 = simple_expr_list _3 = self
    {          ( _1, [], List.rev _2, _3, symbol_loc () )}
1127 1128

value:
1129 1130 1131 1132
| _1 = private_flag _2 = mutable_flag _3 = label _4 = EQUAL _5 = seq_expr
    {          ( _3, _1, _2, Some _5, symbol_loc () )}
| _1 = private_flag _2 = mutable_flag _3 = label
    {          ( _3, _1, _2, None, symbol_loc () )}
1133 1134

virtual_method:
1135 1136
| _1 = VIRTUAL _2 = protected_flag _3 = label _4 = COLON _5 = core_type
    {          ( _3, _2, _5, symbol_loc () )}
1137 1138

meth_binding:
1139 1140 1141 1142 1143 1144 1145
| _1 = EQUAL _2 = seq_expr %prec prec_let
    {       ( (_2,0) )}
| _1 = type_constraint _2 = EQUAL _3 = seq_expr %prec prec_let
    {       ( let (t, t') = _1 in (mkexp(Pexp_constraint(_3, t, t')),0) )}
| _1 = simple_pattern _2 = meth_binding
    {       ( 
       let (s2,nparams) = _2
1146
         in
1147
         (mkexp(Pexp_function[_1,s2]),nparams+1) )}
1148 1149

method_def:
1150 1151 1152
| _1 = METHOD _2 = protected_flag _3 = label _4 = meth_binding
    {          ( let (s4,np)= _4 in
	    _3, np , _2, s4, symbol_loc () )}
1153 1154

class_type_list:
1155 1156 1157 1158
| _1 = class_type_list _2 = AND _3 = class_type
    {                                                ( _3 :: _1 )}
| _1 = class_type
    {                                                ( [_1] )}
1159 1160

class_type:
1161 1162 1163 1164 1165 1166
| _1 = virtual_flag _2 = closed_flag _3 = class_type_parameters _4 = LIDENT _5 = type_list _6 = self_type _7 = EQUAL _8 = constraints _9 = class_type_fields
    {          ( { pcty_name = _4; pcty_param = _3; pcty_args = _5;
              pcty_self = _6; pcty_cstr = List.rev _8;
              pcty_field = List.rev _9;
              pcty_kind = _1; pcty_closed = _2;
              pcty_loc = symbol_loc () } )}
1167 1168

type_list:
1169 1170 1171 1172
| _1 = LPAREN _2 = core_type _3 = RPAREN _4 = type_list
    {                                                ( _2 :: _4 )}
| _1 = LPAREN _2 = core_type _3 = RPAREN
    {                                                ( [_2] )}
1173 1174

self_type:
1175 1176
| _1 = COLON _2 = type_parameter
    {                                                ( Some _2 )}
1177
| 
1178
    {                                                ( None )}
1179 1180

constraints:
1181 1182
| _1 = constraints _2 = CONSTRAINT _3 = constrain
    {                                                ( _3 :: _1 )}
1183
| 
1184
    {                                                ( [] )}
1185 1186

constrain:
1187 1188
| _1 = type_parameter _2 = EQUAL _3 = core_type
    {                                                ( _1, _3, symbol_loc () )}
1189 1190 1191

class_type_fields:
| 
1192 1193 1194 1195 1196 1197 1198 1199 1200
    {                                                ( [] )}
| _1 = class_type_fields _2 = INHERIT _3 = ancestor_type
    {                                                ( Pctf_inher _3 :: _1 )}
| _1 = class_type_fields _2 = VAL _3 = value_type
    {                                                ( Pctf_val _3 :: _1 )}
| _1 = class_type_fields _2 = virtual_method
    {                                                ( Pctf_virt _2 :: _1 )}
| _1 = class_type_fields _2 = method_type
    {                                                ( Pctf_meth _2 :: _1 )}
1201 1202

ancestor_type:
1203 1204 1205 1206 1207 1208
| _1 = LPAREN _2 = core_type_comma_list _3 = RPAREN _4 = class_longident
    {          ( _4, List.rev _2, symbol_loc () )}
| _1 = LPAREN _2 = core_type _3 = RPAREN _4 = class_longident
    {          ( _4, [_2], symbol_loc () )}
| _1 = class_longident
    {          ( _1, [], symbol_loc () )}
1209 1210

value_type:
1211 1212 1213 1214
| _1 = private_flag _2 = mutable_flag _3 = label _4 = COLON _5 = core_type
    {          ( _3, _1, _2, Some _5, symbol_loc () )}
| _1 = private_flag _2 = mutable_flag _3 = label
    {          ( _3, _1, _2, None, symbol_loc () )}
1215 1216

method_type:
1217 1218 1219 1220
| _1 = METHOD _2 = protected_flag _3 = label _4 = COLON _5 = core_type
    {          ( _3, _2, _5, symbol_loc () )}
| _1 = METHOD _2 = protected_flag _3 = label
    {          ( _3, _2, mktyp(Ptyp_any), symbol_loc () )}
1221 1222

type_declarations:
1223 1224 1225 1226
| _1 = type_declaration
    {                                                ( [_1] )}
| _1 = type_declarations _2 = AND _3 = type_declaration
    {                                                ( _3 :: _1 )}
1227 1228

type_declaration:
1229 1230 1231 1232
| _1 = type_parameters _2 = LIDENT _3 = type_kind _4 = constraints
    {      ( let (kind, manifest) = _3 in
        (_2, {ptype_params = _1;
              ptype_cstrs = List.rev _4;
1233 1234
              ptype_kind = kind;
              ptype_manifest = manifest;
1235
              ptype_loc = symbol_loc()}) )}
1236 1237 1238

type_kind:
| 
1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251
    {      ( (Ptype_abstract, None) )}
| _1 = EQUAL _2 = core_type %prec prec_type_def
    {      ( (Ptype_abstract, Some _2) )}
| _1 = EQUAL _2 = constructor_declarations_ext
    {      ( (Ptype_variant(List.rev _2), None) )}
| _1 = EQUAL _2 = BAR _3 = constructor_declarations_ext
    {      ( (Ptype_variant(List.rev _3), None) )}
| _1 = EQUAL _2 = LBRACE _3 = label_declarations _4 = opt_semi _5 = RBRACE
    {      ( (Ptype_record(List.rev _3), None) )}
| _1 = EQUAL _2 = core_type _3 = EQUAL _4 = opt_bar _5 = constructor_declarations_ext %prec prec_type_def
    {      ( (Ptype_variant(List.rev _5), Some _2) )}
| _1 = EQUAL _2 = core_type _3 = EQUAL _4 = LBRACE _5 = label_declarations _6 = opt_semi _7 = RBRACE %prec prec_type_def
    {      ( (Ptype_record(List.rev _5), Some _2) )}
1252 1253 1254

type_parameters:
| 
1255 1256 1257 1258 1259
    {                                                ( [] )}
| _1 = type_parameter
    {                                                ( [_1] )}
| _1 = LPAREN _2 = type_parameter_list _3 = RPAREN
    {                                                ( List.rev _2 )}
1260 1261

type_parameter:
1262 1263
| _1 = QUOTE _2 = ident
    {                                                ( _2 )}
1264 1265

type_parameter_list:
1266 1267 1268 1269
| _1 = type_parameter
    {                                                ( [_1] )}
| _1 = type_parameter_list _2 = COMMA _3 = type_parameter
    {                                                ( _3 :: _1 )}
1270 1271

constructor_declarations:
1272 1273 1274 1275
| _1 = constructor_declaration
    {                                                ( [_1] )}
| _1 = constructor_declarations _2 = BAR _3 = constructor_declaration
    {                                                         ( _3 :: _1 )}
1276 1277

constructor_declarations_ext:
1278 1279 1280 1281
| _1 = constructor_declarations
    {                                                 ( _1 )}
| _1 = tag_constructor_declarations
    {                                                 ( _1 )}
1282 1283

tag_constructor_declarations:
1284 1285 1286 1287
| _1 = tag_constructor_declaration
    {                                                    ( [_1] )}
| _1 = tag_constructor_declarations _2 = BAR _3 = tag_constructor_declaration
    {                                                                 ( _3 :: _1 )}
1288 1289

tag_constructor_declaration:
1290 1291
| _1 = constr_ident _2 = LBRACKET _3 = INT _4 = RBRACKET _5 = ext_constructor_arguments
    {                                             ( (_1, Some _3,_5) )}
1292 1293

constructor_declaration:
1294 1295
| _1 = constr_ident _2 = ext_constructor_arguments
    {                                              ( (_1, None, _2) )}
1296 1297 1298

constructor_arguments:
| 
1299 1300 1301
    {                                                ( [] )}
| _1 = OF _2 = core_type_list
    {                                                ( List.rev _2 )}
1302 1303 1304

ext_constructor_arguments:
| 
1305 1306 1307 1308 1309
    {                                                 ( Pconstr_tuple[])}
| _1 = OF _2 = core_type_list
    {                                                 ( Pconstr_tuple(List.rev _2))}
| _1 = OF _2 = LBRACE _3 = label_declarations _4 = opt_semi _5 = RBRACE
    {                                                 ( Pconstr_record(List.rev _3))}
1310 1311

label_declarations:
1312 1313 1314 1315
| _1 = label_declaration
    {                                                ( [_1] )}
| _1 = label_declarations _2 = SEMI _3 = label_declaration
    {                                                ( _3 :: _1 )}
1316 1317

label_declaration:
1318 1319
| _1 = mutable_flag _2 = LIDENT _3 = COLON _4 = core_type
    {                                                ( (_2, _1, _4) )}
1320 1321

with_constraints:
1322 1323 1324 1325
| _1 = with_constraint
    {                                                ( [_1] )}
| _1 = with_constraints _2 = AND _3 = with_constraint
    {                                                ( _3 :: _1 )}
1326 1327

with_constraint:
1328 1329 1330
| _1 = TYPE _2 = type_parameters _3 = label_longident _4 = EQUAL _5 = core_type _6 = constraints
    {      ( (_3, Pwith_type {ptype_params = _2;
                         ptype_cstrs = List.rev _6;
1331
                         ptype_kind = Ptype_abstract;
1332 1333 1334 1335
                         ptype_manifest = Some _5;
                         ptype_loc = symbol_loc()}) )}
| _1 = MODULE _2 = mod_longident _3 = EQUAL _4 = mod_ext_longident
    {      ( (_2, Pwith_module _4) )}
1336 1337

core_type:
1338 1339 1340 1341 1342 1343 1344 1345
| _1 = simple_core_type
    {      ( _1 )}
| _1 = core_type _2 = MINUSGREATER _3 = core_type %prec prec_type_arrow
    {      ( mktyp(Ptyp_arrow(_1, _3)) )}
| _1 = core_type_tuple
    {      ( mktyp(Ptyp_tuple(List.rev _1)) )}
| _1 = core_type _2 = AS _3 = type_parameter
    {      ( mktyp(Ptyp_alias(_1, _3)) )}
1346 1347

simple_core_type:
1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371
| _1 = QUOTE _2 = ident
    {      ( mktyp(Ptyp_var _2) )}
| _1 = LESSLESS _2 = core_type _3 = GREATERGREATER
    {      ( mktyp(Ptyp_channel(_2,Pasync)) )}
| _1 = UNDERSCORE
    {      ( mktyp(Ptyp_any) )}
| _1 = type_longident
    {      ( mktyp(Ptyp_constr(_1, [])) )}
| _1 = simple_core_type _2 = type_longident %prec prec_constr_appl
    {      ( mktyp(Ptyp_constr(_2, [_1])) )}
| _1 = LPAREN _2 = core_type_comma_list _3 = RPAREN _4 = type_longident %prec prec_constr_appl
    {      ( mktyp(Ptyp_constr(_4, List.rev _2)) )}
| _1 = LPAREN _2 = core_type _3 = RPAREN
    {      ( _2 )}
| _1 = LESS _2 = meth_list _3 = GREATER
    {      ( mktyp(Ptyp_object _2) )}
| _1 = LESS _2 = GREATER
    {      ( mktyp(Ptyp_object []) )}
| _1 = SHARP _2 = class_longident
    {      ( mktyp(Ptyp_class(_2, [])) )}
| _1 = simple_core_type _2 = SHARP _3 = class_longident %prec prec_constr_appl
    {      ( mktyp(Ptyp_class(_3, [_1])) )}
| _1 = LPAREN _2 = core_type_comma_list _3 = RPAREN _4 = SHARP _5 = class_longident %prec prec_constr_appl
    {      ( mktyp(Ptyp_class(_5, List.rev _2)) )}
1372 1373

core_type_tuple:
1374 1375 1376 1377
| _1 = simple_core_type _2 = STAR _3 = simple_core_type
    {                                                ( [_3; _1] )}
| _1 = core_type_tuple _2 = STAR _3 = simple_core_type
    {                                                ( _3 :: _1 )}
1378 1379

core_type_comma_list:
1380 1381 1382 1383
| _1 = core_type _2 = COMMA _3 = core_type
    {                                                ( [_3; _1] )}
| _1 = core_type_comma_list _2 = COMMA _3 = core_type
    {                                                ( _3 :: _1 )}
1384 1385

core_type_list:
1386 1387 1388 1389
| _1 = simple_core_type
    {                                                ( [_1] )}
| _1 = core_type_list _2 = STAR _3 = simple_core_type
    {                                                ( _3 :: _1 )}
1390 1391

meth_list:
1392 1393 1394 1395 1396 1397
| _1 = field _2 = SEMI _3 = meth_list
    {                                                ( _1 :: _3 )}
| _1 = field _2 = opt_semi
    {                                                ( [_1] )}
| _1 = DOTDOT
    {                                                ( [mkfield Pfield_var] )}
1398 1399

field:
1400 1401
| _1 = label _2 = COLON _3 = core_type
    {                                                ( mkfield(Pfield(_1, _3)) )}
1402 1403

label:
1404 1405
| _1 = LIDENT
    {                                                ( _1 )}
1406 1407

constant:
1408 1409 1410 1411 1412 1413 1414 1415
| _1 = INT
    {                                                ( Const_int _1 )}
| _1 = CHAR
    {                                                ( Const_char _1 )}
| _1 = STRING
    {                                                ( Const_string _1 )}
| _1 = FLOAT
    {                                                ( Const_float _1 )}
1416 1417

signed_constant:
1418 1419 1420 1421 1422 1423
| _1 = constant
    {                                                ( _1 )}
| _1 = SUBTRACTIVE _2 = INT
    {                                                ( Const_int(- _2) )}
| _1 = SUBTRACTIVE _2 = FLOAT
    {                                                ( Const_float("-" ^ _2) )}
1424 1425

ident:
1426 1427 1428 1429
| _1 = UIDENT
    {                                                ( _1 )}
| _1 = LIDENT
    {                                                ( _1 )}
1430 1431

val_ident:
1432 1433 1434 1435
| _1 = LIDENT
    {                                                ( _1 )}
| _1 = LPAREN _2 = operator _3 = RPAREN
    {                                                ( _2 )}
1436 1437

operator:
1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469
| _1 = PREFIXOP
    {                                                ( _1 )}
| _1 = INFIXOP0
    {                                                ( _1 )}
| _1 = LESSGREATER
    {                                                ( "<>" )}
| _1 = INFIXOP1
    {                                                ( _1 )}
| _1 = INFIXOP2
    {                                                ( _1 )}
| _1 = INFIXOP3
    {                                                ( _1 )}
| _1 = INFIXOP4
    {                                                ( _1 )}
| _1 = SUBTRACTIVE
    {                                                ( _1 )}
| _1 = STAR
    {                                                ( "*" )}
| _1 = EQUAL
    {                                                ( "=" )}
| _1 = LESS
    {                                                ( "<" )}
| _1 = GREATER
    {                                                ( ">" )}
| _1 = BARBAR
    {                                                ( "||" )}
| _1 = AMPERSAND
    {                                                ( "&" )}
| _1 = AMPERAMPER
    {                                                ( "&&" )}
| _1 = COLONEQUAL
    {                                                ( ":=" )}
1470 1471

constr_ident:
1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483
| _1 = UIDENT
    {                                                ( _1 )}
| _1 = LBRACKET _2 = RBRACKET
    {                                                ( "[]" )}
| _1 = LPAREN _2 = RPAREN
    {                                                ( "()" )}
| _1 = COLONCOLON
    {                                                ( "::" )}
| _1 = FALSE
    {                                                ( "false" )}
| _1 = TRUE
    {                                                ( "true" )}
1484 1485

val_longident:
1486 1487 1488 1489
| _1 = val_ident
    {                                                ( Lident _1 )}
| _1 = mod_longident _2 = DOT _3 = val_ident
    {                                                ( Ldot(_1, _3) )}
1490 1491

constr_longident:
1492 1493 1494 1495 1496 1497 1498 1499 1500 1501
| _1 = mod_longident
    {                                                ( _1 )}
| _1 = LBRACKET _2 = RBRACKET
    {                                                ( Lident "[]" )}
| _1 = LPAREN _2 = RPAREN
    {                                                ( Lident "()" )}
| _1 = FALSE
    {                                                ( Lident "false" )}
| _1 = TRUE
    {                                                ( Lident "true" )}
1502 1503

label_longident:
1504 1505 1506 1507
| _1 = LIDENT
    {                                                ( Lident _1 )}
| _1 = mod_longident _2 = DOT _3 = LIDENT
    {                                                ( Ldot(_1, _3) )}
1508 1509

type_longident:
1510 1511 1512 1513
| _1 = LIDENT
    {                                                ( Lident _1 )}
| _1 = mod_ext_longident _2 = DOT _3 = LIDENT
    {                                                ( Ldot(_1, _3) )}
1514 1515

mod_longident:
1516 1517 1518 1519
| _1 = UIDENT
    {                                                ( Lident _1 )}
| _1 = mod_longident _2 = DOT _3 = UIDENT
    {                                                ( Ldot(_1, _3) )}
1520 1521

mod_ext_longident:
1522 1523 1524 1525 1526 1527
| _1 = UIDENT
    {                                                ( Lident _1 )}
| _1 = mod_ext_longident _2 = DOT _3 = UIDENT
    {                                                ( Ldot(_1, _3) )}
| _1 = mod_ext_longident _2 = LPAREN _3 = mod_ext_longident _4 = RPAREN
    {                                                      ( Lapply(_1, _3) )}
1528 1529

mty_longident:
1530 1531 1532 1533
| _1 = ident
    {                                                ( Lident _1 )}
| _1 = mod_ext_longident _2 = DOT _3 = ident
    {                                                ( Ldot(_1, _3) )}
1534 1535

class_longident:
1536 1537 1538 1539
| _1 = LIDENT
    {                                                ( Lident _1 )}
| _1 = mod_longident _2 = DOT _3 = LIDENT
    {                                                ( Ldot(_1, _3) )}
1540 1541

toplevel_directive:
1542 1543 1544 1545 1546 1547 1548 1549
| _1 = SHARP _2 = ident
    {                                ( Ptop_dir(_2, Pdir_none) )}
| _1 = SHARP _2 = ident _3 = STRING
    {                                ( Ptop_dir(_2, Pdir_string _3) )}
| _1 = SHARP _2 = ident _3 = INT
    {                                ( Ptop_dir(_2, Pdir_int _3) )}
| _1 = SHARP _2 = ident _3 = val_longident
    {                                ( Ptop_dir(_2, Pdir_ident _3) )}
1550 1551 1552

rec_flag:
| 
1553 1554 1555
    {                                                ( Nonrecursive )}
| _1 = REC
    {                                                ( Recursive )}
1556 1557

direction_flag:
1558 1559 1560 1561
| _1 = TO
    {                                                ( Upto )}
| _1 = DOWNTO
    {                                                ( Downto )}
1562 1563 1564

private_flag:
| 
1565 1566 1567
    {                                                ( Public )}
| _1 = PRIVATE
    {                                                ( Private )}
1568 1569 1570

protected_flag:
| 
1571 1572 1573
    {                                                ( Public )}
| _1 = PROTECTED
    {                                                ( Private )}
1574 1575 1576

mutable_flag:
| 
1577 1578 1579
    {                                                ( Immutable )}
| _1 = MUTABLE
    {                                                ( Mutable )}
1580 1581 1582

virtual_flag:
| 
1583 1584 1585
    {                                                ( Concrete )}
| _1 = VIRTUAL
    {                                                ( Virtual )}
1586 1587 1588

closed_flag:
| 
1589 1590 1591
    {                                                ( Open )}
| _1 = CLOSED
    {                                                ( Closed )}
1592 1593 1594

opt_bar:
| 
1595 1596 1597
    {                                                ( () )}
| _1 = BAR
    {                                                ( () )}
1598 1599 1600

opt_semi:
| 
1601 1602 1603
    {                                                ( () )}
| _1 = SEMI
    {                                                ( () )}
1604 1605 1606 1607 1608 1609 1610

%%