PGSConDefs.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Ed Satterthwaite, October 16, 1985 5:32:10 pm PDT
John Maxwell, August 8, 1983 11:17 am
Doug Wyatt, March 29, 1984 2:10:29 pm PST
Russ Atkinson (RRA) March 19, 1985 9:55:48 am PST
DIRECTORY
Basics: TYPE USING [bitsPerWord, charsPerWord],
IO: TYPE USING [STREAM],
PGSTypes: TYPE USING [Aliases, alternateLim, AttrVec, BackChain, BitsInfo, BitString, Column, HashTab, maxProd, maxRhsSymbols, maxRule, NTDefaults, Options, PInfo, ProdInfo, pssLim, Renumber, RhsChar, rhsLim, SInfo, Stack, StateData, StateInfo, SymInfo, SymTab, symTabSize, Tab, Table, TokenInfo, tokenSize, VocabIndex],
PrincOps: TYPE USING [wordsPerPage],
Rope: TYPE USING [ROPE],
TimeStamp: TYPE USING [Stamp];
PGSConDefs: DEFINITIONS = {
OPEN PGSTypes;
machine parameters
cpw: NAT = Basics.charsPerWord;
pageSize: NAT = PrincOps.wordsPerPage;
wordLength: NAT = Basics.bitsPerWord;
maxCharCode: NAT = CHAR.LAST.ORD;
common compile time constants
outbufLim: NAT = 90;
PGSScan compile time constants
alternateLim: CARDINAL = PGSTypes.alternateLim;
maxProd: CARDINAL = PGSTypes.maxProd;
maxRhsSymbols: CARDINAL = PGSTypes.maxRhsSymbols;
maxRule: CARDINAL = PGSTypes.maxRule;
pssLim: CARDINAL = PGSTypes.pssLim;
rhsLim: CARDINAL = PGSTypes.rhsLim;
symTabSize: CARDINAL = PGSTypes.symTabSize;
tokenSize: CARDINAL = PGSTypes.tokenSize;
wordsForToken: CARDINAL = (tokenSize+cpw-1)/cpw;
query: CHAR = '?; -- marker character in PGSformat
PGSLALR constants
maxStateNum: CARDINAL = 400;
stateExt: CARDINAL = 100;
maxTabEntries: CARDINAL = 7000;
tabExt: CARDINAL = 1000;
maxContexts: CARDINAL = 960;
PGSTab constants
defaultMarker: CARDINAL = 0;
structures built and exported by PGSControl, used by PGSFormat and PGSBcd
pgsVersion: VAR TimeStamp.Stamp;
sourceVersion: VAR TimeStamp.Stamp;
sourceName: VAR Rope.ROPE;
objectVersion: VAR TimeStamp.Stamp;
structures built by PGSScan, exported by PGSControl, used by PGSLALR and PGSTab
warningsLogged: VAR BOOL;
eofMark: VAR CARDINAL; -- last terminal
totalTokens: VAR CARDINAL; -- size of grammar vocabulary
numProd: VAR CARDINAL; -- number of productions
numRules: VAR CARDINAL; -- number of rules
nextAlias: VAR CARDINAL; -- number of aliased terminal symbols
flags: VAR ARRAY Options OF BOOL;
symTab: VAR SymTab;
symInfo: VAR SymInfo;
aliases: VAR Aliases;
tokenInfo: VAR TokenInfo;
prodInfo: VAR ProdInfo;
rhsChar: VAR RhsChar;
structures built by PGSLALR, exported by PGSControl, used by PGSTab
sLim, tEntries, ntEntries: VAR CARDINAL;
structures built by PGSLALR, exported by PGSControl, used by PGSControl and PGSLALR
bitstrSize: VAR CARDINAL;
procedures
storage management, exported by PGSControl
MakeSymTab: PROC[length: CARDINAL] RETURNS[new: SymTab];
MakeSymInfo: PROC[length: CARDINAL] RETURNS[new: SymInfo];
MakeAliases: PROC[length: CARDINAL] RETURNS[new: Aliases];
MakeTokenInfo: PROC[length: CARDINAL] RETURNS[new: TokenInfo];
MakeProdInfo: PROC[length: CARDINAL] RETURNS[new: ProdInfo];
MakeRhsChar: PROC[length: CARDINAL] RETURNS[new: RhsChar];
MakeStateInfo: PROC[length: CARDINAL] RETURNS[new: StateInfo];
MakeTable: PROC[length: CARDINAL] RETURNS[new: Table];
MakeBackChain: PROC[length: CARDINAL] RETURNS[new: BackChain];
MakeStack: PROC[length: CARDINAL] RETURNS[new: Stack];
MakeBitsInfo: PROC[length: CARDINAL] RETURNS[new: BitsInfo];
MakeBitString: PROC[length, width: CARDINAL] RETURNS[new: BitString];
MakeAttrVec: PROC[length: CARDINAL] RETURNS[new: AttrVec];
MakeHashTab: PROC[length: CARDINAL] RETURNS[new: HashTab];
MakeTab: PROC[length: CARDINAL] RETURNS[new: Tab];
MakeColumn: PROC[length: CARDINAL] RETURNS[new: Column];
MakeStateData: PROC[length: CARDINAL] RETURNS[new: StateData];
MakeNTDefaults: PROC[length: CARDINAL] RETURNS[new: NTDefaults];
MakeRenumber: PROC[length: CARDINAL] RETURNS[new: Renumber];
MakeVocabIndex: PROC[length: CARDINAL] RETURNS[new: VocabIndex];
MakeSInfo: PROC[length: CARDINAL] RETURNS[new: SInfo];
MakePInfo: PROC[length: CARDINAL] RETURNS[new: PInfo];
ExpandSymTab: PROC[old: SymTab, ext: CARDINAL] RETURNS[new: SymTab];
ExpandSymInfo: PROC[old: SymInfo, ext: CARDINAL] RETURNS[new: SymInfo];
ExpandAliases: PROC[old: Aliases, ext: CARDINAL] RETURNS[new: Aliases];
ExpandProdInfo: PROC[old: ProdInfo, ext: CARDINAL] RETURNS[new: ProdInfo];
ExpandRhsChar: PROC[old: RhsChar, ext: CARDINAL] RETURNS[new: RhsChar];
ExpandStateInfo: PROC[old: StateInfo, ext: CARDINAL] RETURNS[new: StateInfo];
ExpandStack: PROC[old: Stack, ext: CARDINAL] RETURNS[new: Stack];
ExpandBitsInfo: PROC[old: BitsInfo, ext: CARDINAL] RETURNS[new: BitsInfo];
ExpandBitString: PROC[old: BitString, ext: CARDINAL] RETURNS[new: BitString];
ExpandSInfo: PROC[old: SInfo, ext: CARDINAL] RETURNS[new: SInfo];
ExpandPInfo: PROC[old: PInfo, ext: CARDINAL] RETURNS[new: PInfo];
stream input/output, exported by PGSControl
seterrstream: PROC;
setoutstream: PROC[dotstring: Rope.ROPE];
resetoutstream: PROC;
closeoutstream: PROC;
cleanupstreams: PROC;
inchar: PROC RETURNS[c: CHAR, end: BOOL];
getindex: PROC RETURNS[CARDINAL];
setindex: PROC[index: CARDINAL];
outchar: PROC[c: CHAR, n: INTEGER];
outeol: PROC[n: INTEGER];
outnum: PROC[val: INTEGER, cols: NAT, signChar: CHAR←'-];
outstring: PROC[string: Rope.ROPE];
outtab: PROC;
outtime: PROC;
openwordstream: PROC[scratch: BOOLTRUE];
closewordstream: PROC;
inword: PROC RETURNS[CARDINAL];
outword: PROC[n: CARDINAL];
outblock: PROC[address: LONG POINTER, words: CARDINAL, offset: CARDINAL ← 0];
bit manipulation, exported by PGSControl
BitsPtr: PRIVATE TYPE ~ LONG POINTER TO PACKED ARRAY[0..0) OF BOOL;
FindBit: PROC[source: BitString, index, bit: CARDINAL] RETURNS[BOOL]
~ TRUSTED INLINE {RETURN[LOOPHOLE[@source[index*source.width], BitsPtr][bit]]};
InsertBit: PROC[sink: BitString, index, bit: CARDINAL]
~ TRUSTED INLINE {LOOPHOLE[@sink[index*sink.width], BitsPtr][bit] ← TRUE};
orCount: VAR CARDINAL;
OrBits: PROC[source: BitString, sourceI: CARDINAL, sink: BitString, sinkI: CARDINAL];
errors, exported by PGSControl
PGSFail: ERROR;
implemented by PGSScan
OutToken: PROC[symbol: CARDINAL] RETURNS[CARDINAL];
CheckOut: PROC;
implemented by PGSLALR
LALRGen: PROC RETURNS[BOOL];
implemented by PGSTab
TabGen: PROC[prefix, suffix: PROC] RETURNS[BOOL];
OutModule: PROC[typename, modfname: Rope.ROPE, long: BOOLFALSE];
implemented by PGSFormat
Format: PROC RETURNS[table, type, export: Rope.ROPE];
PrintGrammar: PROC;
implemented by PGSBcd
WriteBcdHeader: PROC[
outStream: IO.STREAM,
tableId, binaryId: Rope.ROPE, -- file being written
interfaceId, fileId: Rope.ROPE, -- interface being exported
altoCode: BOOLFALSE];
FixupBcdHeader: PROC;
implemented by PGSSymbols
WriteSymbols: PROC[s: IO.STREAM, moduleId: Rope.ROPE];
}.