From f66300ccd1e6ef05b633cda06c87f913d1c91a1e Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Sat, 13 Apr 2019 01:50:05 +0800 Subject: Remove skip Delimiter::None and handle Dollars --- crates/ra_parser/src/parser.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'crates/ra_parser') 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> { /// consumed between the `start` and the corresponding `Marker::complete` /// belong to the same node. pub(crate) fn start(&mut self) -> Marker { + self.eat_dollars(); + let pos = self.events.len() as u32; self.push_event(Event::tombstone()); Marker::new(pos) @@ -180,13 +182,23 @@ impl<'t> Parser<'t> { } fn do_bump(&mut self, kind: SyntaxKind, n_raw_tokens: u8) { + self.eat_dollars(); self.token_pos += usize::from(n_raw_tokens); self.push_event(Event::Token { kind, n_raw_tokens }); + self.eat_dollars(); } fn push_event(&mut self, event: Event) { self.events.push(event) } + + fn eat_dollars(&mut self) { + while self.nth(0) == SyntaxKind::L_DOLLAR || self.nth(0) == SyntaxKind::R_DOLLAR { + let kind = self.nth(0); + self.token_pos += 1; + self.push_event(Event::Token { kind, n_raw_tokens: 1 }); + } + } } /// See `Parser::start`. -- cgit v1.2.3