From 7e20a3b1bdc1a3d26b13c2597d0286c79851e9ac Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Fri, 9 Feb 2024 15:42:43 -0800 Subject: [Parser] Parse `resume` (#6295) --- src/parser/parsers.h | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src/parser/parsers.h') diff --git a/src/parser/parsers.h b/src/parser/parsers.h index db4c716f1..960ccb26d 100644 --- a/src/parser/parsers.h +++ b/src/parser/parsers.h @@ -1228,7 +1228,7 @@ template MaybeResult catchinstr(Ctx& ctx) { return result; } -// trytable ::= 'try_table' label blocktype catchinstr* instr* end id? +// trytable ::= 'try_table' label blocktype catchinstr* instr* 'end' id? // | '(' 'try_table' label blocktype catchinstr* instr* ')' template MaybeResult<> trytable(Ctx& ctx, bool folded) { auto pos = ctx.in.getPos(); @@ -1992,8 +1992,24 @@ template Result<> makeStringSliceIter(Ctx& ctx, Index pos) { return ctx.makeStringSliceIter(pos); } +// resume ::= 'resume' typeidx ('(' 'tag' tagidx labelidx ')')* template Result<> makeResume(Ctx& ctx, Index pos) { - return ctx.in.err("unimplemented instruction"); + auto type = typeidx(ctx); + CHECK_ERR(type); + + auto tagLabels = ctx.makeTagLabelList(); + while (ctx.in.takeSExprStart("tag"sv)) { + auto tag = tagidx(ctx); + CHECK_ERR(tag); + auto label = labelidx(ctx); + CHECK_ERR(label); + ctx.appendTagLabel(tagLabels, *tag, *label); + if (!ctx.in.takeRParen()) { + return ctx.in.err("expected ')' at end of handler clause"); + } + } + + return ctx.makeResume(pos, *type, tagLabels); } // ======= -- cgit v1.2.3