HerculesParseViewer
Last Edited by: Stolfi, February 22, 1984 12:16 pm
Copied from OldParseWindow
Coded by GNelson (?) September 6, 1982 12:25 am
Last Edited by: Gnelson, October 11, 1983 9:29 pm
DIRECTORY
Atom,
ViewerClasses,
Parser,
Rope;
HerculesParseViewer: DEFINITIONS
= BEGIN
ROPE: TYPE = Rope.ROPE;
PViewer: TYPE = RECORD
[oldContents: LIST OF ROPE ← NIL, -- contents of nodes after last parse/unparse of viewer
viewer: ViewerClasses.Viewer];
NewViewer: PUBLIC PROC RETURNS [pv: PViewer];
-- Creates a new empty and unnamed editable viewer for Juno procedures.
AddText: PUBLIC PROC[text: ROPE, pv: PViewer];
-- Adds a new last node to the viewer, with given contents.
-- does not parse the viewer or alter pw.content. The idea is that the text
-- will have fields to be filled in by the user.
AddExpr: PUBLIC PROC[expr: Se, viewer: PViewer];
-- unparses the expression, adds the text, and repaints the viewer.
ParseViewer: PUBLIC PROC [pv: PViewer]
RETURNS [exprs: LIST OF Se, error: BOOL, nv: PViewer];
-- Parses each node of pv that has been edited since last parse,
-- according to the Juno syntax, and checks if the resulting tree
-- is a valid definition of the form (<is> <name> <expr>), where <expr>
-- evaluates to a value (generally a FunVal).
-- Also unparses each expresssion and puts it back into the viewer.
-- In case of parsing/syntax error, stops the process and
-- returns error = TRUE. The offending expression will be unparsed up to the
-- error, and the rest of the original node contents will be appended to it.
-- Will NOT re-parse nodes that have not been edited since last parse of this file.
SetFile: PUBLIC PROC [v: ViewerfileName: ROPE];
-- Loads specified file into viewer v.
END.