NPGSTypes.mesa
Copyright Ó 1985, 1988 by Xerox Corporation. All rights reserved.
Satterthwaite, October 16, 1985 5:27:53 pm PDT
John Maxwell, August 8, 1983 11:15 am
Doug Wyatt, March 21, 1984 10:19:55 am PST
Russ Atkinson (RRA) March 25, 1988 7:21:07 pm PST
JKF February 2, 1989 8:16:23 am PST
NPGSTypes: CEDAR DEFINITIONS = {
data structures and associated types
data structtures using the following types are built by NPGSScan
alternateLim: CARDINAL = 63;
maxProd: CARDINAL = 511;
maxRhsSymbols: CARDINAL = 3*maxProd; -- empirical relation
maxRule: CARDINAL = 2047; --this is the current ProdInfo/NPGSTab limit
pssLim: CARDINAL = 1023; -- 10 bit field in itemrec to hold production, symbol
or state numbers, NPGSTab allows an 11 bit field
rhsLim: CARDINAL = 15; --this is the current NPGSTab limit, change the grammar?
symTabSize: CARDINAL = 511; --symbol table size
tokenSize: CARDINAL = 20; -- changed for CUSP
SymTab: TYPE = REF TEXT; --[0..(symTabSize+1)*tokensize)
SymTabSeq: TYPE = TEXT;
SymTabEntry: TYPE = RECORD[
link: [0..symTabSize],
length: [0..tokenSize],
used: BOOL];
nullSymTabEntry: SymTabEntry = [link: 0, length: 0, used: FALSE];
SymInfo: TYPE = REF SymInfoSeq; --[0..symtabsize]
SymInfoSeq: TYPE = RECORD[SEQUENCE length: CARDINAL OF SymTabEntry];
AliasEntry: TYPE = RECORD[terminal, alias: CARDINAL];
nullAliasEntry: AliasEntry = [terminal: 0, alias: 0];
Aliases: TYPE = REF AliasesSeq; --[0..63]
AliasesSeq: TYPE = RECORD[SEQUENCE length: CARDINAL OF AliasEntry];
TokenEntry: TYPE = RECORD[
count: [0..alternateLim],
empty: BOOL,
index: [0..maxProd]];
nullTokenEntry: TokenEntry = [count: 0, empty: FALSE, index: 0];
TokenInfo: TYPE = REF TokenInfoSeq; --(eofile..totaltokens]
TokenInfoSeq: TYPE = RECORD[SEQUENCE length: CARDINAL OF TokenEntry];
ProdEntry: TYPE = MACHINE DEPENDENT RECORD [
chain (0: 0..0): BOOL,
count (0: 1..15): [0..rhsLim],
rule (0: 16..31): [0..maxRule],
lhs (0: 32..47): [0..symTabSize],
index (0: 48..63): [0..maxRhsSymbols]];
nullProdEntry: ProdEntry = [chain: FALSE, count: 0, rule: 0, lhs: 0, index: 0];
ProdInfo: TYPE = REF ProdInfoSeq; --[0..maxProd]
ProdInfoSeq: TYPE = RECORD[SEQUENCE length: CARDINAL OF ProdEntry];
Cardinals: TYPE = REF CardinalsSeq;
CardinalsSeq: TYPE = RECORD[SEQUENCE length: CARDINAL OF CARDINAL];
RhsChar: TYPE = Cardinals; --[0..maxRhsSymbols]
Options: TYPE = {echo, chain, lists, printLR, printLALR, first, ids};
types for LR(0) tables in NPGSLALR
StateInfoRec: TYPE = RECORD[link, nucleus, entries: CARDINAL];
nullStateInfoRec: StateInfoRec = [link: 0, nucleus: 0, entries: 0];
StateInfo: TYPE = REF StateInfoSeq; --[0,maxstatenum+1]
StateInfoSeq: TYPE = RECORD[SEQUENCE length: CARDINAL OF StateInfoRec];
ItemRec: TYPE = PACKED RECORD[tag: CARDINAL[0..3], jf: CARDINAL[0..15], pss: CARDINAL[0..pssLim]];
nullItemRec: ItemRec = [tag: 0, jf: 0, pss: 0];
Table: TYPE = REF TableSeq; --[0..maxtabentries]
TableSeq: TYPE = RECORD[SEQUENCE length: CARDINAL OF ItemRec];
after table is built,
tag = 3 => pss is a nonterminal symbol, such an entry is followed by an entry:
tag = 0 => pss is a next state number
tag = 1 => pss is production number, scanreduce, jf=n[p]
tag = 2 => pss is production number, reduce, jf=n[p]
types for LALR(1) lookahead sets in NPGSLALR
ChainRec: TYPE = RECORD[state, link: CARDINAL];
nullChainRec: ChainRec = [state: 0, link: 0];
BackChain: TYPE = REF BackChainSeq; --[0..totalshifts] initially
BackChainSeq: TYPE = RECORD[SEQUENCE length: CARDINAL OF ChainRec];
Stack: TYPE = Cardinals; --[0..30) initially
ChainStack: TYPE = Stack; --[0..90) initially
ContextRec: TYPE = RECORD[state, status, link: CARDINAL, item: ItemRec];
nullContextRec: ContextRec = [state: 0, status: 0, link: 0, item: nullItemRec];
BitsInfo: TYPE = REF BitsInfoSeq; --[0..maxcontexts)
BitsInfoSeq: TYPE = RECORD[SEQUENCE length: CARDINAL OF ContextRec];
BitString: TYPE = REF BitStringSeq; --[0..maxcontexts)
BitStringSeq: TYPE = RECORD[length, width: CARDINAL, seq: SEQUENCE size: CARDINAL OF WORD];
FirstBits: TYPE = BitString; --[eofile+1..totaltokens]
types used internally by NPGSLALR
AttrVec: TYPE = Cardinals; --[eofile+1..totaltokens]
HashHeads: TYPE = ARRAY [0..60] OF CARDINAL;
HashHeadsRef: TYPE = REF HashHeads;
types used by NPGSTab
HashTabRec: TYPE = MACHINE DEPENDENT RECORD[symPtr: [0..255], link: [0..255]];
nullHashTabRec: HashTabRec = [symPtr: 0, link: 0];
HashTab: TYPE = REF HashTabSeq; --[0..hashval]
HashTabSeq: TYPE = RECORD[SEQUENCE length: CARDINAL OF HashTabRec];
TabRec: TYPE = RECORD[symbol: CARDINAL, item: ItemRec];
nullTabRec: TabRec = [symbol: 0, item: nullItemRec];
Tab: TYPE = REF TabSeq;
TabSeq: TYPE = RECORD[SEQUENCE length: CARDINAL OF TabRec];
TTab: TYPE = Tab; --[0..tentries-1];
NTab: TYPE = Tab; --[0..ntentries-1];
ColumnRec: TYPE = RECORD[link, count: CARDINAL, item: ItemRec];
nullColumnRec: ColumnRec = [link: 0, count: 0, item: nullItemRec];
Column: TYPE = REF ColumnSeq; --[0..ntentries];
ColumnSeq: TYPE = RECORD[SEQUENCE length: CARDINAL OF ColumnRec];
StateDataRec: TYPE = RECORD[tIndex, ntIndex: CARDINAL, tLink, ntLink: INTEGER];
nullStateDataRec: StateDataRec = [tIndex: 0, ntIndex: 0, tLink: 0, ntLink: 0];
StateData: TYPE = REF StateDataSeq; --[0..slim-1];
StateDataSeq: TYPE = RECORD[SEQUENCE length: CARDINAL OF StateDataRec];
NTDefaultRec: TYPE = RECORD[count: CARDINAL, item: ItemRec];
nullNTDefaultRec: NTDefaultRec = [count: 0, item: nullItemRec];
NTDefaults: TYPE = REF NTDefaultsSeq; --[0..totaltokens-eofile+1]
NTDefaultsSeq: TYPE = RECORD[SEQUENCE length: CARDINAL OF NTDefaultRec];
Renumber: TYPE = Cardinals; --[0..slim-1]
VocabIndex: TYPE = Cardinals; --[0..eofile-1]
types used by NPGSFormat (also uses SymTab, RhsChar, HashHeads, HashHeadsRef)
SInfoRec: TYPE = RECORD[symPtr, link, lhsHead: CARDINAL];
nullSInfoRec: SInfoRec = [symPtr: 0, link: 0, lhsHead: 0];
SInfo: TYPE = REF SInfoSeq; --[0..symTabSize+1];
SInfoSeq: TYPE = RECORD[SEQUENCE length: CARDINAL OF SInfoRec];
PInfoRec: TYPE = RECORD[rule: [0..77777B], chain: BOOL, link, rhsPtr: CARDINAL];
nullPInfoRec: PInfoRec = [rule: 0, chain: FALSE, link: 0, rhsPtr: 0];
PInfo: TYPE = REF PInfoSeq; --[0..maxProd+1];
PInfoSeq: TYPE = RECORD[SEQUENCE length: CARDINAL OF PInfoRec];
Cusp extensions:
Used: TYPE = {no, yes, header};
TokenSeq: TYPE = RECORD [SEQUENCE length: CARDINAL OF Used];
TokensUsed: TYPE = REF TokenSeq; -- [1..totalTokens]
ErrorType: TYPE = {MAgg, MCalled, MDotLB, MExpr, MId, MOpd,
MOptn, MRArrow, MThe, MTxt, MTypeId, MFieldTypeId, CloseIconExpr,
CopyIconExpr, MoveIconExpr, SelectIconExpr, IconExpr,
Stmt, MSecs, tl};
ErrSeq: TYPE = RECORD [SEQUENCE length: CARDINAL OF ErrorType];
ErrorMsg: TYPE = REF ErrSeq; --[1..slim]
types used by NPGSCuspPre
HashChainArray: TYPE = ARRAY [1..symTabSize/4] OF CARDINAL;
HashChain: TYPE = REF HashChainArray;
}.