-- TexState.mesa -- last written by Doug Wyatt, November 10, 1979 6:57 PM DIRECTORY TexDefs: FROM "TexDefs", TexMathDefs: FROM "TexMathDefs", TexMemDefs: FROM "TexMemDefs", TexTableDefs: FROM "TexTableDefs"; TexState: PROGRAM IMPORTS TexMemDefs,TexTableDefs EXPORTS TexTableDefs SHARES TexTableDefs = BEGIN OPEN TexMathDefs,TexDefs,TexTableDefs; globalhang: HangSpec; GlobalHangIndent: PUBLIC PROCEDURE RETURNS[HangSpec] = BEGIN RETURN[globalhang] END; SetGlobalHangIndent: PUBLIC PROCEDURE[hang: HangSpec] = BEGIN globalhang_hang END; DimnParamTable: TYPE = ARRAY DimnParamType OF Dimn; dimns: POINTER TO DimnParamTable_NIL; DimnParam: PUBLIC PROCEDURE[t: DimnParamType] RETURNS[Dimn] = BEGIN RETURN[dimns[t]] END; SetDimnParam: PUBLIC PROCEDURE[t: DimnParamType, d: Dimn] = BEGIN dimns[t]_d END; KountTable: TYPE = ARRAY Digit OF INTEGER; kount: POINTER TO KountTable; Kount: PUBLIC PROCEDURE[d: Digit] RETURNS[INTEGER] = BEGIN RETURN[kount[d]] END; SetKount: PUBLIC PROCEDURE[d: Digit, k: INTEGER] = BEGIN kount[d]_k END; SpaceFactorTable: TYPE = ARRAY Char OF SpaceFactor; sftable: POINTER TO SpaceFactorTable_NIL; SfTable: PUBLIC PROCEDURE[c: Char] RETURNS[SpaceFactor] = BEGIN RETURN[sftable[c]] END; SetSfTable: PUBLIC PROCEDURE[c: Char, sf: SpaceFactor] = BEGIN sftable[c]_sf END; DelimIndex: TYPE = [0..377B]; nullDelimIndex: DelimIndex=LAST[DelimIndex]; ndelims: DelimIndex_0; maxdelims: DelimIndex=14; DelimIndexTable: TYPE = PACKED ARRAY Char OF DelimIndex; DelimTable: TYPE = ARRAY DelimIndex[0..maxdelims) OF Delimiter; delimindex: POINTER TO DelimIndexTable; delimtable: POINTER TO DelimTable; AddDelimiter: PUBLIC PROCEDURE[c: Char, delim: Delimiter] = BEGIN IF ndelims=maxdelims THEN ERROR; delimtable[delimindex[c]_ndelims]_delim; ndelims_ndelims+1; END; DelimLookup: PUBLIC PROCEDURE[c: Char] RETURNS[defined: BOOLEAN, delim: Delimiter] = BEGIN i: DelimIndex_delimindex[c]; IF i=nullDelimIndex THEN RETURN[FALSE, nullDelimiter] ELSE RETURN[TRUE,delimtable[i]]; END; StateInit: PROCEDURE = BEGIN OPEN TexMemDefs; globalhang_nullHang; dimns_AllocMem[SIZE[DimnParamTable]]; kount_AllocMem[SIZE[KountTable]]; sftable_AllocMem[SIZE[SpaceFactorTable]]; delimindex_AllocMem[SIZE[DelimIndexTable]]; delimtable_AllocMem[SIZE[DelimTable]]; dimns^_ALL[0]; kount^_ALL[0]; sftable^_ALL[0]; delimindex^_ALL[nullDelimIndex]; ndelims_0; START TexStateInit; END; StateInit; END.