|
|
@@ -51,9 +51,15 @@ COMPILER M2
|
|
|
init; DISPOSE shallow and nils, deviating from Wirth-undefined);
|
|
|
nil-deref is raw (no check). *)
|
|
|
|
|
|
-IMPORT SymTab, QbeGen;
|
|
|
+IMPORT SymTab, QbeGen, AST;
|
|
|
|
|
|
VAR
|
|
|
+ (* Two-phase frontend (docs/plan-two-phase.md). When TRUE the
|
|
|
+ productions ALSO build AST nodes alongside the legacy emit path.
|
|
|
+ Slice 1: the nodes are inert scaffolding — nothing reads them, so
|
|
|
+ the emitted output is unchanged. *)
|
|
|
+ twoPhase: BOOLEAN;
|
|
|
+
|
|
|
(* Class of the method named by the last `obj.Method` designator
|
|
|
(InvalidType when the callee is an ordinary procedure). Set by
|
|
|
Design, consumed by the following ArgList. *)
|
|
|
@@ -150,7 +156,8 @@ TOKENS
|
|
|
|
|
|
PRODUCTIONS
|
|
|
M2
|
|
|
- = Unit "." .
|
|
|
+ = (. AST.Init; twoPhase := TRUE; .)
|
|
|
+ Unit "." .
|
|
|
(* Units: program modules compile fully; DEFINITION and
|
|
|
IMPLEMENTATION modules parse + check now but lower in step 4
|
|
|
(each ends with one 230); same for nested local modules. *)
|
|
|
@@ -2549,9 +2556,9 @@ PRODUCTIONS
|
|
|
isMax: BOOLEAN;
|
|
|
called, isHigh, sfx, isCh,
|
|
|
isU, uok, isStr: BOOLEAN;
|
|
|
- ucp: INTEGER; .)
|
|
|
+ ucp: INTEGER; astScratch: AST.Node; .)
|
|
|
= integer (. LexString(s);
|
|
|
- QbeGen.NormInt(s, q);
|
|
|
+ QbeGen.NormInt(s, q); IF twoPhase THEN astScratch := AST.MakeLeaf(AST.NkIntLit, s) END;
|
|
|
t := SymTab.IntType(); .)
|
|
|
| charConst (. LexString(s);
|
|
|
QbeGen.NormLit(s, q, isCh);
|