Skip to content

Commit 3ac5779

Browse files
committed
Improved error recovery
1 parent 2b57b80 commit 3ac5779

File tree

1 file changed

+14
-0
lines changed
  • crates/emmylua_parser/src/grammar/lua

1 file changed

+14
-0
lines changed

crates/emmylua_parser/src/grammar/lua/stat.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,20 @@ pub fn parse_stats(p: &mut LuaParser) {
170170
p.push_node_end();
171171
}
172172

173+
let mut can_continue = false;
174+
// error recover
175+
while p.current_token() != LuaTokenKind::TkEof {
176+
if is_statement_start_token(p.current_token()) {
177+
can_continue = true;
178+
break;
179+
}
180+
181+
p.bump();
182+
}
183+
184+
if can_continue {
185+
continue;
186+
}
173187
break;
174188
}
175189
}

0 commit comments

Comments
 (0)