MODULE ObliqBdl;
Generated by m3bundle; see its manpage.
IMPORT Bundle, BundleRep, Text;
IMPORT Thread, Wr, TextWr;
TYPE T = Bundle.T OBJECT OVERRIDES
get := LookUp;
getNames := GetNames;
END;
TYPE Texts = REF ARRAY OF TEXT;
VAR
bundle: T := NIL;
names : Texts := NIL;
PROCEDURE Get(): Bundle.T =
BEGIN
IF (bundle = NIL) THEN bundle := NEW (T) END;
RETURN bundle;
END Get;
PROCEDURE GetNames (<*UNUSED*> self: T): Texts =
BEGIN
IF names = NIL THEN
names := NEW (Texts, NUMBER (Names));
names^ := Names;
END;
RETURN names;
END GetNames;
PROCEDURE LookUp (<*UNUSED*> self: T; element: TEXT): TEXT =
BEGIN
FOR i := 0 TO LAST (Names)-1 DO
IF Text.Equal (Names[i], element) THEN
IF Elements[i] = NIL THEN Elements[i] := GetElt (i) END;
RETURN Elements[i];
END;
END;
RETURN NIL;
END LookUp;
CONST Names = ARRAY [0..1] OF TEXT {
"ObliqGram",
NIL
};
VAR Elements := ARRAY [0..1] OF TEXT {
NIL (* E0 .. E0_5 *),
NIL
};
PROCEDURE GetElt (n: INTEGER): TEXT =
<*FATAL Thread.Alerted, Wr.Failure *>
VAR wr := TextWr.New ();
BEGIN
CASE n OF
| 0 =>
Wr.PutText (wr, E0);
Wr.PutText (wr, E0_0);
Wr.PutText (wr, E0_1);
Wr.PutText (wr, E0_2);
Wr.PutText (wr, E0_3);
Wr.PutText (wr, E0_4);
Wr.PutText (wr, E0_5);
ELSE (*skip*)
END;
RETURN TextWr.ToText (wr);
END GetElt;
CONST E0 =
"(* <pre> *)\n(* METASYNTAX (Parsing is LL(1) recursive descent).\n "
& " Non-terminals are declared by \'::=\' and must be non-left-recursive.\n"
& " Terminals are in double quotes \'\"\'\n \'{ g1 .. gn }\' is a "
& "(sequential) choice of grammars gi.\n \'[ g1 .. gn ]\' is a sequenc"
& "e of grammars gi.\n \'(g1 * g2)\' is \'[g1 g]\' where \'g::={[g2 g]"
& "[]}\', but left-associative\n \'_n\' and \'::\' are used for abstra"
& "ct-syntax-tree generation.\n*)\n\nphrase ::=\n { phraseEmpty\n phra"
& "seHelp\n phraseFlag\n phraseFrame\n phraseType\n phraseTerm"
& "\n phraseEOF\n }\n\nphraseEmpty ::=\n \";\" \t\t\t\t\t\t:: BuildPh"
& "raseEmpty\n\nphraseEOF ::=\n EOF \t\t\t\t\t\t:: BuildPhraseEmpty\n\nph"
& "raseHelp ::=\n [ \"~help\" \n { name string [] }_1\n { name stri"
& "ng [] }_2\n \";\"\n ] :"
& ": BuildPhraseHelp\n\nphraseFlag ::=\n [ \"~flag\" \n { name string "
& "[] }_1\n { name string [] }_2\n \";\"\n ] "
& " :: BuildPhraseFlag\n\nphraseType ::=\n [ typDecl"
& " \";\" ] :: BuildPhraseEmpty\n\nphraseFrame ::=\n { phraseLoad\n ph"
& "raseImport\n phraseModule\n phraseAddHelp\n phraseEndModule\n "
& " phraseEstablish\n phraseDelete\n phraseSave\n phraseQualify"
& "\n phraseQuit\n }\n\nphraseQuit ::=\n [ \"~quit\" \";\" ]\t\t\t\t:"
& ": BuildPhraseQuit\n\nphraseLoad ::=\n [ \"load\" \n { name_1\t\t\t\t"
& "\t:: BuildPhraseLoadName\n string_1 \t\t\t\t\t:: BuildPhraseLoadSt"
& "ring\n }_2\n \";\" \n ]\t\t\t\t\t\t:: Select2\n\nphraseImport ::"
& "=\n [ \"import\" name_1 \";\" ]\t\t\t:: BuildPhraseImport\n\nphraseEst"
& "ablish ::=\n [ \"~establish\" name_1\n { [ \"for\" name_2 ]\t "
& " \t:: Select2\n []\n }_3\n \";\" \n ]\t\t "
& " :: BuildPhraseEstablish\n\nphraseSave ::=\n [ \""
& "~save\" name_1 \";\" ]\t :: BuildPhraseSave\n\nphraseDel"
& "ete ::=\n [ \"~delete\" name_1 \";\" ]\t \t:: BuildPhraseDelete"
& "\n\nphraseQualify ::=\n [ \"~qualify\" \n { [ \"exporting\" import"
& "List_1 ]\t\t:: Select1\n []\n }_2 \";\" ]\t\t "
& " :: BuildPhraseQualify\n\nphraseModule ::=\n [ \"module\" \n ";
CONST E0_0 =
"name_1\n { [ \"for\" name_2 ] :: Select2\n "
& " []\n }_3\n { [ \"import\" importList_4 ] \t::"
& " Select4\n []\n }_5\n { [ \"export\" exportList ] [] }\n "
& "\";\" \n ]\t\t\t \t:: BuildPhraseModule\n\nphraseAddHel"
& "p ::= \n [ \"addhelp\" name_1 \n { [ \"sort\" string_2 ] "
& " :: Select2\n []\n }_3\n { [ \"short\" string_4 ]"
& " :: Select4\n []\n }_5\n string_6 \";\""
& " ] \t\t\t:: BuildPhraseAddHelp\n\nphraseEndModule ::=\n [ \"end\""
& " \"module\" \n { [ \"exporting\" importList_1 ]\t\t:: Select1\n "
& " []\n }_2 \";\" ]\t\t :: BuildPhraseEndModule"
& "\n\nimportList ::=\n { [ name_1 \n\t{ [ \",\" importList_2 ]\t\t\t:: B"
& "uildImportList\n\t []\t\t\t\t\t:: BuildImportListSingle\n\t}_3\n ] "
& " \t\t\t\t\t:: Select3 \n []\t\t\t\t\t\t:: BuildImp"
& "ortListNil\n }\n\nphraseTerm ::=\n [ term_1 \n { [ \"!\"\n "
& " { int_2\t\t\t\t:: BuildPhraseTermDepth\n\t [] \t\t\t\t\t:: Build"
& "PhraseTermDeep\n }_3\n\t]\t\t\t\t\t:: Select3\n\t[]\t\t\t\t\t:"
& ": BuildPhraseTerm\n }_4\n \";\"\n ]\t\t\t\t\t\t:: Select4\n\nt"
& "ypDecl ::=\n [ \"type\" ide { typParams [] } \"=\" typ ]\n\ntyp ::=\n "
& " { [ \"(\" typList \")\" { typRngSpec [] } ]\n [ \"Option\" typField"
& "s \"end\" ]\n [ \"{\" typFields \"}\" ]\n [ \"[\" { [ int \"~*\" "
& "] [] } typ \"]\" ]\n [ \"All\" \"(\" ide { typBound [] } \")\" typ ]"
& "\n [ \"Some\" \"(\" ide { typBound [] } \")\" typ ]\n [ \"Self\" "
& "\"(\" ide \")\" typ ]\n [ ide \n { [ \"_\" name { typParams ["
& "] } ]\n typParams\n []\n }\n ]\n }\n\ntypB"
& "ound ::= \n [ \"<:\" typ ]\n\ntypParams ::=\n [ \"(\" typNameList \")"
& "\" ]\n\ntypNameList ::=\n { [ ide { [ \",\" typList ] [] } ]\n []\n"
& " }\n\ntypList ::=\n { [ typ { [ \",\" typList ] [] } ]\n []\n }\n"
& "\ntypFields ::=\n { [ ide \":\" typ\n { [ \",\" typFields ]\n\t[]"
& "\n }\n ]\n []\n }\n\ntypSpec ::=\n { [ \":\" typ ] [] }\n\n"
& "typResSpec ::=\n { [ \":\" typ { [ \"!\" excList ] [] } ] \n [ \"!\""
& " excList ]\n }\n\ntypRngSpec ::=\n { [ \"->\" typ { [ \"!\" excList ]"
& " [] } ] \n [ \"=>\" typ { [ \"!\" excList ] [] } ] \n [ \"!\"";
CONST E0_1 =
" excList ]\n }\n\nexcList ::=\n { [ ide { [ \"_\" name ] [] } excList"
& " ] [] }\n\nprocDecl ::=\n {\n [ { \"All\" \"Some\" } \"(\" ide { ty"
& "pBound [] } \")\" procDecl ]\n [ ide \n { [ \":\" typ ]\n "
& " [ \"(\" ideList \")\" typResSpec ]\n []\n }\n ]\n }\n"
& " \nexportList ::=\n { [ typDecl { [ \",\" exportList ] [] } ]\n [ "
& "procDecl { [ \",\" exportList ] [] } ]\n []\n }\n\ntermBinding ::=\n"
& " { [ ide_1 typSpec \"=\" term_2 \n { [ \",\" termBinding_3 ] \t\t"
& "\t:: BuildTermBinding\n []\t\t\t\t\t:: BuildTermBindingSingle\n "
& " }_4\n ]\t\t\t\t\t\t:: Select4\n []\t\t\t\t\t\t:: BuildTermBi"
& "ndingNil\n }\n\ntermSeq ::=\n [ term_1\n { [ \";\" \n\t{ termSeq_2"
& "\t\t\t\t:: BuildTermSeq\n\t []\t\t\t\t\t:: Select1\n\t}_3\n ]\t\t"
& "\t\t\t\t:: Select3\n []\t\t\t\t\t:: Select1\n }_4\n ]\t\t\t\t\t"
& "\t:: Select4\n\ntermSeqOpt ::=\n { termSeq\n [] "
& " :: BuildTermOk\n }\n\nterm ::=\n ( termBase *_1"
& "\n { [ \"(\" termList_2 \")\" ]\t\t\t:: BuildTermAppl\n [ \"_\""
& " name_2 \n { [ \"(\" termList_3 \")\" ]\t\t:: BuildTermOp\n "
& " []\t\t\t\t\t:: BuildTermOpConst\n }_4\n ]\t\t\t\t\t\t:"
& ": Select4\n [ \".\" name_2 \n { [ \":=\" termOrAlias_3 ]\t\t"
& ":: BuildTermUpdate\n [ \"(\" termList_3 \")\" ] "
& " :: BuildTermInvoke\n []\t\t\t\t\t:: BuildTermSelect\n "
& "}_4\n ]\t\t\t\t\t\t:: Select4\n [ \":=\" term_2 ] "
& " :: BuildTermAssign\n [ \"[\" term_2 \n { [ \""
& "]\"\n { [ \":=\" term_3 ]\t\t\t:: BuildTermArraySet\n "
& " []\t\t\t\t:: BuildTermArrayGet\n }_4\n ]\t\t"
& "\t\t\t:: Select4\n [ \"for\" term_3 \"]\"\n { [ \":"
& "=\" term_4 ]\t\t\t:: BuildTermArrayUpd\n []\t\t\t\t:: Buil"
& "dTermArraySub\n }_5\n ]\t\t\t\t\t:: Select5\n "
& " }_6\n ]\t\t\t\t\t\t:: Select6\n [ ide_2 term_3 ]\t\t\t\t:: "
& "BuildTermInfix\n [ \"andif\" term_2 ]\t\t\t:: BuildTermAndif\n "
& " [ \"orif\" term_2 ]\t\t\t\t:: BuildTermOrif\n }\n )\n\ntermBase :"
& ":=\n { \n termMinus\n termIde\n termConst\n termArray\n "
& " termObj\n termOption\n termClone\n termNotify\n termPic";
CONST E0_2 =
"kler\n termReplicate\n termRemote\n termSimple\n termDelega"
& "te\n termRedirect\n termProc\n termMeth\n termUpdateMeth\n "
& " termPar\n termLet\n termVar\n termIf\n termCase\n ter"
& "mLoop\n termExit\n termFor\n termForeach\n termException\n "
& " termRaise\n termTry\n termLock\n termWatch\n termAll\n "
& " termSome\n termSelf\n }\n\ntermIde ::=\n ide_1 \t\t\t\t\t:: Buil"
& "dTermIde\n\ntermConst ::=\n { \"ok\" "
& " :: BuildTermOk\n \"true\" "
& " :: BuildTermBoolTrue\n \"false\" "
& " :: BuildTermBoolFalse\n char_1 "
& " :: BuildTermChar\n string_1 :: "
& "BuildTermString\n int_1 :: Bui"
& "ldTermInt\n real_1 :: BuildTerm"
& "Real\n }\n\ntermMinus ::=\n [ \"~-\" term_1 ] "
& " :: BuildTermMinus\n\ntermArray ::=\n [ \"[\" termList_1 \"]\" ]"
& "\t\t\t:: BuildTermArray\n\ntermObj ::=\n [ \"{\" termObjProtected_1 te"
& "rmObjSerialized_2 \n\ttermObjReplicated_3 termObjSimple_4\n termObjF"
& "ields_5 \"}\" ] \t:: BuildTermObj\n\ntermObjProtected :"
& ":=\n { [ \"protected\" { \",\" [] } ] \t\t :: BuildOptionYes\n "
& " []\t\t\t\t\t\t:: BuildOptionNo\n }\n \ntermObjSerialized ::=\n { "
& "[ \"serialized\" { \",\" [] } ] \t :: BuildOptionYes\n []\t\t"
& "\t\t\t\t:: BuildOptionNo\n }\n\ntermObjReplicated ::=\n { [ \"replica"
& "ted\" { \",\" [] } ] \t :: BuildOptionYes\n []\t\t\t\t\t\t:: "
& "BuildOptionNo\n }\n\ntermObjSimple ::=\n { [ \"simple\" { \",\" [] } "
& "] \t \t:: BuildOptionYes\n []\t\t\t\t\t\t:: BuildOptionNo\n "
& " }\n\ntermOption ::=\n [ \"option\" name_1 typSpec \"=>\" termSeqOpt_2"
& " \"end\" ]\t:: BuildTermOption\n\ntermOrAlias ::=\n { term\n [ \"al"
& "ias\" ide_1 \"of\" termSeq_2 \"end\" ] :: BuildTermAlias\n }\n\nt"
& "ermObjFields ::=\n { [ name_1 typSpec \"=>\" termOrAlias_2 \n { ["
& " \",\" termObjFields_3 ]\t\t\t:: BuildTermObjField\n\t[]\t\t\t\t\t:: Bu"
& "ildTermObjFieldSingle\n }_4\n ]\t\t\t\t\t\t:: Selec";
CONST E0_3 =
"t4\n []\t\t\t\t\t\t:: BuildTermObjFieldNil\n }\n\ntermClone ::=\n "
& "[ \"clone\" \"(\" termList_1 \")\" ]\t\t:: BuildTermClone\n\ntermNotify"
& " ::=\n [ \"notify\" term_1 \"with\" term_2 ]\t\t:: BuildTermNotify\n\n"
& "termPickler ::=\n [ \"setpickler\" \"(\" term_1 \",\" term_2 \",\" ter"
& "m_3 \")\" ]\t:: BuildTermPickler\n\ntermReplicate ::=\n [ \"replicate\""
& " \"(\" termList_1 \")\" ]\t\t:: BuildTermReplicate\n\ntermSimple ::=\n "
& " [ \"simple\" \"(\" term_1 \")\" ]\t\t\t:: BuildTermSimple\n\ntermRemot"
& "e ::=\n [ \"remote\" \"(\" term_1 \")\" ]\t\t\t:: BuildTermRemote\n\nt"
& "ermDelegate ::= (* OBSOLETE *)\n [ \"delegate\" termSeq_1 \"to\" termS"
& "eq_2 \"end\" ]\t:: BuildTermRedirect\n\ntermRedirect ::=\n [ \"redirec"
& "t\" termSeq_1 \"to\" termSeq_2 \"end\" ]\t:: BuildTermRedirect\n\ntermP"
& "roc ::=\n [ \"proc\" \"(\" ideList_1 \")\" { [ typResSpec \",\" ] [] }"
& " termSeqOpt_2 \"end\" ]\n\t\t\t\t\t \t:: BuildTermProc\n\ntermMeth ::=\n"
& " [ \"meth\" \"(\" ideList_1 \")\" { [ typResSpec \",\" ] [] } termSeqO"
& "pt_2 \"end\" ]\n\t\t\t\t\t\t:: BuildTermMeth\ntermUpdateMeth ::=\n [ \""
& "umeth\" \"(\" ideList_1 \")\" { [ typResSpec \",\" ] [] } termSeqOpt_2 "
& "\"end\" ]\n\t\t\t\t\t\t:: BuildTermUpdateMeth\ntermPar ::=\n [ \"(\" t"
& "ermSeqOpt_1 \")\" ]\t\t\t:: Select1\n\ntermLet ::=\n [ \"let\"\n { "
& "[ \"rec\" termBinding_1 ] :: BuildTermLetRec\n t"
& "ermBinding_1 :: BuildTermLet\n }_2\n ] "
& " :: Select2 "
& " \n\ntermVar ::=\n [ \"var\"\n { [ \"rec\" termBinding_1 ] "
& " :: BuildTermVarRec\n termBinding_1 "
& " :: BuildTermVar\n }_2\n ] "
& " :: Select2 \n\ntermIf ::=\n [ \"if\" te"
& "rmSeq_1 \"then\" termSeqOpt_2 termElsif_3 ]\n\t\t\t\t\t\t:: BuildTermIf"
& "\ntermElsif ::=\n { [ \"end\" ]\t\t\t\t\t:: BuildTermIfEnd\n [ \"el"
& "se\" termSeqOpt_1 \"end\" ]\t\t\t:: Select1\n [ \"elsif\" termSeq_1 "
& "\"then\" termSeqOpt_2 termElsif_3 ]\n\t\t\t\t\t\t:: BuildTermIf\n }\n\n"
& "termCase ::=\n [ \"case\" termSeq_1 \n \"of\" termCaseList_2 ]\t\t\t"
& ":: BuildTermCase\n\ntermLoop ::=\n [ \"loop\" termSeqOpt_1 \"end\" ]\t"
& "\t\t:: BuildTermLoop\n\ntermExit ::=\n \"exit\"\t\t\t";
CONST E0_4 =
"\t\t:: BuildTermExit\n\ntermFor ::=\n [ \"for\" ide_1 typSpec \"=\" te"
& "rm_2 \"to\" term_3 \"do\" termSeqOpt_4 \"end\" ]\n\t\t\t\t\t\t:: BuildT"
& "ermFor\n\ntermForeach ::=\n [ \"foreach\" ide_1 typSpec \"in\" term_2 "
& "\n { [ \"do\" termSeqOpt_3 ]\t\t\t:: BuildTermForeachDo\n [ \"m"
& "ap\" termSeqOpt_3 ]\t\t\t:: BuildTermForeachMap\n }_4\n \"end\" \n"
& " ]\t\t\t\t\t\t:: Select4\n\t\t\t\t\t\t\ntermException ::=\n [ \"excep"
& "tion\"\t\"(\" term_1 \")\" ]\t\t:: BuildTermException\n\ntermRaise ::=\n"
& " [ \"raise\" \"(\" term_1 \")\" ] :: BuildTermRaise"
& "\n\ntermTry ::=\n [ \"try\" termSeqOpt_1 \n { [ \"except\" termTryL"
& "ist_2 \"end\" ] \t\t:: BuildTermTry\n [ \"else\" termSeqOpt_2 \"en"
& "d\" ] \t\t:: BuildTermTryElse\n [ \"finally\" termSeqOpt_2 \"end\""
& " ]\t\t:: BuildTermTryFinally\n }_3\n ]\t\t\t\t\t\t:: Select3\n\nter"
& "mList ::=\n { [ term_1 \n { [ \",\" termList_2 ]\t\t\t:: BuildTer"
& "mListCons\n\t[]\t\t\t\t\t:: BuildTermListSingle\n }_3\n ]\t\t\t"
& "\t\t\t:: Select3\n []\t\t\t\t\t\t:: BuildTermListNil\n }\n\ntermLoc"
& "k ::=\n [ \"lock\" termSeq_1 \"do\" termSeqOpt_2 \"end\" ] :: BuildTe"
& "rmLock\n\ntermWatch ::=\n [ \"watch\" termSeq_1 \"until\" termSeq_2 \""
& "end\" ] :: BuildTermWatch\n\nideList ::=\n { [ ide_1 typSpec\n { "
& "[ \",\" ideList_2 ]\t\t\t:: BuildIdeListCons\n\t[]\t\t\t\t\t:: BuildIde"
& "ListSingle\n }_3\n ]\t\t\t\t\t\t:: Select3\n []\t\t\t\t\t\t:"
& ": BuildIdeListNil\n }\n\ntermCaseListEnd ::=\n { \"end\"\t\t\t\t\t:: "
& "BuildCaseListNil\n [ \"else\" termSeqOpt_1 \"end\" ]\t :: Bui"
& "ldCaseListElse\n }\n\ntermCaseList ::=\n { termCaseListEnd\n [ nam"
& "e_1 \n { [ \"(\" ide_2 typSpec \")\" \"=>\" termSeqOpt_3\n "
& " { [ \",\" termCaseList_4 ]\t\t:: BuildCaseListCons\n\t termCaseLis"
& "tEnd_4 \t\t:: BuildCaseListCons\n }_5\n ]\t\t\t"
& "\t\t:: Select5\n [ \"=>\" termSeqOpt_3\n { [ \",\" term"
& "CaseList_4 ]\t\t:: BuildCaseListCons\n\t termCaseListEnd_4 \t"
& "\t:: BuildCaseListCons\n }_5\n ]\t\t\t\t\t:: Select5\n "
& " }_6\n ]\t\t\t\t\t\t:: Select6\n }\n\ntermTryList ::=\n { [ \""
& "else\" termSeqOpt_1 ] :: BuildTryListElse\n [ te"
& "rm_1 \"=>\" termSeqOpt_2 \n { [ \",\" termTryList_3 ]\t\t\t:: Buil"
& "dTryLi";
CONST E0_5 =
"stCons\n\t[ \"else\" termSeqOpt_3 ]\t\t\t:: BuildTryListConsElse\n\t[]\t"
& "\t\t\t\t:: BuildTryListSingle\n }_4\n ]\t\t\t\t\t\t:: Select4\n"
& " []\t\t\t\t\t\t:: BuildTryListNil\n }\n\ntermAll ::=\n [ \"All\""
& " \"(\" ide { typBound [] } \")\" term_1 ] :: Select1\n\ntermSome ::="
& "\n [ \"Some\" \"(\" ide { typBound [] } \")\" term_1 ] :: Select1"
& "\n\ntermSelf ::=\n [ \"Self\" \"(\" ide \")\" term_1 ] :: Select1"
& "\n\n(* </pre> *)\n";
BEGIN
END ObliqBdl.