EBLanguage.mesa
Copyright Ó 1989, 1991, 1992 by Xerox Corporation. All rights reserved.
Goodisman, August 16, 1989 4:54:50 pm PDT
Bier, August 28, 1991 1:29 pm PDT
Doug Wyatt, April 10, 1992 6:56 pm PDT
Contents: parser, unparser, evaluator, and some convenience routine for the EmbeddedButtons language (a lisp-like, not-turing equivalent language).
DIRECTORY
IO, EBTypes, RefTab, Rope;
EBLanguage: CEDAR DEFINITIONS = BEGIN
ButtonInfo: TYPE = EBTypes.ButtonInfo;
Context: TYPE = EBTypes.Context;
ROPE: TYPE = Rope.ROPE;
EBLanguageProc: TYPE = EBTypes.EBLanguageProc;
Produces a printed representation of the object.
If object is a list, uses the prettyPrintList to pretty print the object. The first item in the list is a rope to be inserted before every top level object in the list. The second item in this list is a boolean specifying if the rope should be inserted before the first item. The third and fourth items in the list are for the second level, etc.
PoppyParse: PROC [stream: IO.STREAM] RETURNS [symbols: RefTab.Ref, order: LIST OF ATOM];
Parses expressions in the Poppy Language, and stores name value pairs in "symbols". For example, this expression binds values for the names ButtonClass, Menu, MessageHandler, and Feedback:
ButtonClass: PopUpButton
Menu: (
(Event1 "First Item" "Sends Event1 to application")
((Event2 Arg2) "Second Item" "Sends Event2 to application")
((Event3 <GetVal>) "Third Item" "Sends Event3 to application")
)
MessageHandler: MessageWindow
Feedback: (
(MouseMoved <SetCursor bullseye>)
)
PoppyParseFieldNames: PROC [stream: IO.STREAM] RETURNS [symbols: RefTab.Ref, order: LIST OF ATOM];
Records the poppy keywords in the symbol table and associates each one with a ROPE representing the value. Use PoppyParseFieldValues to parse the values. PoppyParseFieldNames followed by PoppyParseFieldValues is equivalent to PoppyParse.
PoppyParseFieldValues: PROC [symbols: RefTab.Ref];
For each key-value pair in symbols that has a ROPE value, parse that value based on the parsing routines registered for that key. Used after PoppyParseFieldNames to complete a two-step (lazy evaluation) parse. Returns ERROR ERROR is some key has a non-rope value.
PoppyUnparse: PROC [symbols: RefTab.Ref, order: LIST OF ATOM] RETURNS [result: ROPE];
Produces a printed representation of the name-value pairs in "symbols" using the Poppy Language.
FieldParseProc: TYPE = PROC [stream: IO.STREAM] RETURNS [val: REF];
RegisterFieldParseProc: PROC [fieldName: ATOM, parseProc: FieldParseProc];
FieldUnparseProc: TYPE = PROC[val: REF] RETURNS [rope: ROPE];
RegisterFieldUnparseProc: PROC [fieldName: ATOM, unparseProc: FieldUnparseProc];
VariableType: TYPE = REF VariableTypeObj;
VariableTypeObj: TYPE = RECORD [
class: {boolean, atom, rope, integer, real, enumerated},
enumeration: SEQUENCE count: NAT OF REF ANY
];
VariableTable: TYPE = RefTab.Ref;
Variable: TYPE = REF VariableObj;
VariableObj: TYPE = RECORD [
type: VariableType,
value: REF
];
CreateVariableTable: PROC [] RETURNS [table: VariableTable];
GetVariable: PROC [table: VariableTable, name: ATOM] RETURNS [variable: Variable];
Gets the value and type of the named variable from the variable table.
SetVariable: PROC [table: VariableTable, name: ATOM, variable: Variable];
Sets the value and type of the named variable in the variable table.
DeleteVariable: PROC [table: VariableTable, name: ATOM] RETURNS [existed: BOOL ¬ FALSE];
Deletes the named variable from the table.
Short for "IO.SkipWhitespace[...]; ReadWord[f]"
GetFieldRope: PROC [symbols: RefTab.Ref, key: ATOM] RETURNS [rope: ROPE];
GetFieldAtom: PROC [symbols: RefTab.Ref, key: ATOM] RETURNS [atom: ATOM];
GetFieldRef: PROC [symbols: RefTab.Ref, key: ATOM] RETURNS [ref: REF];
SetFieldRope: PROC [symbols: RefTab.Ref, order: LIST OF ATOM, key: ATOM, rope: ROPE];
SetFieldAtom: PROC [symbols: RefTab.Ref, order: LIST OF ATOM, key: ATOM, atom: ATOM];
SetFieldRef: PROC [symbols: RefTab.Ref, order: LIST OF ATOM, key: ATOM, ref: REF];
Equal: PROC [o1, o2: REF ANY] RETURNS [result: BOOL ¬ FALSE];
If o1 and o2 are types produced by Parse, checks if they are equal.
EqualInt: PROC [o1: REF ANY, o2: INT] RETURNS[result: BOOL ¬ FALSE];
EqualBool: PROC [o1: REF ANY, o2: BOOL] RETURNS[result: BOOL ¬ FALSE];
RegisterProc: PROC [name: ATOM, proc: EBLanguageProc, interpreted: BOOL ¬ TRUE];
Registers a name-proc pair for use in evaluation.
Evaluate: PROC [expression: REF, buttonInfo: ButtonInfo, clientData: REF ¬ NIL, context: Context ¬ NIL] RETURNS [REF ANY];
If the object is a procedure call, looks up the procedure and calls it, evaluating arguments first, if topOnly is FALSE. Otherwise, if topOnly is FALSE, evaluates every item in the list.
AddEntity: PROC [entity: REF ANY, entityList, ptr: LIST OF REF ANY] RETURNS [newList, newPtr: LIST OF REF ANY];
Adds the entity to the end of the list, returning the new tail pointer. Good for list construction.
CreateContext: PROC [] RETURNS [context: Context];
GetSystemValue: PROC [context: Context, name: ATOM] RETURNS [value: REF];
SetSystemValue: PROC [context: Context, name: ATOM, value: REF];
END.