diff options
author | Edwin Cheng <[email protected]> | 2019-04-12 18:50:05 +0100 |
---|---|---|
committer | Edwin Cheng <[email protected]> | 2019-04-12 18:50:05 +0100 |
commit | f66300ccd1e6ef05b633cda06c87f913d1c91a1e (patch) | |
tree | bfa2e896c1da845dd04e43bb0973a156a310bcd5 /crates/ra_parser | |
parent | 74e846b9ecffd819af3109c50e48517b560b17cf (diff) |
Remove skip Delimiter::None and handle Dollars
Diffstat (limited to 'crates/ra_parser')
-rw-r--r-- | crates/ra_parser/src/parser.rs | 12 |
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`. |