docOckXmlParser.opp.exp 44.4 KB
Newer Older
1
%parameter< Root : sig type t end >
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
%{

open DocOckPaths
open DocOckTypes

let relax_class_path cl =
  match (cl : ('a, Kind.identifier_class) Path.Resolved.t) with
  | Path.Resolved.Identifier (Identifier.Class _)
  | Path.Resolved.Class _ as cl -> cl

let relax_class_type_path cltyp =
  match (cltyp : 'a Path.Resolved.class_type) with
  | Path.Resolved.Identifier (Identifier.Class _ | Identifier.ClassType _)
  | Path.Resolved.Class _
  | Path.Resolved.ClassType _ as cltyp -> cltyp

let relax_datatype_reference typ =
  match (typ : 'a Reference.Resolved.datatype) with
  | Reference.Resolved.Identifier (Identifier.Type _ | Identifier.CoreType _)
  | Reference.Resolved.Type _ as typ -> typ

let relax_extension_reference ext =
  match (ext : 'a Reference.Resolved.extension) with
  | Reference.Resolved.Identifier
      (Identifier.Exception _ | Identifier.CoreException _
      | Identifier.Extension _)
  | Reference.Resolved.Exception _
  | Reference.Resolved.Extension _ as ext -> ext

let relax_exception_reference exn =
  match (exn : 'a Reference.Resolved.exception_) with
  | Reference.Resolved.Identifier
      (Identifier.Exception _ | Identifier.CoreException _)
  | Reference.Resolved.Exception _ as exn -> exn

let relax_class_reference cl =
  match (cl : 'a Reference.Resolved.class_) with
  | Reference.Resolved.Identifier (Identifier.Class _)
  | Reference.Resolved.Class _ as cl -> cl

let relax_class_type_reference cltyp =
  match (cltyp : 'a Reference.Resolved.class_type) with
  | Reference.Resolved.Identifier
      (Identifier.Class _ | Identifier.ClassType _)
  | Reference.Resolved.Class _
  | Reference.Resolved.ClassType _ as cltyp -> cltyp

%}
%start file
%start unit
%token ALIAS
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
%token ANY
%token APPLY
%token ARGUMENTS
%token ARROW
%token AUTHOR
%token <int option> Argument
%token BEFORE
%token BOLD
%token <Root.t> Base
%token CENTER
%token CLASS
%token CLASS_TYPE
%token CLOSE
%token CLOSED
%token CODE
%token COLUMN
%token COMMENT
%token CONSTANT
%token CONSTRAINT
%token CONSTRUCTOR
%token <string> Custom
%token DEPRECATED
%token DIGEST
%token DIR
%token DOC
%token DOT
%token DTD
%token <string> Data
%token ELEMENT
%token EMPHASIZE
%token ENUM
%token EOF
%token ERROR
%token EXCEPTION
%token EXTENSIBLE
%token EXTENSION
%token EXTERNAL
%token FIELD
%token FILE
%token FILENAME
%token FIXED
%token FUNCTOR
%token IDENTIFIER
%token IMPORT
%token INCLUDE
%token INDEX
%token INHERIT
%token INSTANCE_VARIABLE
%token INTERFACE
%token ITALIC
%token ITEM
%token LABEL
%token LEFT
%token LINE
%token LINK
%token LIST
%token LOCATION
%token METHOD
%token MODULE
%token MODULES
%token MODULE_SUBST
%token MODULE_TYPE
%token MUTABLE
%token NAME
%token NEG
%token NEWLINE
%token OBJECT
%token OFFSET
%token OPEN
%token OPTIONAL
%token PACK
%token PACKAGE
%token PARAM
%token PATH
%token POLY
%token POLY_VARIANT
%token POS
%token POSITION
%token PRECODE
%token PRIMITIVE
%token PRIVATE
%token RAISE
%token RECORD
%token REFERENCE
%token RESOLVED
%token RESULT
%token RETURN
%token RIGHT
%token ROOT
%token SECTION
%token SEE
%token SIGNATURE
%token SINCE
%token SOURCE
%token SPECIAL
%token STOP
%token SUBSCRIPT
%token SUBST
%token SUBST_ALIAS
%token SUPERSCRIPT
%token TAG
%token TUPLE
%token TYPE
%token TYPEOF
%token TYPE_SUBST
%token <string option> Target
%token <int> Title
%token UNIT
%token URL
%token VALUE
%token VAR
%token VARIANT
%token VERBATIM
%token VERSION
%token VIRTUAL
%token WITH
169 170 171 172
%type <Root.t DocOckTypes.Unit.t> file
%type <Root.t DocOckTypes.Unit.t> unit
%%

173 174 175 176 177
option_argument_label_:
  
    {    ( None )}
| x = argument_label
    {    ( Some x )}
178

179 180 181 182 183
option_digest_:
  
    {    ( None )}
| x = digest
    {    ( Some x )}
184

185 186 187 188 189
option_label_identifier_:
  
    {    ( None )}
| x = label_identifier
    {    ( Some x )}
190

191 192 193 194 195
option_location_:
  
    {    ( None )}
| x = location
    {    ( Some x )}
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
option_module_type_expr_:
  
    {    ( None )}
| x = module_type_expr
    {    ( Some x )}

option_source_:
  
    {    ( None )}
| x = source
    {    ( Some x )}

option_type_expr_:
  
    {    ( None )}
| x = type_expr
    {    ( Some x )}

option_type_representation_:
  
    {    ( None )}
| x = type_representation
    {    ( Some x )}

option_variance_:
  
    {    ( None )}
| x = variance
    {    ( Some x )}

list_class_signature_item_:
  
    {    ( [] )}
| x = class_signature_item xs = list_class_signature_item_
    {    ( x :: xs )}

list_module_reference_:
  
    {    ( [] )}
| x = module_reference xs = list_module_reference_
    {    ( x :: xs )}

list_name_:
  
    {    ( [] )}
| x = name xs = list_name_
    {    ( x :: xs )}

list_object_method_:
  
    {    ( [] )}
| x = object_method xs = list_object_method_
    {    ( x :: xs )}

list_package_substitution_:
  
    {    ( [] )}
| x = package_substitution xs = list_package_substitution_
    {    ( x :: xs )}

list_packed_item_:
  
    {    ( [] )}
| x = packed_item xs = list_packed_item_
    {    ( x :: xs )}

list_poly_variant_element_:
  
    {    ( [] )}
| x = poly_variant_element xs = list_poly_variant_element_
    {    ( x :: xs )}

list_signature_item_:
  
    {    ( [] )}
| x = signature_item xs = list_signature_item_
    {    ( x :: xs )}

list_tag_:
  
    {    ( [] )}
| x = tag xs = list_tag_
    {    ( x :: xs )}

list_text_element_:
  
    {    ( [] )}
| x = text_element xs = list_text_element_
    {    ( x :: xs )}

list_type_constraint_:
  
    {    ( [] )}
| x = type_constraint xs = list_type_constraint_
    {    ( x :: xs )}

list_type_expr_:
  
    {    ( [] )}
| x = type_expr xs = list_type_expr_
    {    ( x :: xs )}

list_type_parameter_:
  
    {    ( [] )}
| x = type_parameter xs = list_type_parameter_
    {    ( x :: xs )}

list_type_subst_parameter_:
  
    {    ( [] )}
| x = type_subst_parameter xs = list_type_subst_parameter_
    {    ( x :: xs )}

list_unit_import_:
  
    {    ( [] )}
| x = unit_import xs = list_unit_import_
    {    ( x :: xs )}

nonempty_list_constructor_:
  x = constructor
319
    {    ( [ x ] )}
320
| x = constructor xs = nonempty_list_constructor_
321 322
    {    ( x :: xs )}

323 324
nonempty_list_extension_constructor_:
  x = extension_constructor
325
    {    ( [ x ] )}
326
| x = extension_constructor xs = nonempty_list_extension_constructor_
327 328
    {    ( x :: xs )}

329 330
nonempty_list_external_primitive_:
  x = external_primitive
331
    {    ( [ x ] )}
332
| x = external_primitive xs = nonempty_list_external_primitive_
333 334 335
    {    ( x :: xs )}

nonempty_list_field_:
336
  x = field
337 338 339 340
    {    ( [ x ] )}
| x = field xs = nonempty_list_field_
    {    ( x :: xs )}

341 342
nonempty_list_item_:
  x = item
343
    {    ( [ x ] )}
344
| x = item xs = nonempty_list_item_
345 346
    {    ( x :: xs )}

347 348
nonempty_list_module_argument_:
  x = module_argument
349
    {    ( [ x ] )}
350
| x = module_argument xs = nonempty_list_module_argument_
351 352
    {    ( x :: xs )}

353 354
nonempty_list_name_:
  x = name
355
    {    ( [ x ] )}
356
| x = name xs = nonempty_list_name_
357 358
    {    ( x :: xs )}

359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381
nonempty_list_substitution_:
  x = substitution
    {    ( [ x ] )}
| x = substitution xs = nonempty_list_substitution_
    {    ( x :: xs )}

nonempty_list_text_element_:
  x = text_element
    {    ( [ x ] )}
| x = text_element xs = nonempty_list_text_element_
    {    ( x :: xs )}

nonempty_list_type_expr_:
  x = type_expr
    {    ( [ x ] )}
| x = type_expr xs = nonempty_list_type_expr_
    {    ( x :: xs )}

name:
  _1 = NAME data = Data _3 = CLOSE
    {      ( data )}

flag_CONSTANT_:
382
  
383
    {      ( false )}
384
| _1 = CONSTANT _2 = CLOSE
385 386
    {      ( true )}

387
flag_INTERFACE_:
388
  
389
    {      ( false )}
390
| _1 = INTERFACE _2 = CLOSE
391 392
    {      ( true )}

393
flag_MUTABLE_:
394
  
395
    {      ( false )}
396
| _1 = MUTABLE _2 = CLOSE
397 398
    {      ( true )}

399
flag_OPEN_:
400
  
401
    {      ( false )}
402
| _1 = OPEN _2 = CLOSE
403 404
    {      ( true )}

405
flag_PRIVATE_:
406
  
407
    {      ( false )}
408
| _1 = PRIVATE _2 = CLOSE
409 410
    {      ( true )}

411
flag_VIRTUAL_:
412
  
413
    {      ( false )}
414
| _1 = VIRTUAL _2 = CLOSE
415 416 417
    {      ( true )}

module_identifier:
418
  _1 = ROOT base = Base data = Data _4 = CLOSE
419 420 421 422 423 424 425 426 427
    {      ( Identifier.Root(base, data) )}
| _1 = MODULE sg = signature_identifier data = Data _4 = CLOSE
    {      ( Identifier.Module(sg, data) )}
| pos = Argument sg = signature_identifier data = Data _4 = CLOSE
    {      ( match pos with
        | None -> (raise _eRR)
        | Some pos -> Identifier.Argument(sg, pos, data) )}

module_type_identifier:
428
  _1 = MODULE_TYPE sg = signature_identifier data = Data _4 = CLOSE
429 430
    {      ( Identifier.ModuleType(sg, data) )}

431 432 433 434 435 436 437 438 439 440 441 442
signature_identifier:
  md = module_identifier
    {      ( Identifier.signature_of_module md )}
| mty = module_type_identifier
    {      ( Identifier.signature_of_module_type mty )}

type_identifier:
  _1 = TYPE sg = signature_identifier data = Data _4 = CLOSE
    {      ( Identifier.Type(sg, data) )}
| _1 = TYPE data = Data _3 = CLOSE
    {      ( Identifier.CoreType data )}

443
constructor_identifier:
444
  _1 = CONSTRUCTOR sg = type_identifier data = Data _4 = CLOSE
445 446 447
    {      ( Identifier.Constructor(sg, data) )}

field_identifier:
448
  _1 = FIELD sg = type_identifier data = Data _4 = CLOSE
449 450 451
    {      ( Identifier.Field(sg, data) )}

extension_identifier:
452
  _1 = EXTENSION sg = signature_identifier data = Data _4 = CLOSE
453 454 455
    {      ( Identifier.Extension(sg, data) )}

exception_identifier:
456
  _1 = EXCEPTION sg = signature_identifier data = Data _4 = CLOSE
457 458 459 460
    {      ( Identifier.Exception(sg, data) )}
| _1 = EXCEPTION data = Data _3 = CLOSE
    {      ( Identifier.CoreException data )}

461 462 463 464
value_identifier:
  _1 = VALUE sg = signature_identifier data = Data _4 = CLOSE
    {      ( Identifier.Value(sg, data) )}

465
class_identifier:
466
  _1 = CLASS sg = signature_identifier data = Data _4 = CLOSE
467 468 469
    {      ( Identifier.Class(sg, data) )}

class_type_identifier:
470
  _1 = CLASS_TYPE sg = signature_identifier data = Data _4 = CLOSE
471 472 473
    {      ( Identifier.ClassType(sg, data) )}

class_signature_identifier:
474
  cl = class_identifier
475 476 477 478 479
    {      ( Identifier.class_signature_of_class cl )}
| clty = class_type_identifier
    {      ( Identifier.class_signature_of_class_type clty )}

method_identifier:
480
  _1 = METHOD sg = class_signature_identifier data = Data _4 = CLOSE
481 482 483
    {      ( Identifier.Method(sg, data) )}

instance_variable_identifier:
484
  _1 = INSTANCE_VARIABLE sg = class_signature_identifier data = Data _4 = CLOSE
485 486 487
    {      ( Identifier.InstanceVariable(sg, data) )}

label_identifier:
488
  _1 = LABEL sg = parent_identifier data = Data _4 = CLOSE
489 490 491
    {      ( Identifier.Label(sg, data) )}

parent_identifier:
492
  sg = signature_identifier
493 494 495 496 497 498 499
    {    ( Identifier.parent_of_signature sg )}
| csig = class_signature_identifier
    {    ( Identifier.parent_of_class_signature csig )}
| typ = type_identifier
    {    ( Identifier.parent_of_datatype typ )}

element_identifier:
500
  id = module_identifier
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
    {    ( Identifier.any id )}
| id = module_type_identifier
    {    ( Identifier.any id )}
| id = type_identifier
    {    ( Identifier.any id )}
| id = constructor_identifier
    {    ( Identifier.any id )}
| id = field_identifier
    {    ( Identifier.any id )}
| id = extension_identifier
    {    ( Identifier.any id )}
| id = exception_identifier
    {    ( Identifier.any id )}
| id = value_identifier
    {    ( Identifier.any id )}
| id = class_identifier
    {    ( Identifier.any id )}
| id = class_type_identifier
    {    ( Identifier.any id )}
| id = method_identifier
    {    ( Identifier.any id )}
| id = instance_variable_identifier
    {    ( Identifier.any id )}
| id = label_identifier
    {    ( Identifier.any id )}

module_resolved_path:
528
  _1 = IDENTIFIER id = module_identifier _3 = CLOSE
529 530 531 532 533 534 535 536 537 538 539
    {      ( Path.Resolved.ident_module id )}
| _1 = SUBST sub = module_type_resolved_path p = module_resolved_path _4 = CLOSE
    {      ( Path.Resolved.Subst(sub, p) )}
| _1 = SUBST_ALIAS sub = module_resolved_path p = module_resolved_path _4 = CLOSE
    {      ( Path.Resolved.SubstAlias(sub, p) )}
| _1 = MODULE md = module_resolved_path data = Data _4 = CLOSE
    {      ( Path.Resolved.Module(md, data) )}
| _1 = APPLY md = module_resolved_path arg = module_path _4 = CLOSE
    {      ( Path.Resolved.Apply(md, arg) )}

module_type_resolved_path:
540
  _1 = IDENTIFIER id = module_type_identifier _3 = CLOSE
541 542 543 544
    {      ( Path.Resolved.ident_module_type id )}
| _1 = MODULE_TYPE md = module_resolved_path data = Data _4 = CLOSE
    {      ( Path.Resolved.ModuleType(md, data) )}

545 546 547 548 549 550 551 552
type_resolved_path:
  _1 = IDENTIFIER id = type_identifier _3 = CLOSE
    {      ( Path.Resolved.ident_type id )}
| _1 = TYPE md = module_resolved_path data = Data _4 = CLOSE
    {      ( Path.Resolved.Type(md, data) )}
| cltyp = class_type_resolved_path
    {      ( relax_class_type_path cltyp )}

553
class_resolved_path:
554
  _1 = IDENTIFIER id = class_identifier _3 = CLOSE
555 556 557 558 559
    {      ( Path.Resolved.ident_class id )}
| _1 = CLASS md = module_resolved_path data = Data _4 = CLOSE
    {      ( Path.Resolved.Class(md, data) )}

class_type_resolved_path:
560
  _1 = IDENTIFIER id = class_type_identifier _3 = CLOSE
561 562 563 564 565 566 567
    {      ( Path.Resolved.ident_class_type id )}
| _1 = CLASS_TYPE md = module_resolved_path data = Data _4 = CLOSE
    {      ( Path.Resolved.ClassType(md, data) )}
| cl = class_resolved_path
    {      ( relax_class_path cl )}

module_path:
568
  _1 = RESOLVED path = module_resolved_path _3 = CLOSE
569 570 571 572 573 574 575 576 577
    {      ( Path.Resolved path )}
| _1 = ROOT data = Data _3 = CLOSE
    {      ( Path.Root data )}
| _1 = DOT md = module_path data = Data _4 = CLOSE
    {      ( Path.Dot(md, data) )}
| _1 = APPLY md = module_path arg = module_path _4 = CLOSE
    {      ( Path.Apply(md, arg) )}

module_type_path:
578
  _1 = RESOLVED path = module_type_resolved_path _3 = CLOSE
579 580 581 582
    {      ( Path.Resolved path )}
| _1 = DOT md = module_path data = Data _4 = CLOSE
    {      ( Path.Dot(md, data) )}

583 584 585 586 587 588
type_path:
  _1 = RESOLVED path = type_resolved_path _3 = CLOSE
    {      ( Path.Resolved path )}
| _1 = DOT md = module_path data = Data _4 = CLOSE
    {      ( Path.Dot(md, data) )}

589
class_type_path:
590
  _1 = RESOLVED path = class_type_resolved_path _3 = CLOSE
591 592 593 594 595
    {      ( Path.Resolved path )}
| _1 = DOT md = module_path data = Data _4 = CLOSE
    {      ( Path.Dot(md, data) )}

module_resolved_fragment:
596
  _1 = SUBST sub = module_type_resolved_path p = module_resolved_fragment _4 = CLOSE
597 598 599 600 601 602
    {      ( Fragment.Resolved.Subst(sub, p) )}
| _1 = SUBST_ALIAS sub = module_resolved_path p = module_resolved_fragment _4 = CLOSE
    {      ( Fragment.Resolved.SubstAlias(sub, p) )}
| _1 = MODULE md = signature_resolved_fragment data = Data _4 = CLOSE
    {      ( Fragment.Resolved.Module(md, data) )}

603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626
type_resolved_fragment:
  _1 = TYPE md = signature_resolved_fragment data = Data _4 = CLOSE
    {      ( Fragment.Resolved.Type(md, data) )}
| _1 = CLASS md = signature_resolved_fragment data = Data _4 = CLOSE
    {      ( Fragment.Resolved.Class(md, data) )}
| _1 = CLASS_TYPE md = signature_resolved_fragment data = Data _4 = CLOSE
    {      ( Fragment.Resolved.ClassType(md, data) )}

signature_resolved_fragment:
  _1 = ROOT _2 = CLOSE
    {      ( Fragment.Resolved.Root )}
| _1 = SUBST sub = module_type_resolved_path p = signature_resolved_fragment _4 = CLOSE
    {      ( Fragment.Resolved.Subst(sub, p) )}
| _1 = SUBST_ALIAS sub = module_resolved_path p = signature_resolved_fragment _4 = CLOSE
    {      ( Fragment.Resolved.SubstAlias(sub, p) )}
| _1 = MODULE md = signature_resolved_fragment data = Data _4 = CLOSE
    {      ( Fragment.Resolved.Module(md, data) )}

signature_fragment:
  _1 = RESOLVED frag = signature_resolved_fragment _3 = CLOSE
    {      ( Fragment.Resolved frag )}
| _1 = DOT md = signature_fragment data = Data _4 = CLOSE
    {      ( Fragment.Dot(md, data) )}

627
module_fragment:
628
  _1 = RESOLVED frag = module_resolved_fragment _3 = CLOSE
629 630 631 632
    {      ( Fragment.Resolved frag )}
| _1 = DOT md = signature_fragment data = Data _4 = CLOSE
    {      ( Fragment.Dot(md, data) )}

633 634 635 636 637 638
type_fragment:
  _1 = RESOLVED frag = type_resolved_fragment _3 = CLOSE
    {      ( Fragment.Resolved frag )}
| _1 = DOT md = signature_fragment data = Data _4 = CLOSE
    {      ( Fragment.Dot(md, data) )}

639
module_resolved_reference:
640
  _1 = IDENTIFIER id = module_identifier _3 = CLOSE
641 642 643 644 645
    {      ( Reference.Resolved.ident_module id )}
| _1 = MODULE sg = signature_resolved_reference data = Data _4 = CLOSE
    {      ( Reference.Resolved.Module(sg, data) )}

module_type_resolved_reference:
646
  _1 = IDENTIFIER id = module_type_identifier _3 = CLOSE
647 648 649 650
    {      ( Reference.Resolved.ident_module_type id )}
| _1 = MODULE_TYPE sg = signature_resolved_reference data = Data _4 = CLOSE
    {      ( Reference.Resolved.ModuleType(sg, data) )}

651 652 653 654 655 656
signature_resolved_reference:
  md = module_resolved_reference
    {      ( Reference.Resolved.signature_of_module md )}
| mty = module_type_resolved_reference
    {      ( Reference.Resolved.signature_of_module_type mty )}

657
datatype_resolved_reference:
658
  _1 = IDENTIFIER id = type_identifier _3 = CLOSE
659 660 661 662
    {      ( Reference.Resolved.ident_type id )}
| _1 = TYPE sg = signature_resolved_reference data = Data _4 = CLOSE
    {      ( Reference.Resolved.Type(sg, data) )}

663 664 665 666 667 668
type_resolved_reference:
  typ = datatype_resolved_reference
    {      ( relax_datatype_reference typ )}
| cltyp = class_type_resolved_reference
    {      ( relax_class_type_reference cltyp )}

669
constructor_resolved_reference:
670
  _1 = IDENTIFIER id = constructor_identifier _3 = CLOSE
671 672 673 674 675 676
    {      ( Reference.Resolved.ident_constructor id )}
| _1 = CONSTRUCTOR sg = datatype_resolved_reference data = Data _4 = CLOSE
    {      ( Reference.Resolved.Constructor(sg, data) )}
| ext = extension_resolved_reference
    {      ( relax_extension_reference ext )}

677 678 679 680 681 682
field_resolved_reference:
  _1 = IDENTIFIER id = field_identifier _3 = CLOSE
    {      ( Reference.Resolved.ident_field id )}
| _1 = FIELD sg = datatype_resolved_reference data = Data _4 = CLOSE
    {      ( Reference.Resolved.Field(sg, data) )}

683
exception_resolved_reference:
684
  _1 = IDENTIFIER id = exception_identifier _3 = CLOSE
685 686 687 688 689
    {      ( Reference.Resolved.ident_exception id )}
| _1 = EXCEPTION sg = signature_resolved_reference data = Data _4 = CLOSE
    {      ( Reference.Resolved.Exception(sg, data) )}

extension_resolved_reference:
690
  _1 = IDENTIFIER id = extension_identifier _3 = CLOSE
691 692 693 694 695 696
    {      ( Reference.Resolved.ident_extension id )}
| _1 = EXTENSION sg = signature_resolved_reference data = Data _4 = CLOSE
    {      ( Reference.Resolved.Extension(sg, data) )}
| exn = exception_resolved_reference
    {      ( relax_exception_reference exn )}

697 698 699 700 701 702
value_resolved_reference:
  _1 = IDENTIFIER id = value_identifier _3 = CLOSE
    {      ( Reference.Resolved.ident_value id )}
| _1 = VALUE sg = signature_resolved_reference data = Data _4 = CLOSE
    {      ( Reference.Resolved.Value(sg, data) )}

703
class_resolved_reference:
704
  _1 = IDENTIFIER id = class_identifier _3 = CLOSE
705 706 707 708 709
    {      ( Reference.Resolved.ident_class id )}
| _1 = CLASS sg = signature_resolved_reference data = Data _4 = CLOSE
    {      ( Reference.Resolved.Class(sg, data) )}

class_type_resolved_reference:
710
  _1 = IDENTIFIER id = class_type_identifier _3 = CLOSE
711 712 713 714 715 716 717
    {      ( Reference.Resolved.ident_class_type id )}
| _1 = CLASS_TYPE sg = signature_resolved_reference data = Data _4 = CLOSE
    {      ( Reference.Resolved.ClassType(sg, data) )}
| cl = class_resolved_reference
    {      ( relax_class_reference cl )}

method_resolved_reference:
718
  _1 = IDENTIFIER id = method_identifier _3 = CLOSE
719 720 721 722 723
    {      ( Reference.Resolved.ident_method id )}
| _1 = METHOD sg = class_type_resolved_reference data = Data _4 = CLOSE
    {      ( Reference.Resolved.Method(sg, data) )}

instance_variable_resolved_reference:
724
  _1 = IDENTIFIER id = instance_variable_identifier _3 = CLOSE
725 726 727 728 729
    {      ( Reference.Resolved.ident_instance_variable id )}
| _1 = INSTANCE_VARIABLE sg = class_type_resolved_reference data = Data _4 = CLOSE
    {      ( Reference.Resolved.InstanceVariable(sg, data) )}

label_resolved_reference:
730
  _1 = IDENTIFIER id = label_identifier _3 = CLOSE
731 732 733 734
    {      ( Reference.Resolved.ident_label id )}
| _1 = LABEL sg = parent_resolved_reference data = Data _4 = CLOSE
    {      ( Reference.Resolved.Label(sg, data) )}

735 736 737 738 739 740 741 742
parent_resolved_reference:
  sg = signature_resolved_reference
    {      ( Reference.Resolved.parent_of_signature sg )}
| csig = class_type_resolved_reference
    {      ( Reference.Resolved.parent_of_class_signature csig )}
| t = datatype_resolved_reference
    {      ( Reference.Resolved.parent_of_datatype t )}

743
element_resolved_reference:
744
  _1 = IDENTIFIER id = element_identifier _3 = CLOSE
745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772
    {      ( Reference.Resolved.Identifier id )}
| _1 = MODULE sg = signature_resolved_reference data = Data _4 = CLOSE
    {      ( Reference.Resolved.Module(sg, data) )}
| _1 = MODULE_TYPE sg = signature_resolved_reference data = Data _4 = CLOSE
    {      ( Reference.Resolved.ModuleType(sg, data) )}
| _1 = TYPE sg = signature_resolved_reference data = Data _4 = CLOSE
    {      ( Reference.Resolved.Type(sg, data) )}
| _1 = CONSTRUCTOR sg = datatype_resolved_reference data = Data _4 = CLOSE
    {      ( Reference.Resolved.Constructor(sg, data) )}
| _1 = FIELD sg = datatype_resolved_reference data = Data _4 = CLOSE
    {      ( Reference.Resolved.Field(sg, data) )}
| _1 = EXCEPTION sg = signature_resolved_reference data = Data _4 = CLOSE
    {      ( Reference.Resolved.Exception(sg, data) )}
| _1 = EXTENSION sg = signature_resolved_reference data = Data _4 = CLOSE
    {      ( Reference.Resolved.Extension(sg, data) )}
| _1 = VALUE sg = signature_resolved_reference data = Data _4 = CLOSE
    {      ( Reference.Resolved.Value(sg, data) )}
| _1 = CLASS sg = signature_resolved_reference data = Data _4 = CLOSE
    {      ( Reference.Resolved.Class(sg, data) )}
| _1 = CLASS_TYPE sg = signature_resolved_reference data = Data _4 = CLOSE
    {      ( Reference.Resolved.ClassType(sg, data) )}
| _1 = METHOD sg = class_type_resolved_reference data = Data _4 = CLOSE
    {      ( Reference.Resolved.Method(sg, data) )}
| _1 = INSTANCE_VARIABLE sg = class_type_resolved_reference data = Data _4 = CLOSE
    {      ( Reference.Resolved.InstanceVariable(sg, data) )}
| _1 = LABEL sg = parent_resolved_reference data = Data _4 = CLOSE
    {      ( Reference.Resolved.Label(sg, data) )}

773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796
module_reference:
  _1 = RESOLVED rf = module_resolved_reference _3 = CLOSE
    {      ( Reference.Resolved rf )}
| _1 = ROOT data = Data _3 = CLOSE
    {      ( Reference.Root data )}
| _1 = DOT p = parent_reference data = Data _4 = CLOSE
    {      ( Reference.Dot(p, data) )}

module_type_reference:
  _1 = RESOLVED rf = module_type_resolved_reference _3 = CLOSE
    {      ( Reference.Resolved rf )}
| _1 = ROOT data = Data _3 = CLOSE
    {      ( Reference.Root data )}
| _1 = DOT p = parent_reference data = Data _4 = CLOSE
    {      ( Reference.Dot(p, data) )}

type_reference:
  _1 = RESOLVED rf = type_resolved_reference _3 = CLOSE
    {      ( Reference.Resolved rf )}
| _1 = ROOT data = Data _3 = CLOSE
    {      ( Reference.Root data )}
| _1 = DOT p = parent_reference data = Data _4 = CLOSE
    {      ( Reference.Dot(p, data) )}

797
constructor_reference:
798
  _1 = RESOLVED rf = constructor_resolved_reference _3 = CLOSE
799 800 801 802 803 804 805
    {      ( Reference.Resolved rf )}
| _1 = ROOT data = Data _3 = CLOSE
    {      ( Reference.Root data )}
| _1 = DOT p = parent_reference data = Data _4 = CLOSE
    {      ( Reference.Dot(p, data) )}

field_reference:
806
  _1 = RESOLVED rf = field_resolved_reference _3 = CLOSE
807 808 809 810 811 812 813
    {      ( Reference.Resolved rf )}
| _1 = ROOT data = Data _3 = CLOSE
    {      ( Reference.Root data )}
| _1 = DOT p = parent_reference data = Data _4 = CLOSE
    {      ( Reference.Dot(p, data) )}

extension_reference:
814
  _1 = RESOLVED rf = extension_resolved_reference _3 = CLOSE
815 816 817 818 819 820 821
    {      ( Reference.Resolved rf )}
| _1 = ROOT data = Data _3 = CLOSE
    {      ( Reference.Root data )}
| _1 = DOT p = parent_reference data = Data _4 = CLOSE
    {      ( Reference.Dot(p, data) )}

exception_reference:
822
  _1 = RESOLVED rf = exception_resolved_reference _3 = CLOSE
823 824 825 826 827 828
    {      ( Reference.Resolved rf )}
| _1 = ROOT data = Data _3 = CLOSE
    {      ( Reference.Root data )}
| _1 = DOT p = parent_reference data = Data _4 = CLOSE
    {      ( Reference.Dot(p, data) )}

829 830 831 832 833 834 835 836
value_reference:
  _1 = RESOLVED rf = value_resolved_reference _3 = CLOSE
    {      ( Reference.Resolved rf )}
| _1 = ROOT data = Data _3 = CLOSE
    {      ( Reference.Root data )}
| _1 = DOT p = parent_reference data = Data _4 = CLOSE
    {      ( Reference.Dot(p, data) )}

837
class_reference:
838
  _1 = RESOLVED rf = class_resolved_reference _3 = CLOSE
839 840 841 842 843 844 845
    {      ( Reference.Resolved rf )}
| _1 = ROOT data = Data _3 = CLOSE
    {      ( Reference.Root data )}
| _1 = DOT p = parent_reference data = Data _4 = CLOSE
    {      ( Reference.Dot(p, data) )}

class_type_reference:
846
  _1 = RESOLVED rf = class_type_resolved_reference _3 = CLOSE
847 848 849 850 851 852 853
    {      ( Reference.Resolved rf )}
| _1 = ROOT data = Data _3 = CLOSE
    {      ( Reference.Root data )}
| _1 = DOT p = parent_reference data = Data _4 = CLOSE
    {      ( Reference.Dot(p, data) )}

method_reference:
854
  _1 = RESOLVED rf = method_resolved_reference _3 = CLOSE
855 856 857 858 859 860 861
    {      ( Reference.Resolved rf )}
| _1 = ROOT data = Data _3 = CLOSE
    {      ( Reference.Root data )}
| _1 = DOT p = parent_reference data = Data _4 = CLOSE
    {      ( Reference.Dot(p, data) )}

instance_variable_reference:
862
  _1 = RESOLVED rf = instance_variable_resolved_reference _3 = CLOSE
863 864 865 866 867 868 869
    {      ( Reference.Resolved rf )}
| _1 = ROOT data = Data _3 = CLOSE
    {      ( Reference.Root data )}
| _1 = DOT p = parent_reference data = Data _4 = CLOSE
    {      ( Reference.Dot(p, data) )}

label_reference:
870
  _1 = RESOLVED rf = label_resolved_reference _3 = CLOSE
871 872 873 874 875 876
    {      ( Reference.Resolved rf )}
| _1 = ROOT data = Data _3 = CLOSE
    {      ( Reference.Root data )}
| _1 = DOT p = parent_reference data = Data _4 = CLOSE
    {      ( Reference.Dot(p, data) )}

877 878 879 880 881 882 883 884
parent_reference:
  _1 = RESOLVED rf = parent_resolved_reference _3 = CLOSE
    {      ( Reference.Resolved rf )}
| _1 = ROOT data = Data _3 = CLOSE
    {      ( Reference.Root data )}
| _1 = DOT p = parent_reference data = Data _4 = CLOSE
    {      ( Reference.Dot(p, data) )}

885
element_reference:
886
  _1 = RESOLVED rf = element_resolved_reference _3 = CLOSE
887 888 889 890 891 892
    {      ( Reference.Resolved rf )}
| _1 = ROOT data = Data _3 = CLOSE
    {      ( Reference.Root data )}
| _1 = DOT p = parent_reference data = Data _4 = CLOSE
    {      ( Reference.Dot(p, data) )}

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
reference:
  _1 = MODULE rf = module_reference _3 = CLOSE
    {      ( Documentation.Module rf )}
| _1 = MODULE_TYPE rf = module_type_reference _3 = CLOSE
    {      ( Documentation.ModuleType rf )}
| _1 = TYPE rf = type_reference _3 = CLOSE
    {      ( Documentation.Type rf )}
| _1 = CONSTRUCTOR rf = constructor_reference _3 = CLOSE
    {      ( Documentation.Constructor rf )}
| _1 = FIELD rf = field_reference _3 = CLOSE
    {      ( Documentation.Field rf )}
| _1 = EXTENSION rf = extension_reference _3 = CLOSE
    {      ( Documentation.Extension rf )}
| _1 = EXCEPTION rf = exception_reference _3 = CLOSE
    {      ( Documentation.Exception rf )}
| _1 = VALUE rf = value_reference _3 = CLOSE
    {      ( Documentation.Value rf )}
| _1 = CLASS rf = class_reference _3 = CLOSE
    {      ( Documentation.Class rf )}
| _1 = CLASS_TYPE rf = class_type_reference _3 = CLOSE
    {      ( Documentation.ClassType rf )}
| _1 = METHOD rf = method_reference _3 = CLOSE
    {      ( Documentation.Method rf )}
| _1 = INSTANCE_VARIABLE rf = instance_variable_reference _3 = CLOSE
    {      ( Documentation.InstanceVariable rf )}
| _1 = ELEMENT rf = element_reference _3 = CLOSE
    {      ( Documentation.Element rf )}
| _1 = SECTION rf = label_reference _3 = CLOSE
    {      ( Documentation.Section rf )}
| _1 = LINK data = Data _3 = CLOSE
    {      ( Documentation.Link data )}
| tag = Custom data = Data _3 = CLOSE
    {      ( Documentation.Custom(tag, data) )}

special:
  _1 = MODULES modules = list_module_reference_ _3 = CLOSE
    {      ( Documentation.Modules modules )}
| _1 = INDEX _2 = CLOSE
    {      ( Documentation.Index )}

933
item:
934
  _1 = ITEM elems0 = list_text_element_ _3 = CLOSE
935 936
    {let text =
  let elems = elems0 in
937
        ( elems )
938
in
939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 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 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 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 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124
      ( text )}

text_element:
  data = Data
    {      ( Documentation.Raw data )}
| _1 = CODE _3 = CLOSE
    {let str =
        ( "" )
in
      ( Documentation.Code str )}
| _1 = CODE data0 = Data _3 = CLOSE
    {let str =
  let data = data0 in
        ( data)
in
      ( Documentation.Code str )}
| _1 = PRECODE _3 = CLOSE
    {let str =
        ( "" )
in
      ( Documentation.PreCode str )}
| _1 = PRECODE data0 = Data _3 = CLOSE
    {let str =
  let data = data0 in
        ( data)
in
      ( Documentation.PreCode str )}
| _1 = VERBATIM _3 = CLOSE
    {let str =
        ( "" )
in
      ( Documentation.Verbatim str )}
| _1 = VERBATIM data0 = Data _3 = CLOSE
    {let str =
  let data = data0 in
        ( data)
in
      ( Documentation.Verbatim str )}
| _1 = BOLD elems0 = list_text_element_ _3 = CLOSE
    {let text =
  let elems = elems0 in
        ( elems )
in
      ( Documentation.(Style(Bold, text)) )}
| _1 = ITALIC elems0 = list_text_element_ _3 = CLOSE
    {let text =
  let elems = elems0 in
        ( elems )
in
      ( Documentation.(Style(Italic, text)) )}
| _1 = EMPHASIZE elems0 = list_text_element_ _3 = CLOSE
    {let text =
  let elems = elems0 in
        ( elems )
in
      ( Documentation.(Style(Emphasize, text)) )}
| _1 = CENTER elems0 = list_text_element_ _3 = CLOSE
    {let text =
  let elems = elems0 in
        ( elems )
in
      ( Documentation.(Style(Center, text)) )}
| _1 = LEFT elems0 = list_text_element_ _3 = CLOSE
    {let text =
  let elems = elems0 in
        ( elems )
in
      ( Documentation.(Style(Left, text)) )}
| _1 = RIGHT elems0 = list_text_element_ _3 = CLOSE
    {let text =
  let elems = elems0 in
        ( elems )
in
      ( Documentation.(Style(Right, text)) )}
| _1 = SUPERSCRIPT elems0 = list_text_element_ _3 = CLOSE
    {let text =
  let elems = elems0 in
        ( elems )
in
      ( Documentation.(Style(Superscript, text)) )}
| _1 = SUBSCRIPT elems0 = list_text_element_ _3 = CLOSE
    {let text =
  let elems = elems0 in
        ( elems )
in
      ( Documentation.(Style(Subscript, text)) )}
| tag = Custom elems0 = list_text_element_ _3 = CLOSE
    {let text =
  let elems = elems0 in
        ( elems )
in
      ( Documentation.(Style(Custom tag, text)) )}
| _1 = LIST i = nonempty_list_item_ _3 = CLOSE
    {      ( Documentation.List i )}
| _1 = ENUM i = nonempty_list_item_ _3 = CLOSE
    {      ( Documentation.Enum i )}
| _1 = NEWLINE _2 = CLOSE
    {      ( Documentation.Newline )}
| level = Title label = option_label_identifier_ elems0 = list_text_element_ _4 = CLOSE
    {let text =
  let elems = elems0 in
        ( elems )
in
      ( Documentation.Title(level, label, text) )}
| _1 = REFERENCE rf = reference _4 = CLOSE
    {let text =
        ( None )
in
      ( Documentation.Reference(rf, text) )}
| _1 = REFERENCE rf = reference elems0 = nonempty_list_text_element_ _4 = CLOSE
    {let text =
  let elems = elems0 in
        ( Some elems )
in
      ( Documentation.Reference(rf, text) )}
| target = Target _3 = CLOSE
    {let str =
        ( "" )
in
      ( Documentation.Target(target, str) )}
| target = Target data0 = Data _3 = CLOSE
    {let str =
  let data = data0 in
        ( data)
in
      ( Documentation.Target(target, str) )}
| _1 = SPECIAL special = special _3 = CLOSE
    {      ( Documentation.Special special )}

see:
  _1 = URL data = Data _3 = CLOSE
    {      ( Documentation.Url data )}
| _1 = FILE data = Data _3 = CLOSE
    {      ( Documentation.File data )}
| _1 = DOC data = Data _3 = CLOSE
    {      ( Documentation.Doc data )}

tag:
  _1 = AUTHOR data = Data _3 = CLOSE
    {      ( Documentation.Author data )}
| _1 = VERSION data = Data _3 = CLOSE
    {      ( Documentation.Version data )}
| _1 = SEE see = see elems0 = list_text_element_ _4 = CLOSE
    {let text =
  let elems = elems0 in
        ( elems )
in
      ( Documentation.See(see, text) )}
| _1 = SINCE data = Data _3 = CLOSE
    {      ( Documentation.Since data )}
| _1 = BEFORE name = name elems0 = list_text_element_ _4 = CLOSE
    {let text =
  let elems = elems0 in
        ( elems )
in
      ( Documentation.Before(name, text) )}
| _1 = DEPRECATED elems0 = list_text_element_ _3 = CLOSE
    {let text =
  let elems = elems0 in
        ( elems )
in
      ( Documentation.Deprecated text )}
| _1 = PARAM name = name elems0 = list_text_element_ _4 = CLOSE
    {let text =
  let elems = elems0 in
        ( elems )
in
      ( Documentation.Param(name, text) )}
| _1 = RAISE name = name elems0 = list_text_element_ _4 = CLOSE
    {let text =
  let elems = elems0 in
        ( elems )
in
      ( Documentation.Raise(name, text) )}
| _1 = RETURN elems0 = list_text_element_ _3 = CLOSE
    {let text =
  let elems = elems0 in
        ( elems )
in
      ( Documentation.Return text )}
| _1 = TAG name = name elems0 = list_text_element_ _4 = CLOSE
    {let text =
  let elems = elems0 in
        ( elems )
in
      ( Documentation.Tag(name, text) )}
1125 1126

int:
1127
  data = Data
1128 1129 1130 1131 1132
    {    ( try
        int_of_string data
      with Failure _ -> (raise _eRR) )}

line:
1133
  _1 = LINE line = int _3 = CLOSE
1134 1135 1136
    {    ( line )}

column:
1137
  _1 = COLUMN column = int _3 = CLOSE
1138 1139
    {    ( column )}

1140 1141 1142 1143 1144 1145 1146 1147
position:
  _1 = POSITION line = line column = column _4 = CLOSE
    {    ( Documentation.Error.Position.{line; column} )}

offset:
  _1 = OFFSET start = position finish = position _4 = CLOSE
    {    ( Documentation.Error.Offset.{start; finish} )}

1148
filename:
1149
  _1 = FILENAME data = Data _3 = CLOSE
1150 1151 1152
    {    ( data )}

location:
1153
  _1 = LOCATION filename = filename start = position finish = position _5 = CLOSE
1154 1155 1156
    {      ( Documentation.Error.Location.{filename; start; finish} )}

doc_error:
1157
  _1 = ERROR origin = element_identifier offset = offset location = option_location_ message = Data _6 = CLOSE
1158 1159 1160
    {      ( Documentation.Error.{origin; offset; location; message} )}

doc:
1161
  
1162 1163 1164 1165
    {    ( DocOckAttrs.empty )}
| _1 = DOC elems0 = list_text_element_ tags0 = list_tag_ _4 = CLOSE
    {let tags =
  let tags = tags0 in
1166
        ( tags )
1167 1168 1169
in
let text =
  let elems = elems0 in
1170
        ( elems )
1171 1172 1173 1174 1175 1176
in
    ( Documentation.(Ok {text; tags}) )}
| _1 = DOC err = doc_error _3 = CLOSE
    {    ( Documentation.Error err )}

comment:
1177
  _1 = COMMENT elems0 = list_text_element_ tags0 = list_tag_ _4 = CLOSE
1178 1179
    {let tags =
  let tags = tags0 in
1180
        ( tags )
1181 1182 1183
in
let text =
  let elems = elems0 in
1184
        ( elems )
1185 1186 1187 1188 1189 1190 1191
in
      ( Documentation.(Documentation (Ok {text; tags})) )}
| _1 = COMMENT err = doc_error _3 = CLOSE
    {      ( Documentation.(Documentation (Error err)) )}
| _1 = STOP _2 = CLOSE
    {      ( Documentation.Stop )}

1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225
poly_variant_kind:
  _1 = FIXED _2 = CLOSE
    {      ( TypeExpr.Variant.Fixed )}
| _1 = CLOSED names = list_name_ _3 = CLOSE
    {      ( TypeExpr.Variant.Closed names )}
| _1 = OPEN _2 = CLOSE
    {      ( TypeExpr.Variant.Open )}

poly_variant_element:
  _1 = TYPE expr = type_expr _3 = CLOSE
    {      ( TypeExpr.Variant.Type expr )}
| _1 = CONSTRUCTOR data = Data constant = flag_CONSTANT_ types = list_type_expr_ _5 = CLOSE
    {      ( TypeExpr.Variant.Constructor(data, constant, types) )}

poly_variant:
  kind = poly_variant_kind elements = list_poly_variant_element_
    {      ( TypeExpr.Variant.{kind; elements} )}

object_method:
  name = name type_ = type_expr
    {      ( TypeExpr.Object.{name; type_} )}

object_:
  methods = list_object_method_ open_ = flag_OPEN_
    {      ( TypeExpr.Object.{methods; open_} )}

package_substitution:
  frag = type_fragment expr = type_expr
    {      ( (frag, expr) )}

package:
  path = module_type_path substitutions = list_package_substitution_
    {      ( TypeExpr.Package.{path; substitutions} )}

1226
argument_label:
1227
  _1 = LABEL data = Data _3 = CLOSE
1228 1229 1230 1231
    {      ( TypeExpr.Label data )}
| _1 = OPTIONAL data = Data _3 = CLOSE
    {      ( TypeExpr.Optional data )}

1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255
type_expr:
  _1 = VAR data = Data _3 = CLOSE
    {      ( TypeExpr.Var data )}
| _1 = ANY _2 = CLOSE
    {      ( TypeExpr.Any )}
| _1 = ALIAS expr = type_expr data = Data _4 = CLOSE
    {      ( TypeExpr.Alias(expr, data) )}
| _1 = ARROW lbl = option_argument_label_ arg = type_expr res = type_expr _5 = CLOSE
    {      ( TypeExpr.Arrow(lbl, arg, res) )}
| _1 = TUPLE types = nonempty_list_type_expr_ _3 = CLOSE
    {      ( TypeExpr.Tuple types )}
| _1 = PATH p = type_path params = list_type_expr_ _4 = CLOSE
    {      ( TypeExpr.Constr(p, params) )}
| _1 = POLY_VARIANT v = poly_variant _3 = CLOSE
    {      ( TypeExpr.Variant v )}
| _1 = OBJECT o = object_ _3 = CLOSE
    {      ( TypeExpr.Object o )}
| _1 = CLASS p = class_type_path params = list_type_expr_ _4 = CLOSE
    {      ( TypeExpr.Class(p, params) )}
| _1 = POLY names = nonempty_list_name_ expr = type_expr _4 = CLOSE
    {      ( TypeExpr.Poly(names, expr) )}
| _1 = PACKAGE pkg = package _3 = CLOSE
    {      ( TypeExpr.Package pkg )}

1256
external_primitive:
1257
  _1 = PRIMITIVE data = Data _3 = CLOSE
1258 1259 1260
    {      ( data )}

constructor_arguments:
1261
  
1262 1263 1264 1265 1266
    {      ( [] )}
| _1 = ARGUMENTS types = list_type_expr_ _3 = CLOSE
    {      ( types )}

constructor_result:
1267
  
1268 1269 1270 1271 1272
    {      ( None )}
| _1 = RESULT type_ = type_expr _3 = CLOSE
    {      ( Some type_ )}

constructor:
1273
  _1 = CONSTRUCTOR id = constructor_identifier doc = doc args = constructor_arguments res = constructor_result _6 = CLOSE
1274 1275 1276
    {        ( TypeDecl.Constructor.{id; doc; args; res} )}

field:
1277
  _1 = FIELD id = field_identifier doc = doc mutable_ = flag_MUTABLE_ type_ = type_expr _6 = CLOSE
1278 1279
    {      ( TypeDecl.Field.{id; doc; mutable_; type_} )}

1280 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
type_representation:
  _1 = VARIANT constructors = nonempty_list_constructor_ _3 = CLOSE
    {      ( TypeDecl.Representation.Variant constructors )}
| _1 = RECORD fields = nonempty_list_field_ _3 = CLOSE
    {      ( TypeDecl.Representation.Record fields )}
| _1 = EXTENSIBLE _2 = CLOSE
    {      ( TypeDecl.Representation.Extensible )}

variance:
  _1 = POS _2 = CLOSE
    {      ( TypeDecl.Pos )}
| _1 = NEG _2 = CLOSE
    {      ( TypeDecl.Neg )}

type_parameter:
  _1 = PARAM v = option_variance_ _3 = CLOSE
    {      ( (TypeDecl.Any, v) )}
| _1 = PARAM name = Data v = option_variance_ _4 = CLOSE
    {      ( (TypeDecl.Var name, v) )}

type_subst_parameter:
  _1 = PARAM name = Data _3 = CLOSE
    {      ( name )}

type_constraint:
  _1 = CONSTRAINT expr1 = type_expr expr2 = type_expr _4 = CLOSE
    {      ( (expr1, expr2) )}

type_equation:
  params = list_type_parameter_ private_ = flag_PRIVATE_ manifest = option_type_expr_ constraints = list_type_constraint_
    {        ( let open TypeDecl.Equation in
            {params; private_; manifest; constraints} )}

1313
extension_constructor:
1314
  _1 = CONSTRUCTOR id = extension_identifier doc = doc args = constructor_arguments res = constructor_result _6 = CLOSE
1315 1316 1317
    {        ( Extension.Constructor.{id; doc; args; res} )}

class_decl:
1318
  clty = class_type_expr
1319 1320 1321 1322 1323
    {      ( Class.ClassType clty )}
| _1 = ARROW lbl = option_argument_label_ arg = type_expr res = class_decl _5 = CLOSE
    {      ( Class.Arrow(lbl, arg, res) )}

class_type_expr:
1324
  _1 = PATH p = class_type_path params = list_type_expr_ _4 = CLOSE
1325 1326 1327 1328 1329 1330
    {      ( ClassType.Constr(p, params) )}
| _1 = SIGNATURE self = option_type_expr_ items = list_class_signature_item_ _4 = CLOSE
    {      ( let sg = ClassSignature.{self; items} in
          ClassType.Signature sg )}

class_signature_item:
1331
  _1 = INSTANCE_VARIABLE id = instance_variable_identifier doc = doc mutable_ = flag_MUTABLE_ virtual_ = flag_VIRTUAL_ type_ = type_expr _7 = CLOSE
1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346
    {        ( let open ClassSignature in
          let open InstanceVariable in
            InstanceVariable {id;doc;mutable_;virtual_;type_} )}
| _1 = METHOD id = method_identifier doc = doc private_ = flag_PRIVATE_ virtual_ = flag_VIRTUAL_ type_ = type_expr _7 = CLOSE
    {        ( let open ClassSignature in
          let open Method in
            Method {id;doc;private_;virtual_;type_} )}
| _1 = CONSTRAINT expr1 = type_expr expr2 = type_expr _4 = CLOSE
    {      ( ClassSignature.Constraint(expr1, expr2) )}
| _1 = INHERIT csig = class_type_expr _3 = CLOSE
    {      ( ClassSignature.Inherit csig )}
| comment = comment
    {      ( ClassSignature.Comment comment )}

module_decl:
1347
  _1 = ALIAS p = module_path _3 = CLOSE
1348 1349 1350 1351
    {      ( Module.Alias p )}
| _1 = TYPE expr = module_type_expr _3 = CLOSE
    {      ( Module.ModuleType expr )}

1352 1353 1354 1355 1356 1357 1358 1359 1360 1361
substitution:
  _1 = MODULE frag = module_fragment eq = module_decl _4 = CLOSE
    {      ( ModuleType.ModuleEq(frag, eq) )}
| _1 = MODULE_SUBST frag = module_fragment p = module_path _4 = CLOSE
    {      ( ModuleType.ModuleSubst(frag, p) )}
| _1 = TYPE frag = type_fragment eq = type_equation _4 = CLOSE
    {      ( ModuleType.TypeEq(frag, eq) )}
| _1 = TYPE_SUBST frag = type_fragment params = list_type_subst_parameter_ p = type_path _5 = CLOSE
    {        ( ModuleType.TypeSubst(frag, params, p) )}

1362
module_argument:
1363
  _1 = Argument id = module_identifier expr = module_type_expr _4 = CLOSE
1364 1365 1366 1367 1368
    {      ( Some(id, expr) )}
| _1 = Argument _2 = CLOSE
    {      ( None )}

module_type_expr:
1369
  p = module_type_path
1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381
    {      ( ModuleType.Path p )}
| _1 = SIGNATURE sg = list_signature_item_ _3 = CLOSE
    {      ( ModuleType.Signature sg )}
| _1 = FUNCTOR args = nonempty_list_module_argument_ expr = module_type_expr _4 = CLOSE
    {      ( List.fold_right
          (fun s e -> ModuleType.Functor(s, e))
          args expr )}
| _1 = WITH expr = module_type_expr substs = nonempty_list_substitution_ _4 = CLOSE
    {      ( ModuleType.With(expr, substs) )}
| _1 = TYPEOF md = module_decl _3 = CLOSE
    {      ( ModuleType.TypeOf md )}

1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 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
signature_item:
  _1 = VALUE id = value_identifier doc = doc type_ = type_expr _5 = CLOSE
    {      ( let open Signature in
        let open Value in
          Value {id;doc;type_} )}
| _1 = EXTERNAL id = value_identifier doc = doc type_ = type_expr primitives = nonempty_list_external_primitive_ _6 = CLOSE
    {        ( let open Signature in
          let open External in
            External {id; doc; type_; primitives} )}
| _1 = TYPE id = type_identifier doc = doc equation = type_equation representation = option_type_representation_ _6 = CLOSE
    {        ( let open Signature in
          let open TypeDecl in
            Type {id; doc; equation; representation} )}
| _1 = EXTENSION type_path = type_path doc = doc type_params = list_type_parameter_ private_ = flag_PRIVATE_ constructors = nonempty_list_extension_constructor_ _7 = CLOSE
    {        ( let open Signature in
          let open Extension in
            TypExt {type_path; doc; type_params; private_; constructors} )}
| _1 = EXCEPTION id = exception_identifier doc = doc args = constructor_arguments res = constructor_result _6 = CLOSE
    {        ( let open Signature in
          let open Exception in
            Exception {id; doc; args; res} )}
| _1 = CLASS id = class_identifier doc = doc params = list_type_parameter_ virtual_ = flag_VIRTUAL_ type_ = class_decl _7 = CLOSE
    {        ( let open Signature in
          let open Class in
            Class {id; doc; virtual_; params; type_} )}
| _1 = CLASS_TYPE id = class_type_identifier doc = doc params = list_type_parameter_ virtual_ = flag_VIRTUAL_ expr = class_type_expr _7 = CLOSE
    {        ( let open Signature in
          let open ClassType in
            ClassType {id; doc; virtual_; params; expr} )}
| _1 = MODULE id = module_identifier doc = doc type_ = module_decl _5 = CLOSE
    {      ( let open Signature in
        let open Module in
           Module {id; doc; type_} )}
| _1 = MODULE_TYPE id = module_type_identifier doc = doc expr = option_module_type_expr_ _5 = CLOSE
    {      ( let open Signature in
        let open ModuleType in
          ModuleType {id; doc; expr} )}
| _1 = INCLUDE expr = module_type_expr _3 = CLOSE
    {      ( Signature.Include expr )}
| comment = comment
    {      ( Signature.Comment comment )}

digest:
  _1 = DIGEST data = Data _3 = CLOSE
    {      ( try
          Digest.from_hex data
        with Invalid_argument _ -> (raise _eRR) )}

unit_import:
  _1 = IMPORT data = Data digest = option_digest_ _4 = CLOSE
    {      ( Unit.Import.Unresolved(data, digest) )}
| _1 = IMPORT base = Base _3 = CLOSE
    {      ( Unit.Import.Resolved base )}

source_file:
  _1 = FILE data = Data _3 = CLOSE
    {      ( data )}

source_build_dir:
  _1 = DIR data = Data _3 = CLOSE
    {      ( data )}

source:
  _1 = SOURCE file = source_file build_dir = source_build_dir digest = digest _5 = CLOSE
    {      ( let open Unit.Source in
          {file; build_dir; digest} )}

packed_item:
  _1 = ITEM id = module_identifier path = module_path _4 = CLOSE
    {      ( let open Unit.Packed in
          {id; path} )}

unit_content:
  _1 = MODULE items = list_signature_item_ _3 = CLOSE
    {      ( Unit.Module items )}
| _1 = PACK items = list_packed_item_ _3 = CLOSE
    {      ( Unit.Pack items )}

unit:
  _1 = UNIT id = module_identifier doc = doc digest = digest imports = list_unit_import_ source = option_source_ interface = flag_INTERFACE_ content = unit_content _9 = CLOSE
    {          ( let open Unit in
              {id; doc; digest; imports; source; interface; content} )}

file:
  _1 = DTD unit = unit _3 = EOF
    {      ( unit )}

1469 1470 1471
%%