BE.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Last Edited by: Louis Monier September 17, 1986 7:24:31 pm PDT
Theory
This interface defines the basic functions for representing Boolean expressions. It does not use any canonical representation and new operators can be registered.
Expressions may be:
variables: any REF. Variables are tested for equality using the REF Equal predicate, apart from ROPEs which compares using Rope.Equal, and REF INT which compares the INTs.
constants among {true, false};
expressions created by registered operators such as Not, And, Or, If, etc ... .
Types and Constants
Expression: TYPE = REF;
Variable: TYPE = REF;
Node: TYPE = REF NodeRec;
NodeRec:
TYPE =
RECORD [
op: Operator,
exprs: SEQUENCE size: NAT OF Expression];
Operator: TYPE = REF OperatorRec;
OperatorRec:
TYPE =
RECORD [
name: Rope.ROPE,
data: REF, -- for example a copy of the celltype to use for layout
evalProc: EvalProc];
true: READONLY Expression;
false: READONLY Expression;
unknown: READONLY Expression;
notOpr, andOpr, orOpr, nandOpr, norOpr, xorOpr, xnorOpr, ifOpr: Operator;
RegisterOp: PROC [name: Rope.ROPE, evalProc: EvalProc] RETURNS [op: Operator];
Basic operations
EvalVar: TYPE = PROC [var: Variable] RETURNS [Expression];
EvalProc: TYPE = PROC [expr: Expression, evalVar: EvalVar] RETURNS [Expression];
FullEval: EvalProc;
returns NIL if unknown
PutExpr:
PROC [out:
IO.
STREAM, expr: Expression, deep:
INT ←
LAST [
INT], putRefAny:
PROC [
IO.
STREAM, Variable] ←
NIL];
Variables which are ROPE or REF INT are handled without calling putRefAny.
GetExpr:
PROC [in:
IO.
STREAM, getRefAny:
PROC [
IO.
STREAM]
RETURNS [Variable] ←
NIL]
RETURNS [expr: Expression];
Variables which are ROPE or REF INT are handled without calling getRefAny
ToRope:
PROC [expr: Expression, deep:
INT ← 5]
RETURNS [Rope.
ROPE];
Short cut for PutExpr
FromRope:
PROC [rope: Rope.
ROPE]
RETURNS [Expression];
Short cut for GetExpr
Most usual Boolean Operators returning Expressions
Not:
PROC [expr: Expression]
RETURNS [Expression];
And: PROC [e1, e2, e3, e4, e5: Expression ← NIL] RETURNS [Expression];
Or: PROC [e1, e2, e3, e4, e5: Expression ← NIL] RETURNS [Expression];
Xor: PROC [e1, e2, e3, e4, e5: Expression ← NIL] RETURNS [Expression];
Nand: PROC [e1, e2, e3, e4, e5: Expression ← NIL] RETURNS [Expression];
Nor:
PROC [e1, e2, e3, e4, e5: Expression ←
NIL]
RETURNS [Expression];
AndList: PROC [exprs: LIST OF Expression] RETURNS [Expression];
OrList: PROC [exprs: LIST OF Expression] RETURNS [Expression];
XorList: PROC [exprs: LIST OF Expression] RETURNS [Expression];
NandList: PROC [exprs: LIST OF Expression] RETURNS [Expression];
NorList:
PROC [exprs:
LIST
OF Expression]
RETURNS [Expression];
If:
PROC [cond, then, else: Expression]
RETURNS [result: Expression];
Useful operator computing: Or[And[cond, then], And[Not[cond], else]].