INTERFACEProvides procedures for unparsing Juno modules, top-level module blocks, commands, and expressions. A number of valid tokens may be specified so that incorrect programs may be unparsed up to the point of failure.JunoUnparse ;
Each of these procedures unparses some subtype of JunoAST.T to a writer
wr at an initial indentation level of indent to a maximum width of
width characters. Those procedures taking a tokens argument unparse at
most the specified number of tokens. In all cases, the writer is left
positioned just after the last character of the last token written; no
new-line is appended.
Those procedures that take a private argument will supress the unparsing
of public predicate, function, and procedure bodies when private = FALSE.
For each of the unparsing procedures, a TRUE value for debug will cause
AST's to be printed out with debugging information. In particular, variable
indices will be added.
IMPORT JunoAST, Wr, Formatter, Real AS R;
CONST Prec: CARDINAL = R.MaxSignifDigits - 1;
PROCEDURE Block(wr: Wr.T; ast: JunoAST.Block; tokens: CARDINAL;
indent: CARDINAL := 0; width: CARDINAL := 75; prec := Prec;
debug := FALSE; private := TRUE) RAISES {Wr.Failure};
PROCEDURE Cmd(wr: Wr.T; ast: JunoAST.Cmd; tokens: CARDINAL;
indent: CARDINAL := 0; width: CARDINAL := 75; prec := Prec; debug := FALSE)
RAISES {Wr.Failure};
PROCEDURE Expr(wr: Wr.T; ast: JunoAST.Expr; tokens: CARDINAL;
indent: CARDINAL := 0; width: CARDINAL := 75; prec := Prec; debug := FALSE)
RAISES {Wr.Failure};
PROCEDURE P(wr: Wr.T; ast: JunoAST.T; indent: CARDINAL := 0;
width: CARDINAL := 75; prec := Prec; debug := FALSE; private := TRUE;
errast: JunoAST.T := NIL) RAISES {Wr.Failure};
ProcedurePwill unparse any kind of AST, so long as it does not contain a parse error. If an ``error AST'' is supplied, the characters\001and\002will be placed in the output stream to delimit the extent of the error AST.
PROCEDURE ToFmt(fmt: Formatter.T; ast: JunoAST.T; indent: CARDINAL := 0;
prec := Prec; debug := FALSE; private := TRUE; errast: JunoAST.T := NIL)
RAISES {Wr.Failure};
LikePabove, but the output is written to the formatterf. The formatter is flushed but not closed at the end of this procedure.
PROCEDURE Debug(r: REFANY);
Unparse theJunoAST.TorJunoValue.Trto stderr. Real numbers are unparsed toPrecprecision.
END JunoUnparse.