123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990(*
A parse error is either a list of syntax error or on semantic error.
We need a list of syntax errors for the following reason:
A syntax error signifies that something has been expected and has not been
encountered. Since we have alternatives which can all fail without consuming
tokens we can have a list of failed expectations.
*)openFmlib_stdopenInterfacesmoduleMake(Expect:ANY)(Semantic:ANY)=structtypet=|SyntaxofExpect.tlist|SemanticofSemantic.tletto_string(e:t)(f:Expect.t->string)(g:Semantic.t->string):string=matchewith|Syntaxlst->"["^String.concat", "(List.rev_mapflst)^"]"|Semanticsem->gsemletinit:t=Syntax[]letclear_last(e:t):t=matchewith|Syntax(_::tail)->Syntaxtail|_->eletadd_expected(exp:Expect.t)(e:t):t=matchewith|Syntaxlst->Syntax(exp::lst)|_->Syntax[exp]letmake_semantic(sem:Semantic.t):t=Semanticsemletmake_expectations(lst:Expect.tlist):t=Syntax(List.revlst)letis_semantic(e:t):bool=matchewith|Syntax_->false|_->trueletis_syntax(e:t):bool=not(is_semantice)letsemantic(e:t):Semantic.t=matchewith|Syntax_->assertfalse(* Illegal call! *)|Semanticsem->semletexpectations(e:t):Expect.tlist=matchewith|Syntaxes->List.reves|Semantic_->assertfalse(* Illegal call! *)end