UnpList:
--recursive--
PROC [l:
LIST
OF
REF
ANY,
uncle:
REF
ANY,
p:
PT.Handle,
openCount:
INT] =
{op: REF ANY = l;
arg1: REF ANY = l.rest;
arg2: REF ANY = l.rest.rest;
opType: PT.Properties = p.Search[NARROW[op, LIST OF REF ANY].first, NIL];
type: INT ← opType.unparserType;
SELECT TRUE FROM
type = 1 AND arg2 # NIL
=> {UB.Setb[];
Unp[arg1, NIL, p, 0];
UB.Charb[' ];
UB.Bp[TRUE, 0];
Unp[op, NIL, p, 0];
UB.Charb[' ];
Unp[arg2, NIL, p, openCount];
UB.Endb[]};
type = 4 AND arg2 # NIL
=> {IF uncle = NIL OR Car[op] # Car[uncle] THEN UB.Setb[];
Unp[arg1, NIL, p, 0];
Unp[op, NIL, p, 0];
UB.Bp[FALSE, -1];
UB.Charb[' ];
Unp[arg2, op, p, openCount];
IF uncle = NIL OR Car[op] # Car[uncle] THEN UB.Endb[]};
type = 6 AND arg2 = NIL
=> {Unp[op, NIL, p, 0];
Unp[arg1, NIL, p, openCount - 1];
IF openCount <= 0 THEN UB.Atomb[opType.closer.name]};
type = 6 AND arg2 # NIL
=> {UB.Setb[];
Unp[arg1, NIL, p, 0];
UB.Bp[TRUE, - 1 - Atom.GetPName
[NARROW[NARROW[op, LIST OF REF ANY].first, ATOM]].Length];
Unp[op, NIL, p, 0];
Unp[arg2, NIL, p, openCount - 1];
IF openCount <= 0 THEN UB.Atomb[opType.closer.name];
UB.Endb[]};
type = 7 AND arg2 # NIL
=> {IF uncle = NIL OR Car[op] # Car[uncle] THEN UB.Setb[];
Unp[arg1, NIL, p, 0];
UB.Bp[TRUE, - 1 - Atom.GetPName
[NARROW[NARROW[op, LIST OF REF ANY].first, ATOM]].Length];
Unp[op, NIL, p, 0];
UB.Charb[' ];
Unp[arg2, op, p, openCount];
IF uncle = NIL OR Car[op] # Car[uncle] THEN UB.Endb[]};
type = 8 AND arg2 # NIL
=> {UB.Setb[];
Unp[arg1, NIL, p, 0];
UB.Charb[' ];
Unp[op, NIL, p, 0];
UB.Charb[' ];
UB.Bp[FALSE, 0];
Unp[arg2, op, p, openCount];
UB.Endb[]};
opType.infix AND arg2 # NIL
=> {IF uncle = NIL OR Car[op] # Car[uncle] THEN UB.Setb[];
Unp[arg1, NIL, p, 0];
UB.Bp[TRUE, - 2 - Atom.GetPName
[NARROW[NARROW[op, LIST OF REF ANY].first, ATOM]].Length];
UB.Charb[' ];
Unp[op, NIL, p, 0];
UB.Charb[' ];
Unp[arg2, op, p, openCount];
IF uncle = NIL OR Car[op] # Car[uncle] THEN UB.Endb[]};
opType.matchfix AND arg2 = NIL
=> {Unp[op, NIL, p, 0];
UB.Charb[' ];
Unp[arg1, NIL, p, openCount - 1];
IF openCount <= 0 THEN {UB.Charb[' ];
UB.Atomb[opType.closer.name]}};
opType.prefix AND arg2 = NIL
=> {Unp[op, NIL, p, 0];
UB.Charb[' ];
Unp[arg1, NIL, p, openCount]};
opType.postfix AND arg2 = NIL
=> {Unp[arg1, NIL, p, openCount];
UB.Charb[' ];
Unp[op, NIL, p, 0]};
opType.subfix AND arg2 # NIL
=> {UB.Setb[];
Unp[arg1, NIL, p, 0];
UB.Charb[' ];
UB.Bp[TRUE, - 2 - Atom.GetPName
[NARROW[NARROW[op, LIST OF REF ANY].first, ATOM]].Length];
Unp[op, NIL, p, 0];
UB.Charb[' ];
Unp[arg2, NIL, p, openCount - 1];
UB.Charb[' ];
IF openCount <= 0 THEN UB.Atomb[opType.closer.name];
UB.Endb[]};
opType.busfix AND arg2 # NIL
=> {Unp[op, NIL, p, 0];
UB.Setb[];
UB.Charb[' ];
Unp[arg1, NIL, p, 0];
UB.Charb[' ];
UB.Bp[TRUE, - Atom.GetPName[opType.closer.name].Length];
UB.Atomb[opType.closer.name];
UB.Charb[' ];
Unp[arg2, NIL, p, openCount];
UB.Endb[]};
ENDCASE => ERROR Error};