mirror of
https://forge.katzen.cafe/katzen-cafe/iowo.git
synced 2024-11-24 14:28:44 +01:00
lang: handle and recover some errors in lists
This commit is contained in:
parent
4bcaf945d7
commit
ed151c2e3c
|
@ -4,4 +4,7 @@ use crate::lst_parser::syntax_kind::SyntaxKind;
|
||||||
pub enum SyntaxError {
|
pub enum SyntaxError {
|
||||||
Expected(Vec<SyntaxKind>),
|
Expected(Vec<SyntaxKind>),
|
||||||
PipelineNeedsSink,
|
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)
|
finish_mat_or_vec(p, start, row_start)
|
||||||
} else if p.eat(R_BRACK) {
|
} else if p.eat(R_BRACK) {
|
||||||
|
row_start.abandon(p);
|
||||||
start.complete(p, LIST)
|
start.complete(p, LIST)
|
||||||
} else {
|
} else {
|
||||||
|
row_start.abandon(p);
|
||||||
start.complete_err(p, SyntaxError::Expected(vec![EXPR, R_BRACK]))
|
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) {
|
} else if p.eat(R_BRACK) {
|
||||||
return list_start.complete(p, LIST);
|
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