file MTP1.mesa
last modified by Satterthwaite, June 6, 1983 2:35 pm
last edit by Schmidt, May 3, 1982 4:28 pm
Last Edited by: Nichols, July 13, 1983 6:24 pm
DIRECTORY
IO: TYPE USING [STREAM],
MTParseTable: TYPE ParseTable USING [ActionEntry, ProdDataRef, State, TableRef, TSymbol],
Rope USING [ROPE];
MTP1: CEDAR DEFINITIONS ~ {
OPEN MTParseTable;
Index: TYPE~INT;
ref types
ValueStack: TYPE~REF ValueSeq;
StateStack: TYPE~REF StateSeq;
LinkStack: TYPE~REF LinkSeq;
ActionStack: TYPE~REF ActionSeq;
record structures
These three record types are used to build the tree describing the name list. Fields that have default initializers of NIL may be NIL, but others must be filled in.
AddrSpecNode: TYPE ~ RECORD[
localPart: REF ANY,  -- localPart may point to AddrSpecNode or DotWordsNode
atSign: REF TerminalNode ← NIL,
domain: REF DomainNode ← NIL];
DomainNode: TYPE ~ RECORD[
domain: REF DomainNode ← NIL,
dot: REF TerminalNode ← NIL,
subDomain: REF TerminalNode];
DotWordsNode: TYPE ~ RECORD[
dotWords: REF DotWordsNode ← NIL,
dot: REF TerminalNode ← NIL,
word: REF TerminalNode];
InternalNode: TYPE ~ LIST OF REF ANY;
MailboxNode: TYPE ~ RECORD[
phrase: REF ANYNIL,
address: REF ANY];
RouteAddrNode: TYPE ~ RECORD[
lBrack: REF TerminalNode,
route: REF RouteNode ← NIL,
colon: REF TerminalNode ← NIL,
addrSpec: REF AddrSpecNode,
rBrack: REF TerminalNode];
RouteNode: TYPE ~ RECORD[
route: REF RouteNode ← NIL,
comma: REF TerminalNode ← NIL,
atSign: REF TerminalNode,
domain: REF DomainNode];
TerminalNode: TYPE ~ RECORD[
whiteSpace: Rope.ROPENIL,
text: Rope.ROPE];
TValue: TYPE ~ REF ANYNIL;  -- value of terminal symbol
NTValue: TYPE ~ CARDINAL𡤀  -- value of nonterminal
Value: TYPE~RECORD[ -- type of the value stack
t: TValue,   -- refs (ATOMS, etc.)
n: NTValue];   -- scalars (counts, flags, etc.)
ValueSeq: TYPE~RECORD[SEQUENCE length: NAT OF Value];
nullTValue: TValue ~ NIL;
nullNTValue: NTValue ~ NTValue.LAST;
nullValue: Value ~ [];
nullId: Value ~ nullValue;
StateSeq: TYPE~RECORD[SEQUENCE length: NAT OF State];
LinkSeq: TYPE~RECORD[SEQUENCE length: NAT OF Index]; -- links to source text
ActionSeq: TYPE~RECORD[SEQUENCE length: NAT OF ActionEntry];
Token: TYPE~RECORD[
class: TSymbol,  -- the token class
value: TValue,  -- value
index: Index];  -- source stream index
implemented by scanner
ScanInit: PROC[source: IO.STREAM];
ScanReset: PROC RETURNS[nTokens, nErrors: CARDINAL];
ScannerProc: TYPE~PROC RETURNS [token: Token];
ScanName: ScannerProc;
ScanDate: ScannerProc;
implemented by parser
InstallParseTable: PROC[TableRef];
Parse: PROC[source: IO.STREAM, Input: ScannerProc]
RETURNS[complete: BOOL, nTokens, nErrors: CARDINAL];
implemented by evaluator
AssignDescriptors: PROC[
qd: ActionStack, vd: ValueStack, ld: LinkStack,
pp: ProdDataRef];
EvalInit: PROC;
ProcessQueue: PROC[qI, top: CARDINAL];
ProcessError: PROC[top: CARDINAL, inputValue: TValue];
GetEvalResult: PROC RETURNS [tree: REF ANY, badSemantics: BOOL];
}.