Move token tree related lexer state to a separate struct

We only used a bunch of fields when tokenizing into a token tree,
so let's move them out of the base lexer
This commit is contained in:
Aleksey Kladov
2019-05-12 19:55:16 +03:00
parent efa3c27f0f
commit d29f0d23c3
3 changed files with 71 additions and 48 deletions

View File

@@ -66,15 +66,7 @@ pub struct StringReader<'a> {
span: Span,
/// The raw source span which *does not* take `override_span` into account
span_src_raw: Span,
/// Stack of open delimiters and their spans. Used for error message.
open_braces: Vec<(token::DelimToken, Span)>,
crate unmatched_braces: Vec<UnmatchedBrace>,
/// The type and spans for all braces
///
/// Used only for error recovery when arriving to EOF with mismatched braces.
matching_delim_spans: Vec<(token::DelimToken, Span, Span)>,
crate override_span: Option<Span>,
last_unclosed_found_span: Option<Span>,
override_span: Option<Span>,
}
impl<'a> StringReader<'a> {
@@ -254,11 +246,7 @@ impl<'a> StringReader<'a> {
token: token::Eof,
span: syntax_pos::DUMMY_SP,
span_src_raw: syntax_pos::DUMMY_SP,
open_braces: Vec::new(),
unmatched_braces: Vec::new(),
matching_delim_spans: Vec::new(),
override_span,
last_unclosed_found_span: None,
}
}