12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576(**************************************************************************)(* Copyright (C) 2017-2023 Yann Régis-Gianas, Nicolas Jeannerod, *)(* Ralf Treinen. *)(* *)(* This is free software: you can redistribute it and/or modify it *)(* under the terms of the GNU General Public License, version 3. *)(* *)(* Additional terms apply, due to the reproduction of portions of *)(* the POSIX standard. Please refer to the file COPYING for details. *)(**************************************************************************)openParser.MenhirInterpreteropenMenhirLib.Generalletcurrent_itemsparsing_state=matchLazy.force(stackparsing_state)with|Nil->[]|Cons(Element(s,_,_,_),_)->itemsstype'astatus=|AcceptedNowof'a|Fine|Wrongletrecclosecheckpoint=matchcheckpointwith|AboutToReduce(_,_)|Shifting_->close(resumecheckpoint)|Rejected|HandlingError_->Wrong|Acceptedx->AcceptedNowx|InputNeeded_->Fineletaccepted_tokencheckpointtoken=matchcheckpointwith|InputNeeded_->close(offercheckpointtoken)|_->Wrongletis_accepted_tokencheckpointtoken=accepted_tokencheckpointtoken<>Wrongletaccepted_raw_tokencheckpointraw_token=accepted_tokencheckpoint(raw_token,Lexing.dummy_pos,Lexing.dummy_pos)(** [finished checkpoint] is [true] if the current [checkpoint] can
move the LR(1) automaton to an accepting state with no extra
input.
*)letrecfinished=function|Accepted_->true|(AboutToReduce(_,_)|Shifting(_,_,_))ascheckpoint->finished(resumecheckpoint)|_->false(** [nonterminal_production p] returns the non terminal of [p].
The nonterminals of Menhir API are a too precisely typed for
our needs. Hence, we introduce an extential type for weaken
this precision. *)typenonterminal=AnyN:'aParser.MenhirInterpreter.nonterminal->nonterminalletnonterminal_of_productionp=matchlhspwith|X(Nnt)->AnyNnt|_->assertfalse(* Because every production as a nonterminal. *)exceptionEmptyStacktype'btop_symbol_processor={perform:'a.'asymbol*'a->'b}leton_top_symbolenvf=matchtopenvwith|Some(Element(state,v,_,_))->f.perform(incoming_symbolstate,v)|_->raiseEmptyStack