diff options
Diffstat (limited to 'crates/ra_syntax/src/parser_impl')
-rw-r--r-- | crates/ra_syntax/src/parser_impl/event.rs | 11 | ||||
-rw-r--r-- | crates/ra_syntax/src/parser_impl/mod.rs | 12 |
2 files changed, 18 insertions, 5 deletions
diff --git a/crates/ra_syntax/src/parser_impl/event.rs b/crates/ra_syntax/src/parser_impl/event.rs index 79fa21389..ced09bcff 100644 --- a/crates/ra_syntax/src/parser_impl/event.rs +++ b/crates/ra_syntax/src/parser_impl/event.rs | |||
@@ -13,6 +13,10 @@ use crate::{ | |||
13 | SmolStr, | 13 | SmolStr, |
14 | SyntaxKind::{self, *}, | 14 | SyntaxKind::{self, *}, |
15 | TextRange, TextUnit, | 15 | TextRange, TextUnit, |
16 | yellow::syntax_error::{ | ||
17 | ParseError, | ||
18 | SyntaxErrorKind, | ||
19 | }, | ||
16 | }; | 20 | }; |
17 | use std::mem; | 21 | use std::mem; |
18 | 22 | ||
@@ -75,7 +79,7 @@ pub(crate) enum Event { | |||
75 | }, | 79 | }, |
76 | 80 | ||
77 | Error { | 81 | Error { |
78 | msg: String, | 82 | msg: ParseError, |
79 | }, | 83 | }, |
80 | } | 84 | } |
81 | 85 | ||
@@ -157,7 +161,10 @@ impl<'a, S: Sink> EventProcessor<'a, S> { | |||
157 | .sum::<TextUnit>(); | 161 | .sum::<TextUnit>(); |
158 | self.leaf(kind, len, n_raw_tokens); | 162 | self.leaf(kind, len, n_raw_tokens); |
159 | } | 163 | } |
160 | Event::Error { msg } => self.sink.error(msg, self.text_pos), | 164 | Event::Error { msg } => self.sink.error( |
165 | SyntaxErrorKind::ParseError(msg), | ||
166 | TextRange::offset_len(self.text_pos, 1.into()), | ||
167 | ), | ||
161 | } | 168 | } |
162 | } | 169 | } |
163 | self.sink | 170 | self.sink |
diff --git a/crates/ra_syntax/src/parser_impl/mod.rs b/crates/ra_syntax/src/parser_impl/mod.rs index 2b026d61e..ade25770b 100644 --- a/crates/ra_syntax/src/parser_impl/mod.rs +++ b/crates/ra_syntax/src/parser_impl/mod.rs | |||
@@ -10,7 +10,11 @@ use crate::{ | |||
10 | event::{Event, EventProcessor}, | 10 | event::{Event, EventProcessor}, |
11 | input::{InputPosition, ParserInput}, | 11 | input::{InputPosition, ParserInput}, |
12 | }, | 12 | }, |
13 | SmolStr, TextUnit, | 13 | SmolStr, TextRange, |
14 | yellow::syntax_error::{ | ||
15 | ParseError, | ||
16 | SyntaxErrorKind, | ||
17 | }, | ||
14 | }; | 18 | }; |
15 | 19 | ||
16 | use crate::SyntaxKind::{self, EOF, TOMBSTONE}; | 20 | use crate::SyntaxKind::{self, EOF, TOMBSTONE}; |
@@ -21,7 +25,7 @@ pub(crate) trait Sink { | |||
21 | fn leaf(&mut self, kind: SyntaxKind, text: SmolStr); | 25 | fn leaf(&mut self, kind: SyntaxKind, text: SmolStr); |
22 | fn start_internal(&mut self, kind: SyntaxKind); | 26 | fn start_internal(&mut self, kind: SyntaxKind); |
23 | fn finish_internal(&mut self); | 27 | fn finish_internal(&mut self); |
24 | fn error(&mut self, message: String, offset: TextUnit); | 28 | fn error(&mut self, kind: SyntaxErrorKind, offset: TextRange); |
25 | fn finish(self) -> Self::Tree; | 29 | fn finish(self) -> Self::Tree; |
26 | } | 30 | } |
27 | 31 | ||
@@ -144,7 +148,9 @@ impl<'t> ParserImpl<'t> { | |||
144 | } | 148 | } |
145 | 149 | ||
146 | pub(super) fn error(&mut self, msg: String) { | 150 | pub(super) fn error(&mut self, msg: String) { |
147 | self.event(Event::Error { msg }) | 151 | self.event(Event::Error { |
152 | msg: ParseError(msg), | ||
153 | }) | ||
148 | } | 154 | } |
149 | 155 | ||
150 | pub(super) fn complete(&mut self, pos: u32, kind: SyntaxKind) { | 156 | pub(super) fn complete(&mut self, pos: u32, kind: SyntaxKind) { |