fix: parsing diverts within content
This commit is contained in:
parent
2ee43514b4
commit
066369cc13
4 changed files with 45 additions and 6 deletions
|
|
@ -1077,6 +1077,7 @@ fn content(block: *GenIr, scope: *Scope, node: *const Ast.Node) InnerError!Ir.In
|
||||||
.multi_if_stmt => _ = try multiIfStmt(block, scope, child_node),
|
.multi_if_stmt => _ = try multiIfStmt(block, scope, child_node),
|
||||||
.switch_stmt => _ = try switchStmt(block, scope, child_node),
|
.switch_stmt => _ = try switchStmt(block, scope, child_node),
|
||||||
.inline_if_stmt => _ = try inlineIfStmt(block, scope, child_node),
|
.inline_if_stmt => _ = try inlineIfStmt(block, scope, child_node),
|
||||||
|
.divert_expr => _ = try divertExpr(block, scope, child_node),
|
||||||
else => unreachable,
|
else => unreachable,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -785,6 +785,9 @@ fn parseIdentifierExpr(p: *Parse) Error!*Ast.Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parseDivertExpr(p: *Parse) Error!*Ast.Node {
|
fn parseDivertExpr(p: *Parse) Error!*Ast.Node {
|
||||||
|
try p.pushGrammar(.expression);
|
||||||
|
defer p.popGrammar();
|
||||||
|
|
||||||
const main_token = p.nextToken();
|
const main_token = p.nextToken();
|
||||||
const node = try parseIdentifierExpr(p);
|
const node = try parseIdentifierExpr(p);
|
||||||
return .createBinary(p.arena, .divert_expr, .{
|
return .createBinary(p.arena, .divert_expr, .{
|
||||||
|
|
@ -794,9 +797,6 @@ fn parseDivertExpr(p: *Parse) Error!*Ast.Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parseDivertStmt(p: *Parse) Error!*Ast.Node {
|
fn parseDivertStmt(p: *Parse) Error!*Ast.Node {
|
||||||
try p.pushGrammar(.expression);
|
|
||||||
defer p.popGrammar();
|
|
||||||
|
|
||||||
const main_token = p.token;
|
const main_token = p.token;
|
||||||
const node = try parseDivertExpr(p);
|
const node = try parseDivertExpr(p);
|
||||||
_ = try p.expectNewline();
|
_ = try p.expectNewline();
|
||||||
|
|
@ -980,7 +980,7 @@ fn parseContent(p: *Parse, options: ContentOptions) Error!?*Ast.Node {
|
||||||
const node: ?*Ast.Node = switch (p.token.tag) {
|
const node: ?*Ast.Node = switch (p.token.tag) {
|
||||||
.eof, .newline, .left_arrow, .right_brace => break,
|
.eof, .newline, .left_arrow, .right_brace => break,
|
||||||
.left_brace => try parseLbraceExpr(p),
|
.left_brace => try parseLbraceExpr(p),
|
||||||
.right_arrow => try parseDivertStmt(p),
|
.right_arrow => try parseDivertExpr(p),
|
||||||
.glue => blk: {
|
.glue => blk: {
|
||||||
while (true) {
|
while (true) {
|
||||||
_ = p.nextToken();
|
_ = p.nextToken();
|
||||||
|
|
|
||||||
|
|
@ -119,10 +119,26 @@ test "fixture - I042 (Weave options)" {
|
||||||
try testRuntimeFixture("I042");
|
try testRuntimeFixture("I042");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "fixture - I046 (Left right glue matching)" {
|
||||||
|
try testRuntimeFixture("I046");
|
||||||
|
}
|
||||||
|
|
||||||
|
test "fixture - I048 (Simple glue)" {
|
||||||
|
try testRuntimeFixture("I048");
|
||||||
|
}
|
||||||
|
|
||||||
test "fixture - I051 (String constants)" {
|
test "fixture - I051 (String constants)" {
|
||||||
try testRuntimeFixture("I051");
|
try testRuntimeFixture("I051");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "fixture - I055 (Same line divert is inline)" {
|
||||||
|
try testRuntimeFixture("I055");
|
||||||
|
}
|
||||||
|
|
||||||
|
test "fixture - I061 (Divert in conditional)" {
|
||||||
|
try testRuntimeFixture("I061");
|
||||||
|
}
|
||||||
|
|
||||||
test "fixture - I064 (Done stops thread)" {
|
test "fixture - I064 (Done stops thread)" {
|
||||||
try testRuntimeFixture("I064");
|
try testRuntimeFixture("I064");
|
||||||
}
|
}
|
||||||
|
|
@ -132,10 +148,34 @@ test "fixture - I075 (Clean callstack reset on path choice)" {
|
||||||
try testRuntimeFixture("I075");
|
try testRuntimeFixture("I075");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "fixture - I076 (Call stack evaluation)" {
|
||||||
|
try testRuntimeFixture("I076");
|
||||||
|
}
|
||||||
|
|
||||||
test "fixture - I078 (Choice with brackets only)" {
|
test "fixture - I078 (Choice with brackets only)" {
|
||||||
try testRuntimeFixture("I078");
|
try testRuntimeFixture("I078");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "fixture - I082 (Choice diverts to done)" {
|
||||||
|
try testRuntimeFixture("I082");
|
||||||
|
}
|
||||||
|
|
||||||
|
test "fixture - I085 (Logic in choices)" {
|
||||||
|
try testRuntimeFixture("I085");
|
||||||
|
}
|
||||||
|
|
||||||
|
test "fixture - I087 (Non text in choice inner content)" {
|
||||||
|
try testRuntimeFixture("I087");
|
||||||
|
}
|
||||||
|
|
||||||
|
test "fixture - I095 (Multiline logic with glue)" {
|
||||||
|
try testRuntimeFixture("I095");
|
||||||
|
}
|
||||||
|
|
||||||
|
test "fixture - I097 (Logic lines with newlines)" {
|
||||||
|
try testRuntimeFixture("I097");
|
||||||
|
}
|
||||||
|
|
||||||
test "fixture - I117 (Factorial recursive)" {
|
test "fixture - I117 (Factorial recursive)" {
|
||||||
try testRuntimeFixture("I117");
|
try testRuntimeFixture("I117");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -295,8 +295,6 @@ pub const Module = struct {
|
||||||
};
|
};
|
||||||
defer builder.deinit(gpa);
|
defer builder.deinit(gpa);
|
||||||
|
|
||||||
const debug_name_str = mod.intern_pool.getStrBytes(mod.ir, work_unit.decl_name);
|
|
||||||
std.debug.print("Analyzing {s}\n", .{debug_name_str});
|
|
||||||
switch (work_unit.tag) {
|
switch (work_unit.tag) {
|
||||||
.knot => {
|
.knot => {
|
||||||
try sema.analyzeKnot(&builder, work_unit.inst_index);
|
try sema.analyzeKnot(&builder, work_unit.inst_index);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue