123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175(* Yoann Padioleau
*
* Copyright (C) 2019 Yoann Padioleau
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation, with the
* special exception on linking described in file license.txt.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the file
* license.txt for more details.
*)openParser_skipmodulePI=Parse_info(*****************************************************************************)(* Token Helpers *)(*****************************************************************************)letis_eof=function|EOF_->true|_->falseletis_comment=function|TComment_|TCommentSpace_|TCommentNewline_->true|_->falselettoken_kind_of_tokt=matchtwith|TOBrace_->PI.LBrace|TCBrace_->PI.RBrace|TOParen_->PI.LPar|TCParen_->PI.RPar(* less: also TOBracket? (and TOBracketAt...) *)|TComment_->PI.EsthetPI.Comment|TCommentSpace_->PI.EsthetPI.Space|TCommentNewline_->PI.EsthetPI.Newline|_->PI.Other(*****************************************************************************)(* Visitors *)(*****************************************************************************)letvisitor_info_of_tokf=function|TCommentSpaceii->TCommentSpace(fii)|TCommentNewlineii->TCommentNewline(fii)|TCommentii->TComment(fii)|TUnknownii->TUnknown(fii)|EOF(ii)->EOF(fii)|TQuestionii->TQuestion(fii)|TAtii->TAt(fii)|TSharpii->TSharp(fii)|TDollarii->TDollar(fii)|TBackquoteii->TBackquote(fii)|Tforii->Tfor(fii)|Tinii->Tin(fii)|Textensionii->Textension(fii)|Tyieldii->Tyield(fii)|Tbreakii->Tbreak(fii)|Tcontinueii->Tcontinue(fii)|Tmemoizedii->Tmemoized(fii)|Tfrozenii->Tfrozen(fii)|Tdoii->Tdo(fii)|Twhileii->Twhile(fii)|Tloopii->Tloop(fii)|TEqDotii->TEqDot(fii)|TTildeArrowii->TTildeArrow(fii)|TEqualArrowii->TEqualArrow(fii)|TDivii->TDiv(fii)|TModii->TMod(fii)|TEqEqii->TEqEq(fii)|TLessEqii->TLessEq(fii)|TGreaterEqii->TGreaterEq(fii)|THatii->THat(fii)|TPipePipeii->TPipePipe(fii)|TInt(s,ii)->TInt(s,fii)|TFloat(s,ii)->TFloat(s,fii)|TChar(s,ii)->TChar(s,fii)|TString(s,ii)->TString(s,fii)|TLowerIdent(s,ii)->TLowerIdent(s,fii)|TUpperIdent(s,ii)->TUpperIdent(s,fii)|Toverridableii->Toverridable(fii)|Treadonlyii->Treadonly(fii)|Tmacroii->Tmacro(fii)|Taliasii->Talias(fii)|Tasii->Tas(fii)|Tasyncii->Tasync(fii)|Tawaitii->Tawait(fii)|Tcatchii->Tcatch(fii)|Tchildrenii->Tchildren(fii)|Tclassii->Tclass(fii)|Tconstii->Tconst(fii)|Telseii->Telse(fii)|Textendsii->Textends(fii)|Tfinalii->Tfinal(fii)|Tfromii->Tfrom(fii)|Tfunii->Tfun(fii)|Tifii->Tif(fii)|Tmatchii->Tmatch(fii)|Tmoduleii->Tmodule(fii)|Tmutableii->Tmutable(fii)|Tnativeii->Tnative(fii)|Tprivateii->Tprivate(fii)|Tprotectedii->Tprotected(fii)|Tusesii->Tuses(fii)|Tstaticii->Tstatic(fii)|Tthisii->Tthis(fii)|Tthrowii->Tthrow(fii)|Ttraitii->Ttrait(fii)|Ttryii->Ttry(fii)|Ttypeii->Ttype(fii)|Tvoidii->Tvoid(fii)|Twatchii->Twatch(fii)|Twhenii->Twhen(fii)|Twithii->Twith(fii)|Tbaseii->Tbase(fii)|Tcaptureii->Tcapture(fii)|Tdefaultii->Tdefault(fii)|Tdeferredii->Tdeferred(fii)|Tinstii->Tinst(fii)|TnonNullableii->TnonNullable(fii)|Tuntrackedii->Tuntracked(fii)|Tvalueii->Tvalue(fii)|Ttrueii->Ttrue(fii)|Tfalseii->Tfalse(fii)|TOParen(ii)->TOParen(fii)|TCParen(ii)->TCParen(fii)|TOBrace(ii)->TOBrace(fii)|TCBrace(ii)->TCBrace(fii)|TOBracket(ii)->TOBracket(fii)|TCBracket(ii)->TCBracket(fii)|TLess(ii)->TLess(fii)|TGreater(ii)->TGreater(fii)|TDot(ii)->TDot(fii)|TComma(ii)->TComma(fii)|TEq(ii)->TEq(fii)|TColon(ii)->TColon(fii)|TColonColon(ii)->TColonColon(fii)|TBang(ii)->TBang(fii)|TBangEq(ii)->TBangEq(fii)|TPipe(ii)->TPipe(fii)|TSemiColon(ii)->TSemiColon(fii)|TSemiColonSemiColon(ii)->TSemiColonSemiColon(fii)|TStar(ii)->TStar(fii)|TArrow(ii)->TArrow(fii)|TAnd(ii)->TAnd(fii)|TAndAnd(ii)->TAndAnd(fii)|TPlus(ii)->TPlus(fii)|TMinus(ii)->TMinus(fii)letinfo_of_toktok=letres=refNoneinvisitor_info_of_tok(funii->res:=Someii;ii)tok|>ignore;Common2.some!res