diff options
| author | Aleksey Kladov <aleksey.kladov@gmail.com> | 2019-05-06 11:53:40 +0300 |
|---|---|---|
| committer | Aleksey Kladov <aleksey.kladov@gmail.com> | 2019-07-20 21:12:34 +0300 |
| commit | 395ee0b79f23b90593b01dd0a78451b8c93b0aa6 (patch) | |
| tree | 46544580dab78a9ce0e2ad59231c65709955ba2d /src/libsyntax/util | |
| parent | 95b1fe560d2bd8472f250fb8cfd2168520a58405 (diff) | |
| download | rust-395ee0b79f23b90593b01dd0a78451b8c93b0aa6.tar.gz rust-395ee0b79f23b90593b01dd0a78451b8c93b0aa6.zip | |
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.
Diffstat (limited to 'src/libsyntax/util')
| -rw-r--r-- | src/libsyntax/util/parser_testing.rs | 8 |
1 files changed, 4 insertions, 4 deletions
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<I: Iterator<Item= char>>(iter: &mut Peekable<I>) { - while lexer::is_pattern_whitespace(iter.peek().cloned()) { +fn scan_for_non_ws_or_end<I: Iterator<Item = char>>(iter: &mut Peekable<I>) { + 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)] |
