SELECT entry.class
FROM
boolean => {
IO.PutF[aux, Nest["", 1]];
IO.PutF[aux, "Expose%g: PUBLIC PROC [p: %g, level: NAT] RETURNS [x: ROPE] ~ {",
IO.rope[item],
IO.rope[item]
];
IO.PutF[aux, Nest["", 2]];
IO.PutF[aux, Nest["x ← \"%g(\"", 2],
IO.rope[item]
];
IO.PutF[aux, Nest["x ← Rope.Concat[x, Convert.RopeFromBool[p]];", 2]];
IO.PutF[aux, Nest["x ← Rope.Concat[x, \")\"];", 2]];
IO.PutF[aux, Nest["};", 1]];
};
cardinal => {
IO.PutF[aux, Nest["", 1]];
IO.PutF[aux, "Expose%g: PUBLIC PROC [p: %g, level: NAT] RETURNS [x: ROPE] ~ {",
IO.rope[item],
IO.rope[item]
];
IO.PutF[aux, Nest["", 2]];
IO.PutF[aux, Nest["x ← \"%g(\"", 2],
IO.rope[item]
];
IO.PutF[aux, Nest["x ← Rope.Concat[x, Convert.RopeFromCard[p]];", 2]];
IO.PutF[aux, Nest["x ← Rope.Concat[x, \")\"];", 2]];
IO.PutF[aux, Nest["};", 1]];
};
integer => {
IO.PutF[aux, Nest["", 1]];
IO.PutF[aux, "Expose%g: PUBLIC PROC [p: %g, level: NAT] RETURNS [x: ROPE] ~ {",
IO.rope[item],
IO.rope[item]
];
IO.PutF[aux, Nest["", 2]];
IO.PutF[aux, Nest["x ← \"%g(\"", 2],
IO.rope[item]
];
IO.PutF[aux, Nest["x ← Rope.Concat[x, Convert.RopeFromInt[p]];", 2]];
IO.PutF[aux, Nest["x ← Rope.Concat[x, \")\"];", 2]];
IO.PutF[aux, Nest["};", 1]];
};
longCardinal => {
IO.PutF[aux, Nest["", 1]];
IO.PutF[aux, "Expose%g: PUBLIC PROC [p: %g, level: NAT] RETURNS [x: ROPE] ~ {",
IO.rope[item],
IO.rope[item]
];
IO.PutF[aux, Nest["", 2]];
IO.PutF[aux, Nest["x ← \"%g(\"", 2],
IO.rope[item]
];
IO.PutF[aux, Nest["x ← Rope.Concat[x, Convert.RopeFromCard[p]];", 2]];
IO.PutF[aux, Nest["x ← Rope.Concat[x, \")\"];", 2]];
IO.PutF[aux, Nest["};", 1]];
};
longInteger => {
IO.PutF[aux, Nest["", 1]];
IO.PutF[aux, "Expose%g: PUBLIC PROC [p: %g, level: NAT] RETURNS [x: ROPE] ~ {",
IO.rope[item],
IO.rope[item]
];
IO.PutF[aux, Nest["", 2]];
IO.PutF[aux, Nest["x ← \"%g(\"", 2],
IO.rope[item]
];
IO.PutF[aux, Nest["x ← Rope.Concat[x, Convert.RopeFromInt[p]];", 2]];
IO.PutF[aux, Nest["x ← Rope.Concat[x, \")\"];", 2]];
IO.PutF[aux, Nest["};", 1]];
};
string => {
IO.PutF[aux, Nest["", 1]];
IO.PutF[aux, "Expose%g: PUBLIC PROC [p: %g, level: NAT] RETURNS [x: ROPE] ~ {",
IO.rope[item],
IO.rope[item]
];
IO.PutF[aux, Nest["", 2]];
IO.PutF[aux, Nest["x ← \"%g(\"", 2],
IO.rope[item]
];
IO.PutF[aux, Nest["x ← Rope.Concat[x, Convert.RopeFromRope[p]];", 2]];
IO.PutF[aux, Nest["x ← Rope.Concat[x, \")\"];", 2]];
IO.PutF[aux, Nest["};", 1]];
};
unspecified => {
IO.PutF[aux, Nest["", 1]];
IO.PutF[aux, "Expose%g: PUBLIC PROC [p: %g, level: NAT] RETURNS [x: ROPE] ~ {",
IO.rope[item],
IO.rope[item]
];
IO.PutF[aux, Nest["", 2]];
IO.PutF[aux, Nest["x ← \"%g(\"", 2],
IO.rope[item]
];
IO.PutF[aux, Nest["x ← Rope.Concat[x, Convert.RopeFromCard[p]];", 2]];
IO.PutF[aux, Nest["x ← Rope.Concat[x, \")\"];", 2]];
IO.PutF[aux, Nest["};", 1]];
};
enumeration => {
elementList: CComponent ← entry.children;
IO.PutF[aux, Nest["", 1]];
IO.PutF[aux, "Expose%g: PUBLIC PROC [e: %g, level: NAT] RETURNS [x: ROPE] ~ {",
IO.rope[item],
IO.rope[item]
];
IO.PutF[aux, Nest["", 2]];
IO.PutF[aux, Nest["SELECT e FROM", 3]];
WHILE (elementList #
NIL)
DO
IO.PutF[aux, Nest["%g => x ← \"%g\";", 3],
IO.rope[elementList.name],
IO.rope[elementList.name]
];
elementList ← elementList.sibling;
ENDLOOP;
IO.PutF[aux, Nest["ENDCASE => x ← \"unknown %g\";", 2],
IO.rope[item]
];
IO.PutF[aux, Nest["};", 1]];
};
array => {
name: ROPE ← "a[i]";
IO.PutF[aux, Nest["", 1]];
IO.PutF[aux, "Expose%g: PUBLIC PROC [a: %g, level: NAT] RETURNS [x: ROPE] ~ {",
IO.rope[item],
IO.rope[item]
];
IO.PutF[aux, Nest["", 2]];
IO.PutF[aux, Nest["x ← \"%g: [\";", 2],
IO.rope[item]
];
IO.PutF[aux, Nest["FOR i: CARDINAL IN [0..%g) DO", 3],
IO.card[(entry.bound-1)]
];
IO.PutF[aux, Nest["x ← Rope.Concat[x, %g];", 3],
IO.rope[RecursiveItem[h, name, entry.children.type, programKeyWD]]
];
IO.PutF[aux, Nest["x ← Rope.Concat[x, \", \"];", 3]];
IO.PutF[aux, Nest["ENDLOOP;", 2]];
name ← IO.PutFR["a[%g]", IO.card[(entry.bound-1)]];
IO.PutF[aux, Nest["x ← Rope.Concat[x, %g];", 2],
IO.rope[RecursiveItem[h, name, entry.children.type, programKeyWD]]
];
IO.PutF[aux, Nest["x ← Rope.Concat[x, \"]\"];", 2]];
IO.PutF[aux, Nest["};", 1]];
};
choice => {
name: ROPE ← "c.type";
tag: CComponent ← entry.children;
variantList: CComponent ← entry.children.sibling; -- skipping tag item
IO.PutF[aux, Nest["", 1]];
IO.PutF[aux, "Expose%g: PUBLIC PROC [c: %g, level: NAT] RETURNS [x: ROPE] ~ {",
IO.rope[item],
IO.rope[item]
];
IO.PutF[aux, Nest["", 2]];
IO.PutF[aux, Nest["x ← \"%g(\";", 2],
IO.rope[item]
];
IO.PutF[aux, Nest["x ← Rope.Concat[x, %g];", 2],
IO.rope[RecursiveItem[h, name, tag.type, programKeyWD]]
];
IO.PutF[aux, Nest["x ← Rope.Concat[x, \"): \"];", 2]];
IO.PutF[aux, Nest["WITH c SELECT FROM", 3]];
WHILE (variantList #
NIL)
DO
IO.PutF[aux, Nest["v: %g %g => {", 4],
IO.rope[variantList.name],
IO.rope[item]
];
name ← IO.PutFR["v.%g", IO.rope[variantList.name]];
IO.PutF[aux, Nest["x ← Rope.Concat[x, %g];", 4],
IO.rope[RecursiveItem[h, name, variantList.type, programKeyWD]]
];
IO.PutF[aux, Nest["};", 3]];
variantList ← variantList.sibling;
ENDLOOP;
IO.PutF[aux, Nest["ENDCASE => { x ← Rope.Concat[x, \"Unknown\"]; };", 2]];
IO.PutF[aux, Nest["};", 1]];
};
record => {
name: ROPE ← "r.foo";
fieldList: CComponent ← entry.children;
Handle Empty Record as a special case because of compiler bug
IF (fieldList =
NIL)
THEN {
IO.PutF[aux, Nest["", 1]];
IO.PutF[aux, "Expose%g: PUBLIC PROC [--r: %g,-- level: NAT] RETURNS [x: ROPE] ~ {",
IO.rope[item],
IO.rope[item]
];
IO.PutF[aux, Nest["", 2]];
IO.PutF[aux, Nest["x ← \"[\";", 2]];
IO.PutF[aux, Nest["x ← Rope.Concat[x, \"]\"];", 2]];
IO.PutF[aux, Nest["};", 1]];
RETURN;
};
IO.PutF[aux, Nest["", 1]];
IO.PutF[aux, "Expose%g: PUBLIC PROC [r: %g, level: NAT] RETURNS [x: ROPE] ~ {",
IO.rope[item],
IO.rope[item]
];
IO.PutF[aux, Nest["", 2]];
IO.PutF[aux, Nest["x ← \"[\";", 2]];
WHILE (fieldList.sibling #
NIL)
DO
IO.PutF[aux, Nest["x ← Rope.Concat[x, \"%g: \"];", 2],
IO.rope[fieldList.name]
];
name ← IO.PutFR["r.%g", IO.rope[fieldList.name]];
IO.PutF[aux, Nest["x ← Rope.Concat[x, %g];", 2],
IO.rope[RecursiveItem[h, name, fieldList.type, programKeyWD]]
];
fieldList ← fieldList.sibling;
ENDLOOP;
IO.PutF[aux, Nest["x ← Rope.Concat[x, \", \"];", 2]];
IO.PutF[aux, Nest["x ← Rope.Concat[x, \"%g: \"];", 2],
IO.rope[fieldList.name]
];
name ← IO.PutFR["r.%g", IO.rope[fieldList.name]];
IO.PutF[aux, Nest["x ← Rope.Concat[x, %g];", 2],
IO.rope[RecursiveItem[h, name, fieldList.type, programKeyWD]]
];
IO.PutF[aux, Nest["x ← Rope.Concat[x, \"]\"];", 2]];
IO.PutF[aux, Nest["};", 1]];
};
sequence => {
name: ROPE ← "s[i]";
IO.PutF[aux, Nest["", 1]];
IO.PutF[aux, "Expose%g: PUBLIC PROC [s: %g, level: NAT] RETURNS [x: ROPE] ~ {",
IO.rope[item],
IO.rope[item]
];
IO.PutF[aux, Nest["", 2]];
IO.PutF[aux, Nest["x ← \"%g: [\";", 2],
IO.rope[item],
];
IO.PutF[aux, Nest["FOR i: CARDINAL IN [0..s.length) DO", 3]];
IO.PutF[aux, Nest["x ← Rope.Concat[x, \"\\n\"];", 3]];
IO.PutF[aux, Nest["FOR i: CARDINAL IN [0..2*level) DO x ← Rope.Concat[x, \" \"]; ENDLOOP;", 3]];
IO.PutF[aux, Nest["x ← Rope.Concat[x, \"(\"];", 3]];
IO.PutF[aux, Nest["x ← Rope.Concat[x, Convert.RopeFromCard[i]];", 3]];
IO.PutF[aux, Nest["x ← Rope.Concat[x, \") \"];", 3]];
IO.PutF[aux, Nest["x ← Rope.Concat[x, %g];", 3],
IO.rope[RecursiveItem[h, name, entry.children.type, programKeyWD]]
];
IO.PutF[aux, Nest["ENDLOOP;", 2]];
IO.PutF[aux, Nest["x ← Rope.Concat[x, \"]\"];", 2]];
IO.PutF[aux, Nest["};", 1]];
};
error => { NULL }; -- always a constant!
procedure => { NULL }; -- always a constant!