aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_parser
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_parser')
-rw-r--r--crates/ra_parser/src/parser.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/crates/ra_parser/src/parser.rs b/crates/ra_parser/src/parser.rs
index 56f8b7126..3cb57ed9c 100644
--- a/crates/ra_parser/src/parser.rs
+++ b/crates/ra_parser/src/parser.rs
@@ -99,6 +99,8 @@ impl<'t> Parser<'t> {
99 /// consumed between the `start` and the corresponding `Marker::complete` 99 /// consumed between the `start` and the corresponding `Marker::complete`
100 /// belong to the same node. 100 /// belong to the same node.
101 pub(crate) fn start(&mut self) -> Marker { 101 pub(crate) fn start(&mut self) -> Marker {
102 self.eat_dollars();
103
102 let pos = self.events.len() as u32; 104 let pos = self.events.len() as u32;
103 self.push_event(Event::tombstone()); 105 self.push_event(Event::tombstone());
104 Marker::new(pos) 106 Marker::new(pos)
@@ -180,13 +182,23 @@ impl<'t> Parser<'t> {
180 } 182 }
181 183
182 fn do_bump(&mut self, kind: SyntaxKind, n_raw_tokens: u8) { 184 fn do_bump(&mut self, kind: SyntaxKind, n_raw_tokens: u8) {
185 self.eat_dollars();
183 self.token_pos += usize::from(n_raw_tokens); 186 self.token_pos += usize::from(n_raw_tokens);
184 self.push_event(Event::Token { kind, n_raw_tokens }); 187 self.push_event(Event::Token { kind, n_raw_tokens });
188 self.eat_dollars();
185 } 189 }
186 190
187 fn push_event(&mut self, event: Event) { 191 fn push_event(&mut self, event: Event) {
188 self.events.push(event) 192 self.events.push(event)
189 } 193 }
194
195 fn eat_dollars(&mut self) {
196 while self.nth(0) == SyntaxKind::L_DOLLAR || self.nth(0) == SyntaxKind::R_DOLLAR {
197 let kind = self.nth(0);
198 self.token_pos += 1;
199 self.push_event(Event::Token { kind, n_raw_tokens: 1 });
200 }
201 }
190} 202}
191 203
192/// See `Parser::start`. 204/// See `Parser::start`.