diff options
author | Aleksey Kladov <[email protected]> | 2018-08-24 17:27:30 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-08-24 17:27:30 +0100 |
commit | 7edab6ae6b4c5d0c411e88f10e923b91dca31de3 (patch) | |
tree | 4c17856285f568c56adb7c02024ef80e821dd367 /crates/libsyntax2/src/grammar/mod.rs | |
parent | 4d293003964c8f9fabadb1ceb77eab29c0438de3 (diff) |
nodes for blocks
Diffstat (limited to 'crates/libsyntax2/src/grammar/mod.rs')
-rw-r--r-- | crates/libsyntax2/src/grammar/mod.rs | 25 |
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 | ||
146 | fn error_block(p: &mut Parser, message: &str) { | 146 | fn 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 | } |