Attempts to find the next statement by searching for a semicolon
fn findNextStmt(p: *Parse) void
fn findNextStmt(p: *Parse) void {
if (!p.recover) {
while (p.tokenTag(p.tok_i) != .eof) {
p.tok_i += 1;
}
return;
}
var level: u32 = 0;
while (true) {
const tok = p.nextToken();
switch (p.tokenTag(tok)) {
.l_brace => level += 1,
.r_brace => {
if (level == 0) {
p.tok_i -= 1;
return;
}
level -= 1;
},
.semicolon => {
if (level == 0) {
return;
}
},
.eof => {
p.tok_i -= 1;
return;
},
else => {},
}
}
}