MODULE ObliqBdl;
Generated by m3bundle; see its manpage.
IMPORT Bundle, BundleRep, Text;
IMPORT Thread, Wr, TextWr;
TYPE T = Bundle.T OBJECT OVERRIDES get := LookUp END;
VAR bundle: T := NIL;
PROCEDURE Get(): Bundle.T =
BEGIN
IF (bundle = NIL) THEN bundle := NEW (T) END;
RETURN bundle;
END Get;
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_4 *),
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);
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 \";\" \011\011\011\011\011\011"
& ":: BuildPhraseEmpty\n\nphraseEOF ::=\n EOF \011\011\011\011\011\011:: "
& "BuildPhraseEmpty\n\nphraseHelp ::=\n [ \"~help\" \n { name string ["
& "] }_1\n { name string [] }_2\n \";\"\n ] "
& " :: BuildPhraseHelp\n\nphraseFlag ::=\n [ \"~flag\""
& " \n { name string [] }_1\n { name string [] }_2\n \";\"\n ] "
& " :: BuildPhraseFlag\n\nphrase"
& "Type ::=\n [ typDecl \";\" ] :: BuildPhraseEmpty\n\nphraseFrame ::=\n "
& " { phraseLoad\n phraseImport\n phraseModule\n phraseEndModule\n"
& " phraseEstablish\n phraseDelete\n phraseSave\n phraseQualif"
& "y\n phraseQuit\n }\n\nphraseQuit ::=\n [ \"~quit\" \";\" ]\011\011"
& "\011\011:: BuildPhraseQuit\n\nphraseLoad ::=\n [ \"load\" \n { name"
& "_1\011\011\011\011\011:: BuildPhraseLoadName\n string_1 \011\011\011"
& "\011\011:: BuildPhraseLoadString\n }_2\n \";\" \n ]\011\011\011\011"
& "\011\011:: Select2\n\nphraseImport ::=\n [ \"import\" name_1 \";\" ]\011"
& "\011\011:: BuildPhraseImport\n\nphraseEstablish ::=\n [ \"~establish\""
& " name_1\n { [ \"for\" name_2 ]\011 \011:: Select2\n "
& " []\n }_3\n \";\" \n ]\011\011 "
& " :: BuildPhraseEstablish\n\nphraseSave ::=\n [ \"~save\" name_1 \";\" "
& "]\011 :: BuildPhraseSave\n\nphraseDelete ::=\n [ \"~del"
& "ete\" name_1 \";\" ]\011 \011:: BuildPhraseDelete\n\nphraseQuali"
& "fy ::=\n [ \"~qualify\" \";\" ] :: BuildPhr"
& "aseQualify\n\nphraseModule ::=\n [ \"module\" \n name_1\n { [ \""
& "for\" name_2 ] :: Select2\n []\n }_3";
CONST E0_0 =
"\n { [ \"import\" importList_4 ] \011:: Select4\n "
& " []\n }_5\n { [ \"export\" exportList ] [] }\n \";\" \n ]\011"
& "\011\011 \011:: BuildPhraseModule\n\nphraseEndModule ::="
& "\n [ \"end\" \"module\" \";\" ] :: BuildPhraseE"
& "ndModule\n\nimportList ::=\n { [ name_1 \n\011{ [ \",\" importList_2 ]"
& "\011\011\011:: BuildImportList\n\011 []\011\011\011\011\011:: BuildImp"
& "ortListSingle\n\011}_3\n ] \011\011\011\011\011:: Select3 "
& " \n []\011\011\011\011\011\011:: BuildImportListNil\n }\n\n"
& "phraseTerm ::=\n [ term_1 \n { [ \"!\"\n { int_2\011\011"
& "\011\011:: BuildPhraseTermDepth\n\011 [] \011\011\011\011\011:: Buil"
& "dPhraseTermDeep\n }_3\n\011]\011\011\011\011\011:: Select3\n\011"
& "[]\011\011\011\011\011:: BuildPhraseTerm\n }_4\n \";\"\n ]\011"
& "\011\011\011\011\011:: Select4\n\ntypDecl ::=\n [ \"type\" ide { typPa"
& "rams [] } \"=\" typ ]\n\ntyp ::=\n { [ \"(\" typList \")\" { typRngSpe"
& "c [] } ]\n [ \"Option\" typFields \"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\ntypBound ::= \n [ \"<:\" typ ]\n\ntypPar"
& "ams ::=\n [ \"(\" typNameList \")\" ]\n\ntypNameList ::=\n { [ ide { "
& "[ \",\" typList ] [] } ]\n []\n }\n\ntypList ::=\n { [ typ { [ \","
& "\" typList ] [] } ]\n []\n }\n\ntypFields ::=\n { [ ide \":\" typ\n"
& " { [ \",\" typFields ]\n\011[]\n }\n ]\n []\n }\n\ntyp"
& "Spec ::=\n { [ \":\" typ ] [] }\n\ntypResSpec ::=\n { [ \":\" typ { ["
& " \"!\" excList ] [] } ] \n [ \"!\" excList ]\n }\n\ntypRngSpec ::=\n"
& " { [ \"->\" typ { [ \"!\" excList ] [] } ] \n [ \"=>\" typ { [ \"!\""
& " excList ] [] } ] \n [ \"!\" excList ]\n }\n\nexcList ::=\n { [ id"
& "e { [ \"_\" name ] [] } excList ] [] }\n\nprocDecl ::=\n {\n [ { \""
& "All\" \"Some\" } \"(\" ide { typBound [] } \")\" 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";
CONST E0_1 =
"_1 typSpec \"=\" term_2 \n { [ \",\" termBinding_3 ] \011\011\011:"
& ": BuildTermBinding\n []\011\011\011\011\011:: BuildTermBindingSi"
& "ngle\n }_4\n ]\011\011\011\011\011\011:: Select4\n []\011\011"
& "\011\011\011\011:: BuildTermBindingNil\n }\n\ntermSeq ::=\n [ term_1\n"
& " { [ \";\" \n\011{ termSeq_2\011\011\011\011:: BuildTermSeq\n\011 ["
& "]\011\011\011\011\011:: Select1\n\011}_3\n ]\011\011\011\011\011\011"
& ":: Select3\n []\011\011\011\011\011:: Select1\n }_4\n ]\011\011"
& "\011\011\011\011:: Select4\n\ntermSeqOpt ::=\n { termSeq\n [] "
& " :: BuildTermOk\n }\n\nterm ::=\n "
& "( termBase *_1\n { [ \"(\" termList_2 \")\" ]\011\011\011:: BuildTer"
& "mAppl\n [ \"_\" name_2 \n { [ \"(\" termList_3 \")\" ]\011\011"
& ":: BuildTermOp\n []\011\011\011\011\011:: BuildTermOpConst\n "
& " }_4\n ]\011\011\011\011\011\011:: Select4\n [ \".\" nam"
& "e_2 \n { [ \":=\" termOrAlias_3 ]\011\011:: BuildTermUpdate\n "
& " [ \"(\" termList_3 \")\" ] :: BuildTermInvoke\n "
& " []\011\011\011\011\011:: BuildTermSelect\n }_4\n ]\011"
& "\011\011\011\011\011:: Select4\n [ \":=\" term_2 ] "
& " :: BuildTermAssign\n [ \"[\" term_2 \n { [ \"]\""
& "\n { [ \":=\" term_3 ]\011\011\011:: BuildTermArraySet\n "
& " []\011\011\011\011:: BuildTermArrayGet\n }_4\n "
& " ]\011\011\011\011\011:: Select4\n [ \"for\" term_3 \"]\""
& "\n { [ \":=\" term_4 ]\011\011\011:: BuildTermArrayUpd\n "
& " []\011\011\011\011:: BuildTermArraySub\n }_5\n "
& " ]\011\011\011\011\011:: Select5\n }_6\n ]\011\011\011"
& "\011\011\011:: Select6\n [ ide_2 term_3 ]\011\011\011\011:: BuildT"
& "ermInfix\n [ \"andif\" term_2 ]\011\011\011:: BuildTermAndif\n "
& " [ \"orif\" term_2 ]\011\011\011\011:: BuildTermOrif\n }\n )\n\nte"
& "rmBase ::=\n { \n termMinus\n termIde\n termConst\n termAr"
& "ray\n termObj\n termOption\n termClone\n termDelegate\n "
& "termRedirect\n termProc\n termMeth\n termPar\n termLet\n "
& " termVar\n termIf\n termCase\n termLoop\n termExit\n ter"
& "mFor\n termForeach\n termException\n termRaise\n termTry\n "
& " termLock\n termWatch\n termAll\n termSome\n termSelf\n "
& "}\n\ntermIde ::=\n ide_1 \011\011\011\011\011:: BuildTermIde\n\ntermCo"
& "nst ::=\n { \"ok\" :: BuildTerm"
& "Ok\n \"true\" ";
CONST E0_2 =
" :: BuildTermBoolTrue\n \"false\""
& " :: BuildTermBoolFalse\n char_1 "
& " :: BuildTermChar\n string_1 "
& " :: BuildTermString\n int_1 "
& " :: BuildTermInt\n real_1 "
& " :: BuildTermReal\n }\n\ntermMinus ::=\n [ \"~-"
& "\" term_1 ] :: BuildTermMinus\n\ntermArra"
& "y ::=\n [ \"[\" termList_1 \"]\" ]\011\011\011:: BuildTermArray\n\nter"
& "mObj ::=\n [ \"{\" termObjProtected_1 termObjSerialized_2\n termObj"
& "Fields_3 \"}\" ] \011:: BuildTermObj\n\ntermObjProtecte"
& "d ::=\n { [ \"protected\" { \",\" [] } ] \011\011 :: BuildOptio"
& "nYes\n []\011\011\011\011\011\011:: BuildOptionNo\n }\n \ntermObjS"
& "erialized ::=\n { [ \"serialized\" { \",\" [] } ] \011 :: Build"
& "OptionYes\n []\011\011\011\011\011\011:: BuildOptionNo\n }\n\ntermO"
& "ption ::=\n [ \"option\" name_1 typSpec \"=>\" termSeqOpt_2 \"end\" ]\011"
& ":: BuildTermOption\n\ntermOrAlias ::=\n { term\n [ \"alias\" ide_1 "
& "\"of\" termSeq_2 \"end\" ] :: BuildTermAlias\n }\n\ntermObjFields"
& " ::=\n { [ name_1 typSpec \"=>\" termOrAlias_2 \n { [ \",\" termO"
& "bjFields_3 ]\011\011\011:: BuildTermObjField\n\011[]\011\011\011\011\011"
& ":: BuildTermObjFieldSingle\n }_4\n ]\011\011\011\011\011\011:: "
& "Select4\n []\011\011\011\011\011\011:: BuildTermObjFieldNil\n }\n\n"
& "termClone ::=\n [ \"clone\" \"(\" termList_1 \")\" ]\011\011:: BuildTe"
& "rmClone\n\ntermDelegate ::= (* OBSOLETE *)\n [ \"delegate\" termSeq_1 "
& "\"to\" termSeq_2 \"end\" ]\011:: BuildTermRedirect\n\ntermRedirect ::=\n"
& " [ \"redirect\" termSeq_1 \"to\" termSeq_2 \"end\" ]\011:: BuildTermRe"
& "direct\n\ntermProc ::=\n [ \"proc\" \"(\" ideList_1 \")\" { [ typResSp"
& "ec \",\" ] [] } termSeqOpt_2 \"end\" ]\n\011\011\011\011\011 \011:: Bui"
& "ldTermProc\n\ntermMeth ::=\n [ \"meth\" \"(\" ideList_1 \")\" { [ typR"
& "esSpec \",\" ] [] } termSeqOpt_2 \"end\" ]\n\011\011\011\011\011\011:: "
& "BuildTermMeth\ntermPar ::=\n [ \"(\" termSeqOpt_1 \")\" ]\011\011\011:"
& ": Select1\n\ntermLet ::=\n [ \"let\"\n { [ \"rec\" termBinding_1 ] "
& " :: BuildTermLetRec\n termBinding_1 "
& " :: BuildTermLet\n }_2\n ] ";
CONST E0_3 =
" :: Select2 \n\nt"
& "ermVar ::=\n [ \"var\"\n { [ \"rec\" termBinding_1 ] "
& " :: BuildTermVarRec\n termBinding_1 "
& " :: BuildTermVar\n }_2\n ] "
& " :: Select2 \n\ntermIf ::=\n [ \"if\" termSeq_1 "
& "\"then\" termSeqOpt_2 termElsif_3 ]\n\011\011\011\011\011\011:: BuildTe"
& "rmIf\ntermElsif ::=\n { [ \"end\" ]\011\011\011\011\011:: BuildTermIfE"
& "nd\n [ \"else\" termSeqOpt_1 \"end\" ]\011\011\011:: Select1\n [ "
& "\"elsif\" termSeq_1 \"then\" termSeqOpt_2 termElsif_3 ]\n\011\011\011\011"
& "\011\011:: BuildTermIf\n }\n\ntermCase ::=\n [ \"case\" termSeq_1 \n "
& " \"of\" termCaseList_2 ]\011\011\011:: BuildTermCase\n\ntermLoop ::=\n"
& " [ \"loop\" termSeqOpt_1 \"end\" ]\011\011\011:: BuildTermLoop\n\nterm"
& "Exit ::=\n \"exit\"\011\011\011\011\011:: BuildTermExit\n\ntermFor ::="
& "\n [ \"for\" ide_1 typSpec \"=\" term_2 \"to\" term_3 \"do\" termSeqOp"
& "t_4 \"end\" ]\n\011\011\011\011\011\011:: BuildTermFor\n\ntermForeach :"
& ":=\n [ \"foreach\" ide_1 typSpec \"in\" term_2 \n { [ \"do\" termSe"
& "qOpt_3 ]\011\011\011:: BuildTermForeachDo\n [ \"map\" termSeqOpt_3"
& " ]\011\011\011:: BuildTermForeachMap\n }_4\n \"end\" \n ]\011\011"
& "\011\011\011\011:: Select4\n\011\011\011\011\011\011\ntermException ::="
& "\n [ \"exception\"\011\"(\" term_1 \")\" ]\011\011:: BuildTermExceptio"
& "n\n\ntermRaise ::=\n [ \"raise\" \"(\" term_1 \")\" ] "
& " :: BuildTermRaise\n\ntermTry ::=\n [ \"try\" termSeqOpt_1 \n { ["
& " \"except\" termTryList_2 \"end\" ] \011\011:: BuildTermTry\n [ \""
& "else\" termSeqOpt_2 \"end\" ] \011\011:: BuildTermTryElse\n [ \"fi"
& "nally\" termSeqOpt_2 \"end\" ]\011\011:: BuildTermTryFinally\n }_3\n"
& " ]\011\011\011\011\011\011:: Select3\n\ntermList ::=\n { [ term_1 \n "
& " { [ \",\" termList_2 ]\011\011\011:: BuildTermListCons\n\011[]\011"
& "\011\011\011\011:: BuildTermListSingle\n }_3\n ]\011\011\011\011"
& "\011\011:: Select3\n []\011\011\011\011\011\011:: BuildTermListNil\n"
& " }\n\ntermLock ::=\n [ \"lock\" termSeq_1 \"do\" termSeqOpt_2 \"end\""
& " ] :: BuildTermLock\n\ntermWatch ::=\n [ \"watch\" termSeq_1 \"until\""
& " termSeq_2 \"end\" ] :: BuildTermWatch\n\nideList ::=\n { [ ide_1 typS"
& "pec\n { [ \",\" ideList_2 ]\011\011\011:: BuildIdeListCons\n\011[]"
& "\011\011\011\011\011:: BuildIdeListSingle\n }_3\n ]\011\011\011"
& "\011\011\011:: Select3\n []\011\011\011\011\011\011:: BuildIdeListNi"
& "l\n }\n\nterm";
CONST E0_4 =
"CaseListEnd ::=\n { \"end\"\011\011\011\011\011:: BuildCaseListNil\n "
& " [ \"else\" termSeqOpt_1 \"end\" ]\011 :: BuildCaseListElse\n "
& "}\n\ntermCaseList ::=\n { termCaseListEnd\n [ name_1 \n { [ \""
& "(\" ide_2 typSpec \")\" \"=>\" termSeqOpt_3\n { [ \",\" termCa"
& "seList_4 ]\011\011:: BuildCaseListCons\n\011 termCaseListEnd_4 "
& " \011\011:: BuildCaseListCons\n }_5\n ]\011\011\011\011"
& "\011:: Select5\n [ \"=>\" termSeqOpt_3\n { [ \",\" term"
& "CaseList_4 ]\011\011:: BuildCaseListCons\n\011 termCaseListEnd_4 "
& " \011\011:: BuildCaseListCons\n }_5\n ]\011\011\011"
& "\011\011:: Select5\n }_6\n ]\011\011\011\011\011\011:: Select6\n"
& " }\n\ntermTryList ::=\n { [ \"else\" termSeqOpt_1 ] "
& " :: BuildTryListElse\n [ term_1 \"=>\" termSeqOpt_2 \n { [ \""
& ",\" termTryList_3 ]\011\011\011:: BuildTryListCons\n\011[ \"else\" term"
& "SeqOpt_3 ]\011\011\011:: BuildTryListConsElse\n\011[]\011\011\011\011\011"
& ":: BuildTryListSingle\n }_4\n ]\011\011\011\011\011\011:: Selec"
& "t4\n []\011\011\011\011\011\011:: 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.