fn expectStatementRecoverable(p: *Parse) Error!?Node.Index p: *Parse1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149fn expectStatementRecoverable(p: *Parse) Error!?Node.Index {
while (true) {
return p.expectStatement(true) catch |err| switch (err) {
error.OutOfMemory => |e| return e,
error.ParseError => {
p.findNextStmt(); // Try to skip to the next statement.
switch (p.tokenTag(p.tok_i)) {
.r_brace => return null,
.eof => return error.ParseError,
else => continue,
}
},
};
}
}
If a parse error occurs, reports an error, but then finds the next statement and returns that one instead. If a parse error occurs but there is no following statement, returns null.