Error recovery
This commit is contained in:
@@ -52,6 +52,14 @@ visibility = { "pub" ~ ("(" ~ static_path ~ ")")? }
|
||||
mutable = { "mut" }
|
||||
var = { "var" }
|
||||
|
||||
// ======================================================
|
||||
// ERROR RECOVERY
|
||||
// ======================================================
|
||||
|
||||
unexpected_statement = {
|
||||
(!(semicolon | "}" | statement) ~ ANY)+
|
||||
}
|
||||
|
||||
// ======================================================
|
||||
// GENERICS
|
||||
// ======================================================
|
||||
@@ -303,7 +311,7 @@ block = {
|
||||
}
|
||||
|
||||
statement_list = {
|
||||
statement*
|
||||
(statement | unexpected_statement)*
|
||||
}
|
||||
|
||||
statement = _{
|
||||
|
||||
@@ -491,6 +491,12 @@ impl From<pest::iterators::Pair<'_, Rule>> for Statement {
|
||||
.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:#?}"),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user