Error recovery

This commit is contained in:
2026-05-14 19:07:36 +02:00
parent 23f726fd41
commit ef7ccc5aed
2 changed files with 15 additions and 1 deletions
+9 -1
View File
@@ -52,6 +52,14 @@ visibility = { "pub" ~ ("(" ~ static_path ~ ")")? }
mutable = { "mut" } mutable = { "mut" }
var = { "var" } var = { "var" }
// ======================================================
// ERROR RECOVERY
// ======================================================
unexpected_statement = {
(!(semicolon | "}" | statement) ~ ANY)+
}
// ====================================================== // ======================================================
// GENERICS // GENERICS
// ====================================================== // ======================================================
@@ -303,7 +311,7 @@ block = {
} }
statement_list = { statement_list = {
statement* (statement | unexpected_statement)*
} }
statement = _{ statement = _{
+6
View File
@@ -491,6 +491,12 @@ impl From<pest::iterators::Pair<'_, Rule>> for Statement {
.collect(), .collect(),
), ),
Rule::unexpected_statement => {
let pos = pair.as_span().start_pos().line_col();
panic!("({}:{}) Invalid Statement: {}", pos.0, pos.1, pair.as_str())
}
_ => unimplemented!("{rule:#?}"), _ => unimplemented!("{rule:#?}"),
} }
} }