mirror of
https://forge.katzen.cafe/katzen-cafe/iowo.git
synced 2024-12-22 01:55:51 +01:00
lang: handle and recover some errors in lists
This commit is contained in:
parent
4bcaf945d7
commit
ed151c2e3c
2 changed files with 20 additions and 0 deletions
|
@ -4,4 +4,7 @@ use crate::lst_parser::syntax_kind::SyntaxKind;
|
|||
pub enum SyntaxError {
|
||||
Expected(Vec<SyntaxKind>),
|
||||
PipelineNeedsSink,
|
||||
// if there was two space seperated items in a list
|
||||
SpaceSepInList,
|
||||
SemicolonInList,
|
||||
}
|
||||
|
|
|
@ -17,8 +17,10 @@ pub fn vec_matrix_list(p: &mut Parser) -> CompletedMarker {
|
|||
|
||||
finish_mat_or_vec(p, start, row_start)
|
||||
} else if p.eat(R_BRACK) {
|
||||
row_start.abandon(p);
|
||||
start.complete(p, LIST)
|
||||
} else {
|
||||
row_start.abandon(p);
|
||||
start.complete_err(p, SyntaxError::Expected(vec![EXPR, R_BRACK]))
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +37,21 @@ fn finish_list(p: &mut Parser, list_start: Marker) -> CompletedMarker {
|
|||
}
|
||||
} else if p.eat(R_BRACK) {
|
||||
return list_start.complete(p, LIST);
|
||||
} else if let Some(item) = atom(p) {
|
||||
item.precede(p, "next_item")
|
||||
.complete(p, COLLECTION_ITEM)
|
||||
.precede(p, "err_space_sep")
|
||||
.complete_err(p, SyntaxError::SpaceSepInList);
|
||||
} else if p.at(SEMICOLON) {
|
||||
let semi_err = p.start("semicolon_err");
|
||||
p.eat(SEMICOLON);
|
||||
semi_err.complete_err(p, SyntaxError::SemicolonInList);
|
||||
if let Some(item) = atom(p) {
|
||||
item.precede(p, "coll_item_start")
|
||||
.complete(p, COLLECTION_ITEM);
|
||||
} else if p.eat(R_BRACK) {
|
||||
return list_start.complete(p, LIST);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue