mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-03 09:07:26 +00:00
internal: replace TreeSink with a data structure
The general theme of this is to make parser a better independent library. The specific thing we do here is replacing callback based TreeSink with a data structure. That is, rather than calling user-provided tree construction methods, the parser now spits out a very bare-bones tree, effectively a log of a DFS traversal. This makes the parser usable without any *specifc* tree sink, and allows us to, eg, move tests into this crate. Now, it's also true that this is a distinction without a difference, as the old and the new interface are equivalent in expressiveness. Still, this new thing seems somewhat simpler. But yeah, I admit I don't have a suuper strong motivation here, just a hunch that this is better.
This commit is contained in:
parent
2f63558dc5
commit
d0d05075ed
10 changed files with 172 additions and 110 deletions
|
@ -8,7 +8,6 @@ use limit::Limit;
|
|||
use crate::{
|
||||
event::Event,
|
||||
tokens::Tokens,
|
||||
ParseError,
|
||||
SyntaxKind::{self, EOF, ERROR, TOMBSTONE},
|
||||
TokenSet, T,
|
||||
};
|
||||
|
@ -196,7 +195,7 @@ impl<'t> Parser<'t> {
|
|||
/// structured errors with spans and notes, like rustc
|
||||
/// does.
|
||||
pub(crate) fn error<T: Into<String>>(&mut self, message: T) {
|
||||
let msg = ParseError(Box::new(message.into()));
|
||||
let msg = message.into();
|
||||
self.push_event(Event::Error { msg });
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue