--September 6, 1982 12:25 am
-- OldParseWindow.mesa
-- Last Edited by: Gnelson, October 11, 1983 9:29 pm

DIRECTORY Atom, ViewerClasses, Parser, Rope;

OldParseWindow: DEFINITIONS
= BEGIN

ROPE: TYPE = Rope.ROPE;

Handle: TYPE = REF HandleRep;

NewHandle: PROC [v: ViewerClasses.Viewer]
          RETURNS [h: Handle];

HandleRep: TYPE = RECORD [
  ph: Parser.Handle, 
  viewer: ViewerClasses.Viewer,
  WellFormed: SyntacticPredicate,
  content: LIST OF NodeContent,
  contentValid: BOOL];

NodeContent: TYPE = RECORD [text1: ROPE, text2: ROPE, tree: REF ANY];

SyntacticPredicate: TYPE = 
  PROC [f: REF ANY] RETURNS [VerdictAndCulprit];

VerdictAndCulprit: TYPE = 
 RECORD [verdict: Verdict, culprit: REF ANY];  
 -- culprit relevant only if verdict is No or OfCourseNot

Verdict: TYPE = {Yes, No, OfCourseNot}; -- Yes == innocent

HasForm: PROC[f: REF ANY, 
                   op: ATOM, 
                   Arg1: SyntacticPredicate, 
                   Arg2: SyntacticPredicate ← NIL] 
     RETURNS [VerdictAndCulprit];
     
-- HasForm tests if Car[f] is of the form (op x y) where x is  
-- of the form Arg1 and y is of the form Arg2,
-- unless Arg2 = NIL in which case the test is for the 
-- form (op x).  It is assumed that Arg1 # NIL and
-- (Arg1 = NIL => Arg2 = NIL).

Or: PROC [aw1, aw2: VerdictAndCulprit] 
    RETURNS [r: VerdictAndCulprit];

ParseViewer:  PUBLIC PROC [pw: Handle];

AddTree: PUBLIC PROC[pw: Handle, tree: REF];
-- unparses the tree, adds the text, and repaints the viewer.

AddText: PUBLIC PROC[pw: Handle, text1: ROPE, text2: ROPE];
-- adds a new last node to the viewer, with header text1 and body text2.
-- does not parse the viewer or alter pw.content.  The idea is that text1 and
-- text2 will have fields to be filled in by the user. 


AddOp: PROC[
          h: Handle, 
          op: ROPE, 
          alias: ROPE, -- alternate form; op is preferred
          bp: INTEGER,  
          f: OperatorType, 
          c: ROPE,
          u: INT ← 0];

OperatorType: TYPE = {infix, matchfix, subfixMatchfix, prefix, infixPrefix, closefix};
  
END.