DIRECTORY Rope USING [ROPE], IO USING [STREAM]; Interscript: CEDAR DEFINITIONS IMPORTS IO = BEGIN Id: TYPE ~ Rope.ROPE; Universal: TYPE ~ ATOM; LinkSet: TYPE ~ RECORD[sources: SpanList, targets: SpanList]; SpanList: TYPE ~ LIST OF Span; Span: TYPE ~ REF SpanRec; SpanRec: TYPE; Value: TYPE ~ REF ValueRec; ValueRec: TYPE ~ RECORD[SELECT t: * FROM nil => [], number => [SELECT numTag: * FROM int => [int: INT], real => [real: REAL] ENDCASE], string => [r: Rope.ROPE], span => [--TBD--], expr => [expr: ExprTree] ENDCASE]; ExprTree: TYPE ~ REF ExprTreeRec; ExprTreeRec: TYPE ~ RECORD[ vp: SELECT type: * FROM monadic => [op: Operator, left: ExprTree], dyadic => [op: Operator, left, right: ExprTree], terminal => [v: Value] ENDCASE]; Token: TYPE ~ REF TokenRec; TokenRec: TYPE ~ RECORD[ first, last: STREAMPosition, -- to record where a token came from vp: SELECT type: OfToken FROM id => [id: Id], univ => [univ: Universal], -- includes keywords also int => [int: INT], real => [real: REAL], string => [s: Rope.ROPE], op => [op: Operator], sep => [s: Separator], bracket => [b: Bracket], literal => [lit: Literal] ENDCASE ]; OfToken: TYPE ~ {id, univ, int, real, string, op, sep, bracket, literal}; Operator: TYPE ~ {plus, minus, times, slash}; Separator: TYPE ~ {semicolon, dot, percent, exclamation, verticalBar, localGets, globalGets, upArrow, colon}; Bracket: TYPE ~ {lParen, rParen, lBracket, rBracket, lBrace, rBrace, quote}; Literal: TYPE ~ {nil, true, false}; STREAMPosition: TYPE ~ INT; InitScan: PROCEDURE [stream: IO.STREAM, bindTbl: BTHandle, z: ZONE]; GetToken: PROCEDURE RETURNS [t: Token]; Internalize: PROCEDURE [stream: IO.STREAM, z: ZONE]; BTHandle: TYPE ~ REF BindingTable; BindingTable: TYPE; Binding: TYPE ~ REF BindingRec; BindingRec: TYPE ~ RECORD[id: Id, m: BindingMode, v: Value]; BindingMode: TYPE ~ {local, global} _ local; InitBindingTable: PROCEDURE [z: ZONE] RETURNS [bt: BTHandle]; AddBinding: PROCEDURE [self: BTHandle, b: Binding]; GetBinding: PROCEDURE [self: BTHandle, id: Id] RETURNS [binding: Binding]; GetBindings: PROCEDURE [self: BTHandle, ids: LIST OF Id] RETURNS [bindings: LIST OF Binding]; Scope: TYPE ~ RECORD[uid: INT]; NewScope: PROCEDURE [self: BTHandle] RETURNS [s: Scope]; PopScope: PROCEDURE [self: BTHandle, s: Scope]; END. interscript.mesa Last Edited by: Mitchell, February 1, 1983 11:10 am -- basic Interscript items -- lexical definitions -- parsing -- bindings adds the binding to the table in the current scope. Any extant binding for the same id in the current scope is overwritten. Returns id's binding, or NIL if unbound for each id in the list, returns its binding, or NIL if unbound pushes a new scope and returns a handle for it Pops the current scope, which s must identify (else error ScopeError[inputError] is generated). -- spans ΚΖ˜Jšœ Οc™Jšœ3™3unitšΟk ˜ Jšœžœžœ˜Jšžœžœžœ˜—Kš Οn œžœž œžœžœž˜1™Kšœžœžœ˜Kšœ žœžœ˜Kšœ žœžœ'˜=Kšœ žœžœžœ˜Kšœžœžœ ˜Kšœ žœ˜Kšœžœžœ ˜šœ žœžœžœž˜(Jšœ ˜ šœ žœ ž˜!Jšœžœ˜Jšœžœ˜Jšžœ˜ —Jšœžœ˜Jšœ œ˜J˜Jšžœ˜ —Kšœ žœžœ ˜!šœ žœžœ˜codešœžœ ž˜Jšœ+˜+Jšœ1˜1Jšœ˜Jšžœ˜ ———™Kšœžœžœ ˜šœ žœžœ˜Lšœ$˜Bšœžœž˜Jšœ˜Jšœ˜6Jšœžœ˜Jšœžœ˜Jšœžœ˜Jšœ˜J˜J˜Jšœ˜Jšž˜—Jšœ˜—Kšœ žœ<˜IKšœ žœ˜-Kšœ žœ^˜mKšœ žœ?˜LKšœ žœ˜#Kšœžœžœ˜Kš Ÿœž œ žœžœžœ˜DKšŸœž œžœ ˜'—™ Kš Ÿ œž œ žœžœžœ˜4—™ Kšœ žœžœ˜"Kšœžœ˜Kšœ žœžœ ˜Kšœ žœžœ#˜