aboutsummaryrefslogtreecommitdiff
path: root/crates/libsyntax2/src/grammar/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/libsyntax2/src/grammar/mod.rs')
-rw-r--r--crates/libsyntax2/src/grammar/mod.rs25
1 files changed, 14 insertions, 11 deletions
diff --git a/crates/libsyntax2/src/grammar/mod.rs b/crates/libsyntax2/src/grammar/mod.rs
index 25887921b..0f118f12d 100644
--- a/crates/libsyntax2/src/grammar/mod.rs
+++ b/crates/libsyntax2/src/grammar/mod.rs
@@ -144,18 +144,21 @@ fn name_ref(p: &mut Parser) {
144} 144}
145 145
146fn error_block(p: &mut Parser, message: &str) { 146fn error_block(p: &mut Parser, message: &str) {
147 assert!(p.at(L_CURLY)); 147 go(p, Some(message));
148 let err = p.start(); 148 fn go(p: &mut Parser, message: Option<&str>) {
149 p.error(message); 149 assert!(p.at(L_CURLY));
150 p.bump(); 150 let m = p.start();
151 let mut level: u32 = 1; 151 if let Some(message) = message {
152 while level > 0 && !p.at(EOF) { 152 p.error(message);
153 match p.current() {
154 L_CURLY => level += 1,
155 R_CURLY => level -= 1,
156 _ => (),
157 } 153 }
158 p.bump(); 154 p.bump();
155 while !p.at(EOF) && !p.at(R_CURLY) {
156 match p.current() {
157 L_CURLY => go(p, None),
158 _ => p.bump(),
159 }
160 }
161 p.eat(R_CURLY);
162 m.complete(p, ERROR);
159 } 163 }
160 err.complete(p, ERROR);
161} 164}