-- TexToken.mesa -- last written by Doug Wyatt, November 10, 1979 7:00 PM DIRECTORY TexDefs: FROM "TexDefs", TexMemDefs: FROM "TexMemDefs", TexTokenDefs: FROM "TexTokenDefs"; TexToken: PROGRAM IMPORTS TexMemDefs EXPORTS TexTokenDefs = BEGIN OPEN TexTokenDefs; MakeTokenLEntry: PUBLIC PROCEDURE[tok: Token] RETURNS[p: TokenPtr] = BEGIN p←TexMemDefs.AllocMem[SIZE[TokenLEntry]]; p↑←[NIL,tok]; END; MakeTokenLHead: PUBLIC PROCEDURE[hd: TokenPtr] RETURNS[p: TokenListPtr] = BEGIN p←TexMemDefs.AllocMem[SIZE[TokenLHead]]; p↑←[hd,1]; END; FreeTokenLEntry: PUBLIC PROCEDURE[p: TokenPtr] = BEGIN TexMemDefs.FreeMem[p,SIZE[TokenLEntry]] END; FreeTokenLHead: PUBLIC PROCEDURE[p: TokenListPtr] = BEGIN TexMemDefs.FreeMem[p,SIZE[TokenLHead]] END; StoreTok: PUBLIC PROCEDURE[p: POINTER TO TokenPtr, itm: Token] = BEGIN t: TokenPtr←MakeTokenLEntry[itm]; p.link←t; p↑←t; END; DsList: PUBLIC PROCEDURE[p: TokenPtr] = BEGIN q: TokenPtr; WHILE p#NIL DO q←p.link; FreeTokenLEntry[p]; p←q ENDLOOP; END; AddRCLink: PUBLIC PROCEDURE[list: TokenListPtr] = BEGIN list.refs←list.refs+1; END; DelRCLink: PUBLIC PROCEDURE[list: TokenListPtr] = BEGIN p: TokenPtr; IF list=NIL OR (list.refs←list.refs-1)>0 THEN RETURN; p←list.link; FreeTokenLHead[list]; DsList[p]; END; TokChar: PUBLIC PROCEDURE[token: Token] RETURNS[TexDefs.Char] = BEGIN WITH tok:token SELECT FROM macprm,lbrace,rbrace,mathbr,tabmrk, supmrk,submrk,spacer,letter,otherchar => RETURN[tok.char]; ENDCASE; RETURN[0C]; END; END.