ocaml.opp.exp 58.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
File "ocaml.mly", line 227, characters 7-22:
Warning: the token GREATERRBRACKET is unused.
File "ocaml.mly", line 273, characters 7-23:
Warning: the token QUESTIONQUESTION is unused.
%{
open Location
open Asttypes
open Longident
open Parsetree

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

let reloc_pat x = { x with ppat_loc = symbol_rloc () };;
let reloc_exp x = { x with pexp_loc = symbol_rloc () };;

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

(*
  Ghost expressions and patterns:
  expressions and patterns that do not appear explicitely in the
  source file they have the loc_ghost flag set to true.
  Then the profiler will not try to instrument them and the
  -stypes option will not try to display their type.

  Every grammar rule that generates an element with a location must
  make at most one non-ghost element, the topmost one.

  How to tell whether your location must be ghost:
  A location corresponds to a range of characters in the source file.
  If the location contains a piece of code that is syntactically
  valid (according to the documentation), and corresponds to the
  AST node, then the location must be real; in all other cases,
  it must be ghost.
*)
let ghexp d = { pexp_desc = d; pexp_loc = symbol_gloc () };;
let ghpat d = { ppat_desc = d; ppat_loc = symbol_gloc () };;
let ghtyp d = { ptyp_desc = d; ptyp_loc = symbol_gloc () };;

let mkassert e =
  match e with
  | {pexp_desc = Pexp_construct (Lident "false", None, false) } ->
         mkexp (Pexp_assertfalse)
  | _ -> mkexp (Pexp_assert (e))
;;

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

let neg_float_string f =
  if String.length f > 0 && f.[0] = '-'
  then String.sub f 1 (String.length f - 1)
  else "-" ^ f

let mkuminus name arg =
  match name, arg.pexp_desc with
  | "-", Pexp_constant(Const_int n) ->
      mkexp(Pexp_constant(Const_int(-n)))
  | "-", Pexp_constant(Const_int32 n) ->
      mkexp(Pexp_constant(Const_int32(Int32.neg n)))
  | "-", Pexp_constant(Const_int64 n) ->
      mkexp(Pexp_constant(Const_int64(Int64.neg n)))
  | "-", Pexp_constant(Const_nativeint n) ->
      mkexp(Pexp_constant(Const_nativeint(Nativeint.neg n)))
  | _, Pexp_constant(Const_float f) ->
      mkexp(Pexp_constant(Const_float(neg_float_string f)))
  | _ ->
      mkexp(Pexp_apply(mkoperator ("~" ^ name) 1, ["", arg]))

let rec mktailexp = function
    [] ->
      ghexp(Pexp_construct(Lident "[]", None, false))
  | e1 :: el ->
      let exp_el = mktailexp el in
      let l = {loc_start = e1.pexp_loc.loc_start;
               loc_end = exp_el.pexp_loc.loc_end;
               loc_ghost = true}
      in
      let arg = {pexp_desc = Pexp_tuple [e1; exp_el]; pexp_loc = l} in
      {pexp_desc = Pexp_construct(Lident "::", Some arg, false); pexp_loc = l}

let rec mktailpat = function
    [] ->
      ghpat(Ppat_construct(Lident "[]", None, false))
  | p1 :: pl ->
      let pat_pl = mktailpat pl in
      let l = {loc_start = p1.ppat_loc.loc_start;
               loc_end = pat_pl.ppat_loc.loc_end;
               loc_ghost = true}
      in
      let arg = {ppat_desc = Ppat_tuple [p1; pat_pl]; ppat_loc = l} in
      {ppat_desc = Ppat_construct(Lident "::", Some arg, false); ppat_loc = l}

let ghstrexp e =
  { pstr_desc = Pstr_eval e; pstr_loc = {e.pexp_loc with loc_ghost = true} }

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

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

let rec mkrangepat c1 c2 =
  if c1 > c2 then mkrangepat c2 c1 else
  if c1 = c2 then mkpat(Ppat_constant(Const_char c1)) else
  reloc_pat (deep_mkrangepat c1 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 bigarray_function str name =
  Ldot(Ldot(Lident "Bigarray", str), name)

let bigarray_untuplify = function
    { pexp_desc = Pexp_tuple explist} -> explist
  | exp -> [exp]

let bigarray_get arr arg =
  match bigarray_untuplify arg with
    [c1] ->
      mkexp(Pexp_apply(ghexp(Pexp_ident(bigarray_function "Array1" "get")),
                       ["", arr; "", c1]))
  | [c1;c2] ->
      mkexp(Pexp_apply(ghexp(Pexp_ident(bigarray_function "Array2" "get")),
                       ["", arr; "", c1; "", c2]))
  | [c1;c2;c3] ->
      mkexp(Pexp_apply(ghexp(Pexp_ident(bigarray_function "Array3" "get")),
                       ["", arr; "", c1; "", c2; "", c3]))
  | coords ->
      mkexp(Pexp_apply(ghexp(Pexp_ident(bigarray_function "Genarray" "get")),
                       ["", arr; "", ghexp(Pexp_array coords)]))

let bigarray_set arr arg newval =
  match bigarray_untuplify arg with
    [c1] ->
      mkexp(Pexp_apply(ghexp(Pexp_ident(bigarray_function "Array1" "set")),
                       ["", arr; "", c1; "", newval]))
  | [c1;c2] ->
      mkexp(Pexp_apply(ghexp(Pexp_ident(bigarray_function "Array2" "set")),
                       ["", arr; "", c1; "", c2; "", newval]))
  | [c1;c2;c3] ->
      mkexp(Pexp_apply(ghexp(Pexp_ident(bigarray_function "Array3" "set")),
                       ["", arr; "", c1; "", c2; "", c3; "", newval]))
  | coords ->
      mkexp(Pexp_apply(ghexp(Pexp_ident(bigarray_function "Genarray" "set")),
                       ["", arr; 
                        "", ghexp(Pexp_array coords);
                        "", newval]))
%}
%start implementation
%start interface
%start toplevel_phrase
%start use_file
%token WHILE
%token WHEN
%token VIRTUAL
%token VAL
%token UNDERSCORE
%token TYPE
%token TRY
%token TO
%token TILDE
%token STRUCT
%token SIG
%token SEMISEMI
%token RPAREN
%token REC
%token RBRACKET
%token RBRACE
%token QUOTE
%token QUESTIONQUESTION
%token QUESTION
%token PRIVATE
%token <string> OPTLABEL
%token OPEN
%token OF
%token OBJECT
%token MUTABLE
%token MODULE
%token METHOD
%token MATCH
%token LBRACKETLESS
%token LBRACKETGREATER
%token LAZY
%token <string> LABEL
%token INITIALIZER
%token INHERIT
%token INCLUDE
%token IF
%token GREATERRBRACKET
%token GREATERRBRACE
%token FUNCTOR
%token FUN
%token FOR
%token EXTERNAL
%token EXCEPTION
%token EOF
%token END
%token DOWNTO
%token DOTDOT
%token DONE
%token DO
%token CONSTRAINT
%token COLONGREATER
%token COLON
%token CLASS
%token BARRBRACKET
%token ASSERT
%token IN
%token SEMI
%token LET
%token WITH
%token FUNCTION
%token AND
%token THEN
%token ELSE
%token LESSMINUS
%token COLONEQUAL
%token AS
%token BAR
%token COMMA
%token MINUSGREATER
%token OR
%token BARBAR
%token AMPERSAND
%token AMPERAMPER
%token LESS
%token <string> INFIXOP0
%token GREATER
%token EQUAL
%token <string> INFIXOP1
%token COLONCOLON
%token PLUS
%token MINUSDOT
%token MINUS
%token <string> INFIXOP2
%token STAR
%token <string> INFIXOP3
%token <string> INFIXOP4
%token SHARP
%token DOT
%token <string> UIDENT
%token TRUE
%token <string> STRING
%token <string> PREFIXOP
%token NEW
%token <nativeint> NATIVEINT
%token LPAREN
%token <string> LIDENT
%token LBRACKETBAR
%token LBRACKET
%token LBRACELESS
%token LBRACE
%token <int64> INT64
%token <int32> INT32
%token <int> INT
%token <string> FLOAT
%token FALSE
%token <char> CHAR
%token BEGIN
%token BACKQUOTE
%nonassoc IN 
%nonassoc below_SEMI 
%nonassoc SEMI 
%nonassoc LET 
%nonassoc below_WITH 
%nonassoc WITH FUNCTION 
%nonassoc AND 
%nonassoc THEN 
%nonassoc ELSE 
%nonassoc LESSMINUS 
%right COLONEQUAL 
%nonassoc AS 
%left BAR 
%nonassoc below_COMMA 
%left COMMA 
%right MINUSGREATER 
%right OR BARBAR 
%right AMPERSAND AMPERAMPER 
%nonassoc below_EQUAL 
%left LESS INFIXOP0 GREATER EQUAL 
%right INFIXOP1 
%right COLONCOLON 
%left PLUS MINUSDOT MINUS INFIXOP2 
%left STAR INFIXOP3 
%right INFIXOP4 
%nonassoc prec_unary_minus 
%nonassoc prec_constant_constructor 
%nonassoc prec_constr_appl 
%nonassoc below_SHARP 
%nonassoc SHARP 
%nonassoc below_DOT 
%nonassoc DOT 
%nonassoc UIDENT TRUE STRING PREFIXOP NEW NATIVEINT LPAREN LIDENT LBRACKETBAR LBRACKET LBRACELESS LBRACE INT64 INT32 INT FLOAT FALSE CHAR BEGIN BACKQUOTE 
%type <Parsetree.structure> implementation
%type <Parsetree.signature> interface
%type <Parsetree.toplevel_phrase> toplevel_phrase
%type <Parsetree.toplevel_phrase list> use_file
%%

implementation:
327 328
| _1 = structure _2 = EOF
    {                                         ( _1 )}
329 330

interface:
331 332
| _1 = signature _2 = EOF
    {                                         ( List.rev _1 )}
333 334

toplevel_phrase:
335 336 337 338 339 340 341 342
| _1 = top_structure _2 = SEMISEMI
    {                                         ( Ptop_def _1 )}
| _1 = seq_expr _2 = SEMISEMI
    {                                         ( Ptop_def[ghstrexp _1] )}
| _1 = toplevel_directive _2 = SEMISEMI
    {                                         ( _1 )}
| _1 = EOF
    {                                         ( raise End_of_file )}
343 344

top_structure:
345 346 347 348
| _1 = structure_item
    {                                         ( [_1] )}
| _1 = structure_item _2 = top_structure
    {                                         ( _1 :: _2 )}
349 350

use_file:
351 352 353 354
| _1 = use_file_tail
    {                                         ( _1 )}
| _1 = seq_expr _2 = use_file_tail
    {                                         ( Ptop_def[ghstrexp _1] :: _2 )}
355 356

use_file_tail:
357 358 359 360 361 362 363 364 365 366 367 368 369 370
| _1 = EOF
    {                                                ( [] )}
| _1 = SEMISEMI _2 = EOF
    {                                                ( [] )}
| _1 = SEMISEMI _2 = seq_expr _3 = use_file_tail
    {                                                ( Ptop_def[ghstrexp _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 )}
371 372

module_expr:
373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392
| _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
    {      ( 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 )}
393 394

structure:
395 396 397 398
| _1 = structure_tail
    {                                                ( _1 )}
| _1 = seq_expr _2 = structure_tail
    {                                                ( ghstrexp _1 :: _2 )}
399 400 401

structure_tail:
| 
402 403 404 405 406 407 408 409 410
    {                                                ( [] )}
| _1 = SEMISEMI
    {                                                ( [] )}
| _1 = SEMISEMI _2 = seq_expr _3 = structure_tail
    {                                                ( ghstrexp _2 :: _3 )}
| _1 = SEMISEMI _2 = structure_item _3 = structure_tail
    {                                                ( _2 :: _3 )}
| _1 = structure_item _2 = structure_tail
    {                                                ( _1 :: _2 )}
411 412

structure_item:
413 414
| _1 = LET _2 = rec_flag _3 = let_bindings
    {      ( match _3 with
415
          [{ppat_desc = Ppat_any}, exp] -> mkstr(Pstr_eval exp)
416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438
        | _ -> mkstr(Pstr_value(_2, List.rev _3)) )}
| _1 = EXTERNAL _2 = val_ident_colon _3 = core_type _4 = EQUAL _5 = primitive_declaration
    {      ( mkstr(Pstr_primitive(_2, {pval_type = _3; pval_prim = _5})) )}
| _1 = TYPE _2 = type_declarations
    {      ( mkstr(Pstr_type(List.rev _2)) )}
| _1 = EXCEPTION _2 = UIDENT _3 = constructor_arguments
    {      ( mkstr(Pstr_exception(_2, _3)) )}
| _1 = EXCEPTION _2 = UIDENT _3 = EQUAL _4 = constr_longident
    {      ( mkstr(Pstr_exn_rebind(_2, _4)) )}
| _1 = MODULE _2 = UIDENT _3 = module_binding
    {      ( mkstr(Pstr_module(_2, _3)) )}
| _1 = MODULE _2 = REC _3 = module_rec_bindings
    {      ( mkstr(Pstr_recmodule(List.rev _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_declarations
    {      ( mkstr(Pstr_class (List.rev _2)) )}
| _1 = CLASS _2 = TYPE _3 = class_type_declarations
    {      ( mkstr(Pstr_class_type (List.rev _3)) )}
| _1 = INCLUDE _2 = module_expr
    {      ( mkstr(Pstr_include _2) )}
439 440

module_binding:
441 442 443 444 445 446
| _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)) )}
447 448

module_rec_bindings:
449 450 451 452
| _1 = module_rec_binding
    {                                                  ( [_1] )}
| _1 = module_rec_bindings _2 = AND _3 = module_rec_binding
    {                                                  ( _3 :: _1 )}
453 454

module_rec_binding:
455 456
| _1 = UIDENT _2 = COLON _3 = module_type _4 = EQUAL _5 = module_expr
    {                                                  ( (_1, _3, _5) )}
457 458

module_type:
459 460 461 462 463 464 465 466 467 468 469 470 471 472
| _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 below_WITH
    {      ( 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 )}
473 474 475

signature:
| 
476 477 478 479 480
    {                                                ( [] )}
| _1 = signature _2 = signature_item
    {                                                ( _2 :: _1 )}
| _1 = signature _2 = signature_item _3 = SEMISEMI
    {                                                ( _2 :: _1 )}
481 482

signature_item:
483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506
| _1 = VAL _2 = val_ident_colon _3 = core_type
    {      ( mksig(Psig_value(_2, {pval_type = _3; pval_prim = []})) )}
| _1 = EXTERNAL _2 = val_ident_colon _3 = core_type _4 = EQUAL _5 = primitive_declaration
    {      ( mksig(Psig_value(_2, {pval_type = _3; pval_prim = _5})) )}
| _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 = REC _3 = module_rec_declarations
    {      ( mksig(Psig_recmodule(List.rev _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_descriptions
    {      ( mksig(Psig_class (List.rev _2)) )}
| _1 = CLASS _2 = TYPE _3 = class_type_declarations
    {      ( mksig(Psig_class_type (List.rev _3)) )}
507 508

module_declaration:
509 510 511 512
| _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)) )}
513 514

module_rec_declarations:
515 516 517 518
| _1 = module_rec_declaration
    {                                                        ( [_1] )}
| _1 = module_rec_declarations _2 = AND _3 = module_rec_declaration
    {                                                        ( _3 :: _1 )}
519 520

module_rec_declaration:
521 522
| _1 = UIDENT _2 = COLON _3 = module_type
    {                                                        ( (_1, _3) )}
523 524

class_declarations:
525 526 527 528
| _1 = class_declarations _2 = AND _3 = class_declaration
    {                                                ( _3 :: _1 )}
| _1 = class_declaration
    {                                                ( [_1] )}
529 530

class_declaration:
531 532 533 534 535
| _1 = virtual_flag _2 = class_type_parameters _3 = LIDENT _4 = class_fun_binding
    {      ( let params, variance = List.split (fst _2) in
        {pci_virt = _1; pci_params = params, snd _2;
         pci_name = _3; pci_expr = _4; pci_variance = variance;
         pci_loc = symbol_rloc ()} )}
536 537

class_fun_binding:
538 539 540 541 542 543
| _1 = EQUAL _2 = class_expr
    {      ( _2 )}
| _1 = COLON _2 = class_type _3 = EQUAL _4 = class_expr
    {      ( mkclass(Pcl_constraint(_4, _2)) )}
| _1 = labeled_simple_pattern _2 = class_fun_binding
    {      ( let (l,o,p) = _1 in mkclass(Pcl_fun(l, o, p, _2)) )}
544 545 546

class_type_parameters:
| 
547 548 549
    {                                                ( [], symbol_gloc () )}
| _1 = LBRACKET _2 = type_parameter_list _3 = RBRACKET
    {                                                ( List.rev _2, symbol_rloc () )}
550 551

class_fun_def:
552 553 554 555
| _1 = labeled_simple_pattern _2 = MINUSGREATER _3 = class_expr
    {      ( let (l,o,p) = _1 in mkclass(Pcl_fun(l, o, p, _3)) )}
| _1 = labeled_simple_pattern _2 = class_fun_def
    {      ( let (l,o,p) = _1 in mkclass(Pcl_fun(l, o, p, _2)) )}
556 557

class_expr:
558 559 560 561 562 563 564 565
| _1 = class_simple_expr
    {      ( _1 )}
| _1 = FUN _2 = class_fun_def
    {      ( _2 )}
| _1 = class_simple_expr _2 = simple_labeled_expr_list
    {      ( mkclass(Pcl_apply(_1, List.rev _2)) )}
| _1 = LET _2 = rec_flag _3 = let_bindings _4 = IN _5 = class_expr
    {      ( mkclass(Pcl_let (_2, List.rev _3, _5)) )}
566 567

class_simple_expr:
568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583
| _1 = LBRACKET _2 = core_type_comma_list _3 = RBRACKET _4 = class_longident
    {      ( mkclass(Pcl_constr(_4, List.rev _2)) )}
| _1 = class_longident
    {      ( mkclass(Pcl_constr(_1, [])) )}
| _1 = OBJECT _2 = class_structure _3 = END
    {      ( mkclass(Pcl_structure(_2)) )}
| _1 = OBJECT _2 = class_structure _3 = error
    {      ( unclosed "object" 1 "end" 3 )}
| _1 = LPAREN _2 = class_expr _3 = COLON _4 = class_type _5 = RPAREN
    {      ( mkclass(Pcl_constraint(_2, _4)) )}
| _1 = LPAREN _2 = class_expr _3 = COLON _4 = class_type _5 = error
    {      ( unclosed "(" 1 ")" 5 )}
| _1 = LPAREN _2 = class_expr _3 = RPAREN
    {      ( _2 )}
| _1 = LPAREN _2 = class_expr _3 = error
    {      ( unclosed "(" 1 ")" 3 )}
584 585

class_structure:
586 587
| _1 = class_self_pattern _2 = class_fields
    {      ( _1, List.rev _2 )}
588 589

class_self_pattern:
590 591 592 593
| _1 = LPAREN _2 = pattern _3 = RPAREN
    {      ( reloc_pat _2 )}
| _1 = LPAREN _2 = pattern _3 = COLON _4 = core_type _5 = RPAREN
    {      ( mkpat(Ppat_constraint(_2, _4)) )}
594
| 
595
    {      ( ghpat(Ppat_any) )}
596 597 598

class_fields:
| 
599 600 601 602 603 604 605 606 607 608 609 610 611
    {      ( [] )}
| _1 = class_fields _2 = INHERIT _3 = class_expr _4 = parent_binder
    {      ( Pcf_inher (_3, _4) :: _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 = concrete_method
    {      ( Pcf_meth _2 :: _1 )}
| _1 = class_fields _2 = CONSTRAINT _3 = constrain
    {      ( Pcf_cstr _3 :: _1 )}
| _1 = class_fields _2 = INITIALIZER _3 = seq_expr
    {      ( Pcf_init _3 :: _1 )}
612 613

parent_binder:
614 615
| _1 = AS _2 = LIDENT
    {          ( Some _2 )}
616
| 
617
    {          (None)}
618 619

value:
620 621 622 623 624
| _1 = mutable_flag _2 = label _3 = EQUAL _4 = seq_expr
    {          ( _2, _1, _4, symbol_rloc () )}
| _1 = mutable_flag _2 = label _3 = type_constraint _4 = EQUAL _5 = seq_expr
    {          ( _2, _1, (let (t, t') = _3 in ghexp(Pexp_constraint(_5, t, t'))),
            symbol_rloc () )}
625 626

virtual_method:
627 628 629 630
| _1 = METHOD _2 = PRIVATE _3 = VIRTUAL _4 = label _5 = COLON _6 = poly_type
    {      ( _4, Private, _6, symbol_rloc () )}
| _1 = METHOD _2 = VIRTUAL _3 = private_flag _4 = label _5 = COLON _6 = poly_type
    {      ( _4, _3, _6, symbol_rloc () )}
631 632

concrete_method:
633 634 635 636 637 638
| _1 = METHOD _2 = private_flag _3 = label _4 = strict_binding
    {      ( _3, _2, ghexp(Pexp_poly (_4, None)), symbol_rloc () )}
| _1 = METHOD _2 = private_flag _3 = label _4 = COLON _5 = poly_type _6 = EQUAL _7 = seq_expr
    {      ( _3, _2, ghexp(Pexp_poly(_7,Some _5)), symbol_rloc () )}
| _1 = METHOD _2 = private_flag _3 = LABEL _4 = poly_type _5 = EQUAL _6 = seq_expr
    {      ( _3, _2, ghexp(Pexp_poly(_6,Some _4)), symbol_rloc () )}
639 640

class_type:
641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656
| _1 = class_signature
    {      ( _1 )}
| _1 = QUESTION _2 = LIDENT _3 = COLON _4 = simple_core_type_or_tuple _5 = MINUSGREATER _6 = class_type
    {      ( mkcty(Pcty_fun("?" ^ _2 ,
                       {ptyp_desc = Ptyp_constr(Lident "option", [_4]);
                        ptyp_loc = _4.ptyp_loc},
                       _6)) )}
| _1 = OPTLABEL _2 = simple_core_type_or_tuple _3 = MINUSGREATER _4 = class_type
    {      ( mkcty(Pcty_fun("?" ^ _1 ,
                       {ptyp_desc = Ptyp_constr(Lident "option", [_2]);
                        ptyp_loc = _2.ptyp_loc},
                       _4)) )}
| _1 = LIDENT _2 = COLON _3 = simple_core_type_or_tuple _4 = MINUSGREATER _5 = class_type
    {      ( mkcty(Pcty_fun(_1, _3, _5)) )}
| _1 = simple_core_type_or_tuple _2 = MINUSGREATER _3 = class_type
    {      ( mkcty(Pcty_fun("", _1, _3)) )}
657 658

class_signature:
659 660 661 662 663 664 665 666
| _1 = LBRACKET _2 = core_type_comma_list _3 = RBRACKET _4 = clty_longident
    {      ( mkcty(Pcty_constr (_4, List.rev _2)) )}
| _1 = clty_longident
    {      ( mkcty(Pcty_constr (_1, [])) )}
| _1 = OBJECT _2 = class_sig_body _3 = END
    {      ( mkcty(Pcty_signature _2) )}
| _1 = OBJECT _2 = class_sig_body _3 = error
    {      ( unclosed "object" 1 "end" 3 )}
667 668

class_sig_body:
669 670
| _1 = class_self_type _2 = class_sig_fields
    {      ( _1, List.rev _2 )}
671 672

class_self_type:
673 674
| _1 = LPAREN _2 = core_type _3 = RPAREN
    {      ( _2 )}
675
| 
676
    {      ( mktyp(Ptyp_any) )}
677 678 679

class_sig_fields:
| 
680 681 682 683 684 685 686 687 688 689 690
    {                                                ( [] )}
| _1 = class_sig_fields _2 = INHERIT _3 = class_signature
    {                                                ( Pctf_inher _3 :: _1 )}
| _1 = class_sig_fields _2 = VAL _3 = value_type
    {                                                ( Pctf_val   _3 :: _1 )}
| _1 = class_sig_fields _2 = virtual_method
    {                                                ( Pctf_virt  _2 :: _1 )}
| _1 = class_sig_fields _2 = method_type
    {                                                ( Pctf_meth  _2 :: _1 )}
| _1 = class_sig_fields _2 = CONSTRAINT _3 = constrain
    {                                                ( Pctf_cstr  _3 :: _1 )}
691 692

value_type:
693 694
| _1 = mutable_flag _2 = label _3 = COLON _4 = core_type
    {      ( _2, _1, Some _4, symbol_rloc () )}
695 696

method_type:
697 698
| _1 = METHOD _2 = private_flag _3 = label _4 = COLON _5 = poly_type
    {      ( _3, _2, _5, symbol_rloc () )}
699 700

constrain:
701 702
| _1 = core_type _2 = EQUAL _3 = core_type
    {                                           ( _1, _3, symbol_rloc () )}
703 704

class_descriptions:
705 706 707 708
| _1 = class_descriptions _2 = AND _3 = class_description
    {                                                ( _3 :: _1 )}
| _1 = class_description
    {                                                ( [_1] )}
709 710

class_description:
711 712 713 714 715
| _1 = virtual_flag _2 = class_type_parameters _3 = LIDENT _4 = COLON _5 = class_type
    {      ( let params, variance = List.split (fst _2) in
        {pci_virt = _1; pci_params = params, snd _2;
         pci_name = _3; pci_expr = _5; pci_variance = variance;
         pci_loc = symbol_rloc ()} )}
716 717

class_type_declarations:
718 719 720 721
| _1 = class_type_declarations _2 = AND _3 = class_type_declaration
    {                                                        ( _3 :: _1 )}
| _1 = class_type_declaration
    {                                                        ( [_1] )}
722 723

class_type_declaration:
724 725 726 727 728
| _1 = virtual_flag _2 = class_type_parameters _3 = LIDENT _4 = EQUAL _5 = class_signature
    {      ( let params, variance = List.split (fst _2) in
        {pci_virt = _1; pci_params = params, snd _2;
         pci_name = _3; pci_expr = _5; pci_variance = variance;
         pci_loc = symbol_rloc ()} )}
729 730

seq_expr:
731 732 733 734 735 736
| _1 = expr %prec below_SEMI
    {                                  ( _1 )}
| _1 = expr _2 = SEMI
    {                                  ( reloc_exp _1 )}
| _1 = expr _2 = SEMI _3 = seq_expr
    {                                  ( mkexp(Pexp_sequence(_1, _3)) )}
737 738

labeled_simple_pattern:
739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754
| _1 = QUESTION _2 = LPAREN _3 = label_let_pattern _4 = opt_default _5 = RPAREN
    {      ( ("?" ^ fst _3, _4, snd _3) )}
| _1 = QUESTION _2 = label_var
    {      ( ("?" ^ fst _2, None, snd _2) )}
| _1 = OPTLABEL _2 = LPAREN _3 = let_pattern _4 = opt_default _5 = RPAREN
    {      ( ("?" ^ _1, _4, _3) )}
| _1 = OPTLABEL _2 = pattern_var
    {      ( ("?" ^ _1, None, _2) )}
| _1 = TILDE _2 = LPAREN _3 = label_let_pattern _4 = RPAREN
    {      ( (fst _3, None, snd _3) )}
| _1 = TILDE _2 = label_var
    {      ( (fst _2, None, snd _2) )}
| _1 = LABEL _2 = simple_pattern
    {      ( (_1, None, _2) )}
| _1 = simple_pattern
    {      ( ("", None, _1) )}
755 756

pattern_var:
757 758
| _1 = LIDENT
    {              ( mkpat(Ppat_var _1) )}
759 760 761

opt_default:
| 
762 763 764
    {                                        ( None )}
| _1 = EQUAL _2 = seq_expr
    {                                        ( Some _2 )}
765 766

label_let_pattern:
767 768 769 770
| _1 = label_var
    {      ( _1 )}
| _1 = label_var _2 = COLON _3 = core_type
    {      ( let (lab, pat) = _1 in (lab, mkpat(Ppat_constraint(pat, _3))) )}
771 772

label_var:
773 774
| _1 = LIDENT
    {              ( (_1, mkpat(Ppat_var _1)) )}
775 776

let_pattern:
777 778 779 780
| _1 = pattern
    {      ( _1 )}
| _1 = pattern _2 = COLON _3 = core_type
    {      ( mkpat(Ppat_constraint(_1, _3)) )}
781 782

expr:
783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 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 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874
| _1 = simple_expr %prec below_SHARP
    {      ( _1 )}
| _1 = simple_expr _2 = simple_labeled_expr_list
    {      ( mkexp(Pexp_apply(_1, List.rev _2)) )}
| _1 = LET _2 = rec_flag _3 = let_bindings _4 = IN _5 = seq_expr
    {      ( mkexp(Pexp_let(_2, List.rev _3, _5)) )}
| _1 = LET _2 = MODULE _3 = UIDENT _4 = module_binding _5 = IN _6 = seq_expr
    {      ( mkexp(Pexp_letmodule(_3, _4, _6)) )}
| _1 = FUNCTION _2 = opt_bar _3 = match_cases
    {      ( mkexp(Pexp_function("", None, List.rev _3)) )}
| _1 = FUN _2 = labeled_simple_pattern _3 = fun_def
    {      ( let (l,o,p) = _2 in mkexp(Pexp_function(l, o, [p, _3])) )}
| _1 = MATCH _2 = seq_expr _3 = WITH _4 = opt_bar _5 = match_cases
    {      ( mkexp(Pexp_match(_2, List.rev _5)) )}
| _1 = TRY _2 = seq_expr _3 = WITH _4 = opt_bar _5 = match_cases
    {      ( mkexp(Pexp_try(_2, List.rev _5)) )}
| _1 = TRY _2 = seq_expr _3 = WITH _4 = error
    {      ( syntax_error() )}
| _1 = expr_comma_list %prec below_COMMA
    {      ( mkexp(Pexp_tuple(List.rev _1)) )}
| _1 = constr_longident _2 = simple_expr %prec below_SHARP
    {      ( mkexp(Pexp_construct(_1, Some _2, false)) )}
| _1 = name_tag _2 = simple_expr %prec below_SHARP
    {      ( mkexp(Pexp_variant(_1, Some _2)) )}
| _1 = IF _2 = seq_expr _3 = THEN _4 = expr _5 = ELSE _6 = expr
    {      ( mkexp(Pexp_ifthenelse(_2, _4, Some _6)) )}
| _1 = IF _2 = seq_expr _3 = THEN _4 = expr
    {      ( mkexp(Pexp_ifthenelse(_2, _4, None)) )}
| _1 = WHILE _2 = seq_expr _3 = DO _4 = seq_expr _5 = DONE
    {      ( mkexp(Pexp_while(_2, _4)) )}
| _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 = expr _2 = COLONCOLON _3 = expr
    {      ( mkexp(Pexp_construct(Lident "::",
                             Some(ghexp(Pexp_tuple[_1;_3])),
                             false)) )}
| _1 = expr _2 = INFIXOP0 _3 = expr
    {      ( mkinfix _1 _2 _3 )}
| _1 = expr _2 = INFIXOP1 _3 = expr
    {      ( mkinfix _1 _2 _3 )}
| _1 = expr _2 = INFIXOP2 _3 = expr
    {      ( mkinfix _1 _2 _3 )}
| _1 = expr _2 = INFIXOP3 _3 = expr
    {      ( mkinfix _1 _2 _3 )}
| _1 = expr _2 = INFIXOP4 _3 = expr
    {      ( mkinfix _1 _2 _3 )}
| _1 = expr _2 = PLUS _3 = expr
    {      ( mkinfix _1 "+" _3 )}
| _1 = expr _2 = MINUS _3 = expr
    {      ( mkinfix _1 "-" _3 )}
| _1 = expr _2 = MINUSDOT _3 = expr
    {      ( mkinfix _1 "-." _3 )}
| _1 = expr _2 = STAR _3 = expr
    {      ( mkinfix _1 "*" _3 )}
| _1 = expr _2 = EQUAL _3 = expr
    {      ( mkinfix _1 "=" _3 )}
| _1 = expr _2 = LESS _3 = expr
    {      ( mkinfix _1 "<" _3 )}
| _1 = expr _2 = GREATER _3 = expr
    {      ( mkinfix _1 ">" _3 )}
| _1 = expr _2 = OR _3 = expr
    {      ( mkinfix _1 "or" _3 )}
| _1 = expr _2 = BARBAR _3 = expr
    {      ( mkinfix _1 "||" _3 )}
| _1 = expr _2 = AMPERSAND _3 = expr
    {      ( mkinfix _1 "&" _3 )}
| _1 = expr _2 = AMPERAMPER _3 = expr
    {      ( mkinfix _1 "&&" _3 )}
| _1 = expr _2 = COLONEQUAL _3 = expr
    {      ( mkinfix _1 ":=" _3 )}
| _1 = subtractive _2 = expr %prec prec_unary_minus
    {      ( mkuminus _1 _2 )}
| _1 = simple_expr _2 = DOT _3 = label_longident _4 = LESSMINUS _5 = expr
    {      ( mkexp(Pexp_setfield(_1, _3, _5)) )}
| _1 = simple_expr _2 = DOT _3 = LPAREN _4 = seq_expr _5 = RPAREN _6 = LESSMINUS _7 = expr
    {      ( mkexp(Pexp_apply(ghexp(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(ghexp(Pexp_ident(array_function "String" "set")),
                         ["",_1; "",_4; "",_7])) )}
| _1 = simple_expr _2 = DOT _3 = LBRACE _4 = expr _5 = RBRACE _6 = LESSMINUS _7 = expr
    {      ( bigarray_set _1 _4 _7 )}
| _1 = label _2 = LESSMINUS _3 = expr
    {      ( mkexp(Pexp_setinstvar(_1, _3)) )}
| _1 = ASSERT _2 = simple_expr %prec below_SHARP
    {      ( mkassert _2 )}
| _1 = LAZY _2 = simple_expr %prec below_SHARP
    {      ( mkexp (Pexp_lazy (_2)) )}
| _1 = OBJECT _2 = class_structure _3 = END
    {      ( mkexp (Pexp_object(_2)) )}
| _1 = OBJECT _2 = class_structure _3 = error
    {      ( unclosed "object" 1 "end" 3 )}
875 876

simple_expr:
877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938
| _1 = val_longident
    {      ( mkexp(Pexp_ident _1) )}
| _1 = constant
    {      ( mkexp(Pexp_constant _1) )}
| _1 = constr_longident %prec prec_constant_constructor
    {      ( mkexp(Pexp_construct(_1, None, false)) )}
| _1 = name_tag %prec prec_constant_constructor
    {      ( mkexp(Pexp_variant(_1, None)) )}
| _1 = LPAREN _2 = seq_expr _3 = RPAREN
    {      ( reloc_exp _2 )}
| _1 = LPAREN _2 = seq_expr _3 = error
    {      ( unclosed "(" 1 ")" 3 )}
| _1 = BEGIN _2 = seq_expr _3 = END
    {      ( reloc_exp _2 )}
| _1 = BEGIN _2 = END
    {      ( mkexp (Pexp_construct (Lident "()", None, false)) )}
| _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
    {      ( mkexp(Pexp_field(_1, _3)) )}
| _1 = simple_expr _2 = DOT _3 = LPAREN _4 = seq_expr _5 = RPAREN
    {      ( mkexp(Pexp_apply(ghexp(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(ghexp(Pexp_ident(array_function "String" "get")),
                         ["",_1; "",_4])) )}
| _1 = simple_expr _2 = DOT _3 = LBRACKET _4 = seq_expr _5 = error
    {      ( unclosed "[" 3 "]" 5 )}
| _1 = simple_expr _2 = DOT _3 = LBRACE _4 = expr _5 = RBRACE
    {      ( bigarray_get _1 _4 )}
| _1 = simple_expr _2 = DOT _3 = LBRACE _4 = expr_comma_list _5 = error
    {      ( unclosed "{" 3 "}" 5 )}
| _1 = LBRACE _2 = record_expr _3 = RBRACE
    {      ( let (exten, fields) = _2 in mkexp(Pexp_record(fields, exten)) )}
| _1 = LBRACE _2 = record_expr _3 = error
    {      ( unclosed "{" 1 "}" 3 )}
| _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
    {      ( reloc_exp (mktailexp (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 = NEW _2 = class_longident
    {      ( mkexp(Pexp_new(_2)) )}
| _1 = LBRACELESS _2 = field_expr_list _3 = opt_semi _4 = GREATERRBRACE
    {      ( mkexp(Pexp_override(List.rev _2)) )}
| _1 = LBRACELESS _2 = field_expr_list _3 = opt_semi _4 = error
    {      ( unclosed "{<" 1 ">}" 4 )}
| _1 = LBRACELESS _2 = GREATERRBRACE
    {      ( mkexp(Pexp_override []) )}
| _1 = simple_expr _2 = SHARP _3 = label
    {      ( mkexp(Pexp_send(_1, _3)) )}
939 940

simple_labeled_expr_list:
941 942 943 944
| _1 = labeled_simple_expr
    {      ( [_1] )}
| _1 = simple_labeled_expr_list _2 = labeled_simple_expr
    {      ( _2 :: _1 )}
945 946

labeled_simple_expr:
947 948 949 950
| _1 = simple_expr %prec below_SHARP
    {      ( ("", _1) )}
| _1 = label_expr
    {      ( _1 )}
951 952

label_expr:
953 954 955 956 957 958 959 960
| _1 = LABEL _2 = simple_expr %prec below_SHARP
    {      ( (_1, _2) )}
| _1 = TILDE _2 = label_ident
    {      ( _2 )}
| _1 = QUESTION _2 = label_ident
    {      ( ("?" ^ fst _2, snd _2) )}
| _1 = OPTLABEL _2 = simple_expr %prec below_SHARP
    {      ( ("?" ^ _1, _2) )}
961 962

label_ident:
963 964
| _1 = LIDENT
    {             ( (_1, mkexp(Pexp_ident(Lident _1))) )}
965 966

let_bindings:
967 968 969 970
| _1 = let_binding
    {                                                ( [_1] )}
| _1 = let_bindings _2 = AND _3 = let_binding
    {                                                ( _3 :: _1 )}
971 972

let_binding:
973 974 975 976
| _1 = val_ident _2 = fun_binding
    {      ( ({ppat_desc = Ppat_var _1; ppat_loc = rhs_loc 1}, _2) )}
| _1 = pattern _2 = EQUAL _3 = seq_expr
    {      ( (_1, _3) )}
977 978

fun_binding:
979 980 981 982
| _1 = strict_binding
    {      ( _1 )}
| _1 = type_constraint _2 = EQUAL _3 = seq_expr
    {      ( let (t, t') = _1 in ghexp(Pexp_constraint(_3, t, t')) )}
983 984

strict_binding:
985 986 987 988
| _1 = EQUAL _2 = seq_expr
    {      ( _2 )}
| _1 = labeled_simple_pattern _2 = fun_binding
    {      ( let (l, o, p) = _1 in ghexp(Pexp_function(l, o, [p, _2])) )}
989 990

match_cases:
991 992 993 994
| _1 = pattern _2 = match_action
    {                                                ( [_1, _2] )}
| _1 = match_cases _2 = BAR _3 = pattern _4 = match_action
    {                                                ( (_3, _4) :: _1 )}
995 996

fun_def:
997 998 999 1000
| _1 = match_action
    {                                                ( _1 )}
| _1 = labeled_simple_pattern _2 = fun_def
    {      ( let (l,o,p) = _1 in ghexp(Pexp_function(l, o, [p, _2])) )}
1001 1002

match_action:
1003 1004 1005 1006
| _1 = MINUSGREATER _2 = seq_expr
    {                                                ( _2 )}
| _1 = WHEN _2 = seq_expr _3 = MINUSGREATER _4 = seq_expr
    {                                                ( mkexp(Pexp_when(_2, _4)) )}
1007 1008

expr_comma_list:
1009 1010 1011 1012
| _1 = expr_comma_list _2 = COMMA _3 = expr
    {                                                ( _3 :: _1 )}
| _1 = expr _2 = COMMA _3 = expr
    {                                                ( [_3; _1] )}
1013 1014

record_expr:
1015 1016 1017 1018
| _1 = simple_expr _2 = WITH _3 = lbl_expr_list _4 = opt_semi
    {                                                ( (Some _1, List.rev _3) )}
| _1 = lbl_expr_list _2 = opt_semi
    {                                                ( (None, List.rev _1) )}
1019 1020

lbl_expr_list:
1021 1022 1023 1024
| _1 = label_longident _2 = EQUAL _3 = expr
    {      ( [_1,_3] )}
| _1 = lbl_expr_list _2 = SEMI _3 = label_longident _4 = EQUAL _5 = expr
    {      ( (_3, _5) :: _1 )}
1025 1026

field_expr_list:
1027 1028 1029 1030
| _1 = label _2 = EQUAL _3 = expr
    {      ( [_1,_3] )}
| _1 = field_expr_list _2 = SEMI _3 = label _4 = EQUAL _5 = expr
    {      ( (_3, _5) :: _1 )}
1031 1032

expr_semi_list:
1033 1034 1035 1036
| _1 = expr
    {                                                ( [_1] )}
| _1 = expr_semi_list _2 = SEMI _3 = expr
    {                                                ( _3 :: _1 )}
1037 1038

type_constraint:
1039 1040 1041 1042 1043 1044 1045 1046 1047 1048
| _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() )}
1049 1050

pattern:
1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065
| _1 = simple_pattern
    {      ( _1 )}
| _1 = pattern _2 = AS _3 = val_ident
    {      ( mkpat(Ppat_alias(_1, _3)) )}
| _1 = pattern_comma_list %prec below_COMMA
    {      ( mkpat(Ppat_tuple(List.rev _1)) )}
| _1 = constr_longident _2 = pattern %prec prec_constr_appl
    {      ( mkpat(Ppat_construct(_1, Some _2, false)) )}
| _1 = name_tag _2 = pattern %prec prec_constr_appl
    {      ( mkpat(Ppat_variant(_1, Some _2)) )}
| _1 = pattern _2 = COLONCOLON _3 = pattern
    {      ( mkpat(Ppat_construct(Lident "::", Some(ghpat(Ppat_tuple[_1;_3])),
                             false)) )}
| _1 = pattern _2 = BAR _3 = pattern
    {      ( mkpat(Ppat_or(_1, _3)) )}
1066 1067

simple_pattern:
1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103
| _1 = val_ident %prec below_EQUAL
    {      ( 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 = name_tag
    {      ( mkpat(Ppat_variant(_1, None)) )}
| _1 = SHARP _2 = type_longident
    {      ( mkpat(Ppat_type _2) )}
| _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
    {      ( reloc_pat (mktailpat (List.rev _2)) )}
| _1 = LBRACKET _2 = pattern_semi_list _3 = opt_semi _4 = error
    {      ( unclosed "[" 1 "]" 4 )}
| _1 = LBRACKETBAR _2 = pattern_semi_list _3 = opt_semi _4 = BARRBRACKET
    {      ( mkpat(Ppat_array(List.rev _2)) )}
| _1 = LBRACKETBAR _2 = BARRBRACKET
    {      ( mkpat(Ppat_array []) )}
| _1 = LBRACKETBAR _2 = pattern_semi_list _3 = opt_semi _4 = error
    {      ( unclosed "[|" 1 "|]" 4 )}
| _1 = LPAREN _2 = pattern _3 = RPAREN
    {      ( reloc_pat _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 )}
1104 1105

pattern_comma_list:
1106 1107 1108 1109
| _1 = pattern_comma_list _2 = COMMA _3 = pattern
    {                                                ( _3 :: _1 )}
| _1 = pattern _2 = COMMA _3 = pattern
    {                                                ( [_3; _1] )}
1110 1111

pattern_semi_list:
1112 1113 1114 1115
| _1 = pattern
    {                                                ( [_1] )}
| _1 = pattern_semi_list _2 = SEMI _3 = pattern
    {                                                ( _3 :: _1 )}
1116 1117

lbl_pattern_list:
1118 1119 1120 1121
| _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 )}
1122 1123

primitive_declaration:
1124 1125 1126 1127
| _1 = STRING
    {                                                ( [_1] )}
| _1 = STRING _2 = primitive_declaration
    {                                                ( _1 :: _2 )}
1128 1129

type_declarations:
1130 1131 1132 1133
| _1 = type_declaration
    {                                                ( [_1] )}
| _1 = type_declarations _2 = AND _3 = type_declaration
    {                                                ( _3 :: _1 )}
1134 1135

type_declaration:
1136 1137 1138 1139 1140
| _1 = type_parameters _2 = LIDENT _3 = type_kind _4 = constraints
    {      ( let (params, variance) = List.split _1 in
        let (kind, manifest) = _3 in
        (_2, {ptype_params = params;
              ptype_cstrs = List.rev _4;
1141 1142 1143
              ptype_kind = kind;
              ptype_manifest = manifest;
              ptype_variance = variance;
1144
              ptype_loc = symbol_rloc()}) )}
1145 1146

constraints:
1147 1148
| _1 = constraints _2 = CONSTRAINT _3 = constrain
    {                                                ( _3 :: _1 )}
1149
| 
1150
    {                                                ( [] )}
1151 1152 1153

type_kind:
| 
1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168
    {      ( (Ptype_abstract, None) )}
| _1 = EQUAL _2 = core_type
    {      ( (Ptype_abstract, Some _2) )}
| _1 = EQUAL _2 = constructor_declarations
    {      ( (Ptype_variant(List.rev _2, Public), None) )}
| _1 = EQUAL _2 = PRIVATE _3 = constructor_declarations
    {      ( (Ptype_variant(List.rev _3, Private), None) )}
| _1 = EQUAL _2 = private_flag _3 = BAR _4 = constructor_declarations
    {      ( (Ptype_variant(List.rev _4, _2), None) )}
| _1 = EQUAL _2 = private_flag _3 = LBRACE _4 = label_declarations _5 = opt_semi _6 = RBRACE
    {      ( (Ptype_record(List.rev _4, _2), None) )}
| _1 = EQUAL _2 = core_type _3 = EQUAL _4 = private_flag _5 = opt_bar _6 = constructor_declarations
    {      ( (Ptype_variant(List.rev _6, _4), Some _2) )}
| _1 = EQUAL _2 = core_type _3 = EQUAL _4 = private_flag _5 = LBRACE _6 = label_declarations _7 = opt_semi _8 = RBRACE
    {      ( (Ptype_record(List.rev _6, _4), Some _2) )}
1169 1170 1171

type_parameters:
| 
1172 1173 1174 1175 1176
    {                                                ( [] )}
| _1 = type_parameter
    {                                                ( [_1] )}
| _1 = LPAREN _2 = type_parameter_list _3 = RPAREN
    {                                                ( List.rev _2 )}
1177 1178

type_parameter:
1179 1180
| _1 = type_variance _2 = QUOTE _3 = ident
    {                                                ( _3, _1 )}
1181 1182 1183

type_variance:
| 
1184 1185 1186 1187 1188
    {                                                ( false, false )}
| _1 = PLUS
    {                                                ( true, false )}
| _1 = MINUS
    {                                                ( false, true )}
1189 1190

type_parameter_list:
1191 1192 1193 1194
| _1 = type_parameter
    {                                                ( [_1] )}
| _1 = type_parameter_list _2 = COMMA _3 = type_parameter
    {                                                ( _3 :: _1 )}
1195 1196

constructor_declarations:
1197 1198 1199 1200
| _1 = constructor_declaration
    {                                                ( [_1] )}
| _1 = constructor_declarations _2 = BAR _3 = constructor_declaration
    {                                                         ( _3 :: _1 )}
1201 1202

constructor_declaration:
1203 1204
| _1 = constr_ident _2 = constructor_arguments
    {                                                ( (_1, _2, symbol_rloc()) )}
1205 1206 1207

constructor_arguments:
| 
1208 1209 1210
    {                                                ( [] )}
| _1 = OF _2 = core_type_list
    {                                                ( List.rev _2 )}
1211 1212

label_declarations:
1213 1214 1215 1216
| _1 = label_declaration
    {                                                ( [_1] )}
| _1 = label_declarations _2 = SEMI _3 = label_declaration
    {                                                ( _3 :: _1 )}
1217 1218

label_declaration:
1219 1220
| _1 = mutable_flag _2 = label _3 = COLON _4 = poly_type
    {                                                ( (_2, _1, _4, symbol_rloc()) )}
1221 1222

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

with_constraint:
1229 1230 1231 1232
| _1 = TYPE _2 = type_parameters _3 = label_longident _4 = EQUAL _5 = core_type _6 = constraints
    {      ( let params, variance = List.split _2 in
        (_3, Pwith_type {ptype_params = params;
                         ptype_cstrs = List.rev _6;
1233
                         ptype_kind = Ptype_abstract;
1234
                         ptype_manifest = Some _5;
1235
                         ptype_variance = variance;
1236 1237 1238
                         ptype_loc = symbol_rloc()}) )}
| _1 = MODULE _2 = mod_longident _3 = EQUAL _4 = mod_ext_longident
    {      ( (_2, Pwith_module _4) )}
1239 1240

typevar_list:
1241 1242 1243 1244
| _1 = QUOTE _2 = ident
    {                                                ( [_2] )}
| _1 = typevar_list _2 = QUOTE _3 = ident
    {                                                ( _3 :: _1 )}
1245 1246

poly_type:
1247 1248 1249 1250
| _1 = core_type
    {          ( mktyp(Ptyp_poly([], _1)) )}
| _1 = typevar_list _2 = DOT _3 = core_type
    {          ( mktyp(Ptyp_poly(List.rev _1, _3)) )}
1251 1252

core_type:
1253 1254 1255 1256
| _1 = core_type2
    {      ( _1 )}
| _1 = core_type2 _2 = AS _3 = QUOTE _4 = ident
    {      ( mktyp(Ptyp_alias(_1, _4)) )}
1257 1258

core_type2:
1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272
| _1 = simple_core_type_or_tuple
    {      ( _1 )}
| _1 = QUESTION _2 = LIDENT _3 = COLON _4 = core_type2 _5 = MINUSGREATER _6 = core_type2
    {      ( mktyp(Ptyp_arrow("?" ^ _2 ,
               {ptyp_desc = Ptyp_constr(Lident "option", [_4]);
                ptyp_loc = _4.ptyp_loc}, _6)) )}
| _1 = OPTLABEL _2 = core_type2 _3 = MINUSGREATER _4 = core_type2
    {      ( mktyp(Ptyp_arrow("?" ^ _1 ,
               {ptyp_desc = Ptyp_constr(Lident "option", [_2]);
                ptyp_loc = _2.ptyp_loc}, _4)) )}
| _1 = LIDENT _2 = COLON _3 = core_type2 _4 = MINUSGREATER _5 = core_type2
    {      ( mktyp(Ptyp_arrow(_1, _3, _5)) )}
| _1 = core_type2 _2 = MINUSGREATER _3 = core_type2
    {      ( mktyp(Ptyp_arrow("", _1, _3)) )}
1273 1274

simple_core_type:
1275 1276 1277 1278
| _1 = simple_core_type2 %prec below_SHARP
    {      ( _1 )}
| _1 = LPAREN _2 = core_type_comma_list _3 = RPAREN %prec below_SHARP
    {      ( match _2 with [sty] -> sty | _ -> raise Parse_error )}
1279 1280

simple_core_type2:
1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314
| _1 = QUOTE _2 = ident
    {      ( mktyp(Ptyp_var _2) )}
| _1 = UNDERSCORE
    {      ( mktyp(Ptyp_any) )}
| _1 = type_longident
    {      ( mktyp(Ptyp_constr(_1, [])) )}
| _1 = simple_core_type2 _2 = type_longident
    {      ( mktyp(Ptyp_constr(_2, [_1])) )}
| _1 = LPAREN _2 = core_type_comma_list _3 = RPAREN _4 = type_longident
    {      ( mktyp(Ptyp_constr(_4, List.rev _2)) )}
| _1 = LESS _2 = meth_list _3 = GREATER
    {      ( mktyp(Ptyp_object _2) )}
| _1 = LESS _2 = GREATER
    {      ( mktyp(Ptyp_object []) )}
| _1 = SHARP _2 = class_longident _3 = opt_present
    {      ( mktyp(Ptyp_class(_2, [], _3)) )}
| _1 = simple_core_type2 _2 = SHARP _3 = class_longident _4 = opt_present
    {      ( mktyp(Ptyp_class(_3, [_1], _4)) )}
| _1 = LPAREN _2 = core_type_comma_list _3 = RPAREN _4 = SHARP _5 = class_longident _6 = opt_present
    {      ( mktyp(Ptyp_class(_5, List.rev _2, _6)) )}
| _1 = LBRACKET _2 = tag_field _3 = RBRACKET
    {      ( mktyp(Ptyp_variant([_2], true, None)) )}
| _1 = LBRACKET _2 = BAR _3 = row_field_list _4 = RBRACKET
    {      ( mktyp(Ptyp_variant(List.rev _3, true, None)) )}
| _1 = LBRACKET _2 = row_field _3 = BAR _4 = row_field_list _5 = RBRACKET
    {      ( mktyp(Ptyp_variant(_2 :: List.rev _4, true, None)) )}
| _1 = LBRACKETGREATER _2 = opt_bar _3 = row_field_list _4 = RBRACKET
    {      ( mktyp(Ptyp_variant(List.rev _3, false, None)) )}
| _1 = LBRACKETGREATER _2 = RBRACKET
    {      ( mktyp(Ptyp_variant([], false, None)) )}
| _1 = LBRACKETLESS _2 = opt_bar _3 = row_field_list _4 = RBRACKET
    {      ( mktyp(Ptyp_variant(List.rev _3, true, Some [])) )}
| _1 = LBRACKETLESS _2 = opt_bar _3 = row_field_list _4 = GREATER _5 = name_tag_list _6 = RBRACKET
    {      ( mktyp(Ptyp_variant(List.rev _3, true, Some (List.rev _5))) )}
1315 1316

row_field_list:
1317 1318 1319 1320
| _1 = row_field
    {                                                ( [_1] )}
| _1 = row_field_list _2 = BAR _3 = row_field
    {                                                ( _3 :: _1 )}
1321 1322

row_field:
1323 1324 1325 1326
| _1 = tag_field
    {                                                ( _1 )}
| _1 = simple_core_type2
    {                                                ( Rinherit _1 )}
1327 1328

tag_field:
1329 1330 1331 1332
| _1 = name_tag _2 = OF _3 = opt_ampersand _4 = amper_type_list
    {      ( Rtag (_1, _3, List.rev _4) )}
| _1 = name_tag
    {      ( Rtag (_1, true, []) )}
1333 1334

opt_ampersand:
1335 1336
| _1 = AMPERSAND
    {                                                ( true )}
1337
| 
1338
    {                                                ( false )}
1339 1340

amper_type_list:
1341 1342 1343 1344
| _1 = core_type
    {                                                ( [_1] )}
| _1 = amper_type_list _2 = AMPERSAND _3 = core_type
    {                                                ( _3 :: _1 )}
1345 1346

opt_present:
1347 1348
| _1 = LBRACKETGREATER _2 = name_tag_list _3 = RBRACKET
    {                                                ( List.rev _2 )}
1349
| 
1350
    {                                                ( [] )}
1351 1352

name_tag_list:
1353 1354 1355 1356
| _1 = name_tag
    {                                                ( [_1] )}
| _1 = name_tag_list _2 = name_tag
    {                                                ( _2 :: _1 )}
1357 1358

simple_core_type_or_tuple:
1359 1360 1361 1362
| _1 = simple_core_type
    {                                                ( _1 )}
| _1 = simple_core_type _2 = STAR _3 = core_type_list
    {      ( mktyp(Ptyp_tuple(_1 :: List.rev _3)) )}
1363 1364

core_type_comma_list:
1365 1366 1367 1368
| _1 = core_type
    {                                                ( [_1] )}
| _1 = core_type_comma_list _2 = COMMA _3 = core_type
    {                                                ( _3 :: _1 )}
1369 1370

core_type_list:
1371 1372 1373 1374
| _1 = simple_core_type
    {                                                ( [_1] )}
| _1 = core_type_list _2 = STAR _3 = simple_core_type
    {                                                ( _3 :: _1 )}
1375 1376

meth_list:
1377 1378 1379 1380 1381 1382
| _1 = field _2 = SEMI _3 = meth_list
    {                                                ( _1 :: _3 )}
| _1 = field _2 = opt_semi
    {                                                ( [_1] )}
| _1 = DOTDOT
    {                                                ( [mkfield Pfield_var] )}
1383 1384

field:
1385 1386
| _1 = label _2 = COLON _3 = poly_type
    {                                                ( mkfield(Pfield(_1, _3)) )}
1387 1388

label:
1389 1390
| _1 = LIDENT
    {                                                ( _1 )}
1391 1392

constant:
1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406
| _1 = INT
    {                                                ( Const_int _1 )}
| _1 = CHAR
    {                                                ( Const_char _1 )}
| _1 = STRING
    {                                                ( Const_string _1 )}
| _1 = FLOAT
    {                                                ( Const_float _1 )}
| _1 = INT32
    {                                                ( Const_int32 _1 )}
| _1 = INT64
    {                                                ( Const_int64 _1 )}
| _1 = NATIVEINT
    {                                                ( Const_nativeint _1 )}
1407 1408

signed_constant:
1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420
| _1 = constant
    {                                                ( _1 )}
| _1 = MINUS _2 = INT
    {                                                ( Const_int(- _2) )}
| _1 = MINUS _2 = FLOAT
    {                                                ( Const_float("-" ^ _2) )}
| _1 = MINUS _2 = INT32
    {                                                ( Const_int32(Int32.neg _2) )}
| _1 = MINUS _2 = INT64
    {                                                ( Const_int64(Int64.neg _2) )}
| _1 = MINUS _2 = NATIVEINT
    {                                                ( Const_nativeint(Nativeint.neg _2) )}
1421 1422

ident:
1423 1424 1425 1426
| _1 = UIDENT
    {                                                ( _1 )}
| _1 = LIDENT
    {                                                ( _1 )}
1427 1428

val_ident:
1429 1430 1431 1432
| _1 = LIDENT
    {                                                ( _1 )}
| _1 = LPAREN _2 = operator _3 = RPAREN
    {                                                ( _2 )}
1433 1434

val_ident_colon:
1435 1436 1437 1438 1439 1440
| _1 = LIDENT _2 = COLON
    {                                                ( _1 )}
| _1 = LPAREN _2 = operator _3 = RPAREN _4 = COLON
    {                                                ( _2 )}
| _1 = LABEL
    {                                                ( _1 )}
1441 1442

operator:
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 1470 1471 1472 1473 1474 1475 1476 1477 1478
| _1 = PREFIXOP
    {                                                ( _1 )}
| _1 = INFIXOP0
    {                                                ( _1 )}
| _1 = INFIXOP1
    {                                                ( _1 )}
| _1 = INFIXOP2
    {                                                ( _1 )}
| _1 = INFIXOP3
    {                                                ( _1 )}
| _1 = INFIXOP4
    {                                                ( _1 )}
| _1 = PLUS
    {                                                ( "+" )}
| _1 = MINUS
    {                                                ( "-" )}
| _1 = MINUSDOT
    {                                                ( "-." )}
| _1 = STAR
    {                                                ( "*" )}
| _1 = EQUAL
    {                                                ( "=" )}
| _1 = LESS
    {                                                ( "<" )}
| _1 = GREATER
    {                                                ( ">" )}
| _1 = OR
    {                                                ( "or" )}
| _1 = BARBAR
    {                                                ( "||" )}
| _1 = AMPERSAND
    {                                                ( "&" )}
| _1 = AMPERAMPER
    {                                                ( "&&" )}
| _1 = COLONEQUAL
    {                                                ( ":=" )}
1479 1480

constr_ident:
1481 1482 1483 1484 1485 1486 1487 1488 1489 1490
| _1 = UIDENT
    {                                                ( _1 )}
| _1 = LPAREN _2 = RPAREN
    {                                                ( "()" )}
| _1 = COLONCOLON
    {                                                ( "::" )}
| _1 = FALSE
    {                                                ( "false" )}
| _1 = TRUE
    {                                                ( "true" )}
1491 1492

val_longident:
1493 1494 1495 1496
| _1 = val_ident
    {                                                ( Lident _1 )}
| _1 = mod_longident _2 = DOT _3 = val_ident
    {                                                ( Ldot(_1, _3) )}
1497 1498

constr_longident:
1499 1500 1501 1502 1503 1504 1505 1506 1507 1508
| _1 = mod_longident %prec below_DOT
    {                                                ( _1 )}
| _1 = LBRACKET _2 = RBRACKET
    {                                                ( Lident "[]" )}
| _1 = LPAREN _2 = RPAREN
    {                                                ( Lident "()" )}
| _1 = FALSE
    {                                                ( Lident "false" )}
| _1 = TRUE
    {                                                ( Lident "true" )}
1509 1510

label_longident:
1511 1512 1513 1514
| _1 = LIDENT
    {                                                ( Lident _1 )}
| _1 = mod_longident _2 = DOT _3 = LIDENT
    {                                                ( Ldot(_1, _3) )}
1515 1516

type_longident:
1517 1518 1519 1520
| _1 = LIDENT
    {                                                ( Lident _1 )}
| _1 = mod_ext_longident _2 = DOT _3 = LIDENT
    {                                                ( Ldot(_1, _3) )}
1521 1522

mod_longident:
1523 1524 1525 1526
| _1 = UIDENT
    {                                                ( Lident _1 )}
| _1 = mod_longident _2 = DOT _3 = UIDENT
    {                                                ( Ldot(_1, _3) )}
1527 1528

mod_ext_longident:
1529 1530 1531 1532 1533 1534
| _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) )}
1535 1536

mty_longident:
1537 1538 1539 1540
| _1 = ident
    {                                                ( Lident _1 )}
| _1 = mod_ext_longident _2 = DOT _3 = ident
    {                                                ( Ldot(_1, _3) )}
1541 1542

clty_longident:
1543 1544 1545 1546
| _1 = LIDENT
    {                                                ( Lident _1 )}
| _1 = mod_ext_longident _2 = DOT _3 = LIDENT
    {                                                ( Ldot(_1, _3) )}
1547 1548

class_longident:
1549 1550 1551 1552
| _1 = LIDENT
    {                                                ( Lident _1 )}
| _1 = mod_longident _2 = DOT _3 = LIDENT
    {                                                ( Ldot(_1, _3) )}
1553 1554

toplevel_directive:
1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566
| _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) )}
| _1 = SHARP _2 = ident _3 = FALSE
    {                                ( Ptop_dir(_2, Pdir_bool false) )}
| _1 = SHARP _2 = ident _3 = TRUE
    {                                ( Ptop_dir(_2, Pdir_bool true) )}
1567 1568

name_tag:
1569 1570
| _1 = BACKQUOTE _2 = ident
    {                                                ( _2 )}
1571 1572 1573

rec_flag:
| 
1574 1575 1576
    {                                                ( Nonrecursive )}
| _1 = REC
    {                                                ( Recursive )}
1577 1578

direction_flag:
1579 1580 1581 1582
| _1 = TO
    {                                                ( Upto )}
| _1 = DOWNTO
    {                                                ( Downto )}
1583 1584 1585

private_flag:
| 
1586 1587 1588
    {                                                ( Public )}
| _1 = PRIVATE
    {                                                ( Private )}
1589 1590 1591

mutable_flag:
| 
1592 1593 1594
    {                                                ( Immutable )}
| _1 = MUTABLE
    {                                                ( Mutable )}
1595 1596 1597

virtual_flag:
| 
1598 1599 1600
    {                                                ( Concrete )}
| _1 = VIRTUAL
    {                                                ( Virtual )}
1601 1602 1603

opt_bar:
| 
1604 1605 1606
    {                                                ( () )}
| _1 = BAR
    {                                                ( () )}
1607 1608 1609

opt_semi:
| 
1610 1611 1612
    {                                                ( () )}
| _1 = SEMI
    {                                                ( () )}
1613 1614

subtractive:
1615 1616 1617 1618
| _1 = MINUS
    {                                                ( "-" )}
| _1 = MINUSDOT
    {                                                ( "-." )}
1619 1620 1621 1622 1623 1624 1625

%%