From a417225089fd78d53d73ad63cd79f57d1a4a8ff1 Mon Sep 17 00:00:00 2001 From: Vladimir Azarov Date: Fri, 8 Aug 2025 19:07:58 +0200 Subject: Register allocation --- parser.fun | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'parser.fun') diff --git a/parser.fun b/parser.fun index 9e36f2c..0948305 100644 --- a/parser.fun +++ b/parser.fun @@ -178,6 +178,7 @@ functor Parser(structure Tree: TREE; structure P: PPC; StmtDoWhile of stmt * exprAug | StmtReturn of exprAug option | StmtBreak | + StmtNone | StmtContinue datatype parseBinopRes = BRbinop of exprPart | BRfinish of int @@ -3046,7 +3047,7 @@ functor Parser(structure Tree: TREE; structure P: PPC; lx end) - | _ => raise Unimplemented + | _ => raise Unreachable end fun printOffsets (LcAux (offset, l)) out = @@ -3467,6 +3468,7 @@ functor Parser(structure Tree: TREE; structure P: PPC; | Tk T.kwBreak => parseJmp StmtBreak | Tk T.kwContinue => parseJmp StmtContinue | Tk T.kwReturn => parseReturn ctx + | Tk T.Semicolon => (StmtNone, #3 $ getTokenCtx ctx) | _ => parseStmtExpr ctx end @@ -3670,8 +3672,12 @@ functor Parser(structure Tree: TREE; structure P: PPC; | _ => let val (stmt, ctx) = parseStmt ctx + val acc = + case stmt of + StmtNone => acc + | _ => stmt :: acc in - collectStmts (stmt :: acc) ctx + collectStmts acc ctx end end @@ -3723,6 +3729,7 @@ functor Parser(structure Tree: TREE; structure P: PPC; Printf out `"return " Popt pea ea `";" % | pstmt' _ StmtBreak out = Printf out `"break;" % | pstmt' _ StmtContinue out = Printf out `"continue;" % + | pstmt' _ StmtNone _ = raise Unreachable and pCompBody off (S as (StmtCompound _)) out = Printf out A2 pstmt' (off - 1) S % -- cgit v1.2.3