EDIFGrammar.Mesa
Spreitzer, February 24, 1986 10:49:39 pm PST
EDIFGrammar: CEDAR DEFINITIONS
= {
LORA: TYPE = LIST OF REF ANY;
ATOMList: TYPE = LIST OF ATOM;
Level: TYPE = INTEGER [0 .. 2];
RuleList: TYPE = LIST OF Rule;
Rule: TYPE = REF RulePrivate;
RulePrivate: TYPE = RECORD [
variant: SELECT class: * FROM
list => [keyword: ATOM, elts: RuleList, cutAfterFirst: BOOLTRUE],
The first rule in elts is redundant with keyword.
keyword = NIL means any keyword is acceptable.
If cutAfterFirst, there's a cut (a la Prolog) after the keyword; otherwise can backtrack after any prefix of matching.
repeat => [sub: Rule, zero, moreThanOne: BOOL],
choice => [choices: RuleList],
levelGuard => [r: Rule, min, max: Level],
nonTerminal => [category: ATOM, onceOnly: BOOLFALSE],
terminal => [category: TerminalClass, value: REF ANYNIL, defsName: BOOLFALSE],
ENDCASE
];
RuleClass: TYPE = {list, repeat, choice, levelGuard, nonTerminal, terminal};
TerminalClass: TYPE = {String, Integer, Identifier, Form};
GetRuleDef: PROC [category: ATOM] RETURNS [r: Rule];
MakeRule: PROC [category: ATOM] RETURNS [r: Rule];
GetCategory: PROC [r: Rule] RETURNS [category: ATOM];
DL--Def List--: PROC [category: ATOM, rest: LORA, min: Level ← 0, max: Level ← 2] RETURNS [a: ATOM];
DL2--Def List with explicit keyword--: PROC [category: ATOM, rest: LORA, min: Level ← 0, max: Level ← 2] RETURNS [a: ATOM];
DBL2--Def backtracking List with explicit keyword--: PROC [category: ATOM, rest: LORA, min: Level ← 0, max: Level ← 2, cutAfterFirst: BOOLFALSE] RETURNS [a: ATOM];
DLU--Def List with unconstrained keyword--: PROC [category: ATOM, rest: LORA, min: Level ← 0, max: Level ← 2] RETURNS [a: ATOM];
DC--Def Choice--: PROC [category: ATOM, choices: LORA, min: Level ← 0, max: Level ← 2] RETURNS [a: ATOM];
DQ--Def Queer--: PROC [category: ATOM, list: LORA, other: REF ANY, min: Level ← 0, max: Level ← 2] RETURNS [a: ATOM];
NameDef: PROC RETURNS [Rule];
NameRef: PROC RETURNS [Rule];
Ch--oice--: PROC [choices: LORA] RETURNS [Rule];
Star: PROC [rule: REF ANY] RETURNS [Rule];
Plus: PROC [rule: REF ANY] RETURNS [Rule];
Limit: PROC [rule: REF ANY, min: Level ← 0, max: Level ← 2] RETURNS [Rule];
Opt: PROC [rule: REF ANY] RETURNS [Rule];
StarCh: PROC [choices: LORA] RETURNS [Rule];
Oo: PROC [category: ATOM] RETURNS [Rule];
LR: PROC [rules: LORA, cutAfterFirst: BOOLFALSE] RETURNS [Rule];
JdC--Jot dot Cat--: PROC [left, right: ATOMList] RETURNS [crossed: LORA];
}.