fix stray curly

This commit is contained in:
Aleksey Kladov 2018-08-26 09:12:18 +03:00
parent a48964c64d
commit a450142aca
13 changed files with 144 additions and 29 deletions

View file

@ -43,7 +43,12 @@ pub(super) fn item_or_macro(p: &mut Parser, stop_on_r_curly: bool, flavor: ItemF
m.abandon(p);
if p.at(L_CURLY) {
error_block(p, "expected an item");
} else if !p.at(EOF) && !(stop_on_r_curly && p.at(R_CURLY)) {
} else if p.at(R_CURLY) && !stop_on_r_curly {
let e = p.start();
p.error("unmatched `}`");
p.bump();
e.complete(p, ERROR);
} else if !p.at(EOF) && !p.at(R_CURLY) {
p.err_and_bump("expected an item");
} else {
p.error("expected an item");

View file

@ -127,12 +127,12 @@ fn validate_block_structure(root: SyntaxNodeRef) {
assert_eq!(
node.parent(),
pair.parent(),
"unpaired curleys:\n{}",
"\nunpaired curleys:\n{}",
utils::dump_tree(root),
);
assert!(
node.next_sibling().is_none() && pair.prev_sibling().is_none(),
"floating curlys at {:?}\nfile:\n{}\nerror:\n{}\n",
"\nfloating curlys at {:?}\nfile:\n{}\nerror:\n{}\n",
node,
root.text(),
node.text(),

View file

@ -141,7 +141,9 @@ impl<'t> Parser<'t> {
pub(crate) fn err_and_bump(&mut self, message: &str) {
let m = self.start();
self.error(message);
self.bump();
if !self.at(SyntaxKind::L_CURLY) && !self.at(SyntaxKind::R_CURLY) {
self.bump();
}
m.complete(self, ERROR);
}
}