-- Expressions.mesa -- last edit July 12, 1984 1:05:52 pm PDT Sturgis DIRECTORY Dependencies USING[Action, DataItem, DependencySet], Rope USING[ROPE]; Expressions: DEFINITIONS = BEGIN OPEN Dependencies; HCellIdSet: TYPE = REF HCellIdSetBody; HCellIdSetBody: TYPE; MakeHCellIdSet: PROCEDURE RETURNS[HCellIdSet]; AnalyzedHCellIdentifier: TYPE = REF AnalyzedHCellIdentifierBody; AnalyzedHCellIdentifierBody: TYPE = RECORD[ name: Rope.ROPE, dataItem: Dependencies.DataItem, privateData: REF ANY]; HCellIdentifier: TYPE = RECORD[name: Rope.ROPE]; AnalyzedHCellExpression: TYPE = RECORD[exp: Expression]; HCellExpression: TYPE = RECORD[exp: Expression]; ParseHCellExpression: PROCEDURE[Rope.ROPE] RETURNS[HCellExpression]; ParseHCellIdentifier: PROCEDURE[Rope.ROPE] RETURNS[HCellIdentifier]; AnalyzeHCellExpression: PROCEDURE[exp: HCellExpression, idSet: HCellIdSet, pageName, arrayName: Rope.ROPE, dSet: Dependencies.DependencySet, evalAction: Dependencies.Action] RETURNS[AnalyzedHCellExpression]; AnalyzeHCellIdentifier: PROCEDURE[id: HCellIdentifier, idSet: HCellIdSet, pageName, arrayName: Rope.ROPE, dSet: Dependencies.DependencySet] RETURNS[AnalyzedHCellIdentifier]; EvaluateAnalyzedHCellExpression: PROCEDURE[AnalyzedHCellExpression] RETURNS[REAL]; SetAnalyzedHCellIdentifier: PROCEDURE[AnalyzedHCellIdentifier, REAL]; -- following definitions existed before July 12, 1984 1:06:08 pm PDT, and support GCell code. Some are also used to support the new HCell code. IdTable: TYPE = REF IdTableBody; IdTableBody: TYPE; IdTableSetIndex: TYPE = {self, n, e, s, w, page, global}; IdTableSet: TYPE = ARRAY IdTableSetIndex OF IdTable; AnalyzedIdentifier: TYPE = RECORD[id: Identifier]; Identifier: TYPE = REF IdentifierBody; IdentifierBody: TYPE = RECORD[ set: IdTableSetIndex, name: Rope.ROPE, desc: IdentifierDescriptor]; IdentifierDescriptor: TYPE = REF IdentifierDescriptorBody; IdentifierDescriptorBody: TYPE; Token: TYPE = REF TokenBody; TokenBody: TYPE = RECORD[ operator: Operator, charIndex: INTEGER, data: REF ANY ]; Operator: TYPE = {plus, minus, times, divide, leftParen, rightParen, if, then, else, less, lessEqu, gtr, gtrEqu, equ, nEqu, not, and, or, id, number, assign, colon, token, unaryPlus, unaryMinus, binaryPlus, binaryMinus, conditional, parenExp, bad, start, nil, topExp}; AnalyzedExpression: TYPE = RECORD[exp: Expression]; Expression: TYPE = REF ExpressionBody; ExpressionBody: TYPE = RECORD[ operator: Operator, data1: REF ANY, data2: REF ANY ← NIL, data3: REF ANY ← NIL]; ParseExpression: PROCEDURE[Rope.ROPE] RETURNS[Expression]; ParseIdentifier: PROCEDURE[Rope.ROPE] RETURNS[Identifier]; AnalyzeExpression: PROCEDURE[Expression, IdTableSet, DependencySet, --eval action-- Action] RETURNS[AnalyzedExpression]; AnalyzeIdentifier: PROCEDURE[Identifier, IdTableSet, DependencySet, --assign action-- Action] RETURNS[AnalyzedIdentifier]; EvaluateAnalyzedExpression: PROCEDURE[AnalyzedExpression] RETURNS[REAL]; SetAnalyzedIdentifier: PROCEDURE[AnalyzedIdentifier, REAL]; TokenText: PROCEDURE[tkn: Token] RETURNS[Rope.ROPE]; SyntaxError: ERROR[unexpectedToken: Token]; MakeIdTable: PROCEDURE RETURNS[IdTable]; -- following procedures retained for compatability (September 26, 1982 1:51 pm) ParseRope: PROCEDURE[rope: Rope.ROPE] RETURNS[Expression]; RecognizeIdentifiers: PROCEDURE[exp: Expression, ids: IdTable, dSet: DependencySet, eval: Action, assignVal: Action] RETURNS[Expression]; -- in following two procedures (also retained for compatibility), expression must be result of previous call on RecognizeIdentifiers EvaluateExpression: PROCEDURE[Expression] RETURNS[REAL]; AssignVal: PROCEDURE[Expression, REAL]; END.. -- new: July 28, 1982 10:53 am: Sturgis -- remark: July 30, 1982 10:38 am: added TokenText -- change: August 1, 1982 3:14 pm: rename as expressions.mesa, add EvaluateExpression, RecognizeIdentifiers -- change: August 7, 1982 4:15 pm: add IdTables. change: September 26, 1982 1:47 pm: modifications for GCells in which there are multiple tables, and pure expressions are separated from identifiers used for assignment. -- change: July 12, 1984 1:29:53 pm PDT: add the new HCell variety of expresions, in which ids are multi part names pageName.arrayName.id. Also, associate an explicit data item with each identifier, rather than an action. This might simplify some code in the HCells.