123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113(******************************************************************************)(* *)(* Menhir *)(* *)(* Copyright Inria. All rights reserved. This file is distributed under *)(* the terms of the GNU General Public License version 2, as described in *)(* the file LICENSE. *)(* *)(******************************************************************************)(* This module defines the data that is stored in .cmly files. In short, a
.cmly file contains a value of type [grammar], defined below. *)(* The type definitions in this module are used by [Cmly_write], which writes
a .cmly file, and by [Cmly_read], which reads a .cmly file. They should not
be used anywhere else. *)(* All entities (terminal symbols, nonterminal symbols, and so on) are
represented as integers. These integers serve as indices into arrays. This
enables simple and efficient hashing, comparison, indexing, etc. *)typeterminal=inttypenonterminal=inttypeproduction=inttypelr0=inttypelr1=inttypeocamltype=stringtypeocamlexpr=stringtyperange={r_start:Lexing.position;r_end:Lexing.position;}typeattribute={a_label:string;a_payload:string;a_position:range;}typeattributes=attributelisttypeterminal_def={t_name:string;t_kind:[`REGULAR|`ERROR|`EOF|`PSEUDO];t_type:ocamltypeoption;t_attributes:attributes;}typenonterminal_def={n_name:string;n_kind:[`REGULAR|`START];n_mangled_name:string;n_type:ocamltypeoption;n_positions:rangelist;n_nullable:bool;n_first:terminallist;n_attributes:attributes;}typesymbol=|Tofterminal|Nofnonterminaltypeidentifier=stringtypeaction={a_expr:ocamlexpr;a_keywords:Keyword.keywordlist;}typeproducer_def=symbol*identifier*attributestypeproduction_def={p_kind:[`REGULAR|`START];p_lhs:nonterminal;p_rhs:producer_defarray;p_positions:rangelist;p_action:actionoption;p_attributes:attributes;(* Before 2023/08/02, these were the attributes of the left-hand
side of the production. Now, these are the attributes of the
production itself. *)}typelr0_state_def={lr0_incoming:symboloption;lr0_items:(production*int)list;}typelr1_state_def={lr1_lr0:lr0;lr1_transitions:(symbol*lr1)list;lr1_reductions:(terminal*production)list;lr1_default_reduction:productionoption;}typegrammar={g_basename:string;g_preludes:stringlist;g_postludes:stringlist;g_terminals:terminal_defarray;g_nonterminals:nonterminal_defarray;g_productions:production_defarray;g_lr0_states:lr0_state_defarray;g_lr1_states:lr1_state_defarray;g_entry_points:(nonterminal*production*lr1)list;g_attributes:attributes;g_parameters:stringlist;}