From 395ee0b79f23b90593b01dd0a78451b8c93b0aa6 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 6 May 2019 11:53:40 +0300 Subject: Introduce rustc_lexer The idea here is to make a reusable library out of the existing rust-lexer, by separating out pure lexing and rustc-specific concerns, like spans, error reporting an interning. So, rustc_lexer operates directly on `&str`, produces simple tokens which are a pair of type-tag and a bit of original text, and does not report errors, instead storing them as flags on the token. --- src/libsyntax/util/parser_testing.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/libsyntax/util/parser_testing.rs') diff --git a/src/libsyntax/util/parser_testing.rs b/src/libsyntax/util/parser_testing.rs index 2ef32d37d44..627422df1db 100644 --- a/src/libsyntax/util/parser_testing.rs +++ b/src/libsyntax/util/parser_testing.rs @@ -1,7 +1,7 @@ use crate::ast::{self, Ident}; use crate::source_map::FilePathMapping; use crate::parse::{ParseSess, PResult, source_file_to_stream}; -use crate::parse::{lexer, new_parser_from_source_str}; +use crate::parse::new_parser_from_source_str; use crate::parse::parser::Parser; use crate::ptr::P; use crate::tokenstream::TokenStream; @@ -113,14 +113,14 @@ pub fn matches_codepattern(a : &str, b : &str) -> bool { } /// Advances the given peekable `Iterator` until it reaches a non-whitespace character -fn scan_for_non_ws_or_end>(iter: &mut Peekable) { - while lexer::is_pattern_whitespace(iter.peek().cloned()) { +fn scan_for_non_ws_or_end>(iter: &mut Peekable) { + while iter.peek().copied().map(|c| is_pattern_whitespace(c)) == Some(true) { iter.next(); } } pub fn is_pattern_whitespace(c: char) -> bool { - lexer::is_pattern_whitespace(Some(c)) + rustc_lexer::character_properties::is_whitespace(c) } #[cfg(test)] -- cgit 1.4.1-3-g733a5