diff options
Diffstat (limited to 'crates/ra_syntax/src/parser_impl')
-rw-r--r-- | crates/ra_syntax/src/parser_impl/event.rs | 12 | ||||
-rw-r--r-- | crates/ra_syntax/src/parser_impl/mod.rs | 12 |
2 files changed, 19 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..bf9c1cef0 100644 --- a/crates/ra_syntax/src/parser_impl/event.rs +++ b/crates/ra_syntax/src/parser_impl/event.rs | |||
@@ -13,6 +13,11 @@ 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 | SyntaxError, | ||
19 | SyntaxErrorKind, | ||
20 | }, | ||
16 | }; | 21 | }; |
17 | use std::mem; | 22 | use std::mem; |
18 | 23 | ||
@@ -75,7 +80,7 @@ pub(crate) enum Event { | |||
75 | }, | 80 | }, |
76 | 81 | ||
77 | Error { | 82 | Error { |
78 | msg: String, | 83 | msg: ParseError, |
79 | }, | 84 | }, |
80 | } | 85 | } |
81 | 86 | ||
@@ -157,7 +162,10 @@ impl<'a, S: Sink> EventProcessor<'a, S> { | |||
157 | .sum::<TextUnit>(); | 162 | .sum::<TextUnit>(); |
158 | self.leaf(kind, len, n_raw_tokens); | 163 | self.leaf(kind, len, n_raw_tokens); |
159 | } | 164 | } |
160 | Event::Error { msg } => self.sink.error(msg, self.text_pos), | 165 | Event::Error { msg } => self.sink.error(SyntaxError::new( |
166 | SyntaxErrorKind::ParseError(msg), | ||
167 | self.text_pos, | ||
168 | )), | ||
161 | } | 169 | } |
162 | } | 170 | } |
163 | self.sink | 171 | self.sink |
diff --git a/crates/ra_syntax/src/parser_impl/mod.rs b/crates/ra_syntax/src/parser_impl/mod.rs index 2b026d61e..cb6e370ac 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, |
14 | yellow::syntax_error::{ | ||
15 | ParseError, | ||
16 | SyntaxError, | ||
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, error: SyntaxError); |
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) { |