mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-28 17:53:56 +00:00
Lexer: minor
This commit is contained in:
parent
a071e09412
commit
9ccf339c17
@ -11,7 +11,7 @@ mod numbers;
|
|||||||
use self::numbers::scan_number;
|
use self::numbers::scan_number;
|
||||||
|
|
||||||
mod strings;
|
mod strings;
|
||||||
use self::strings::{string_literal_start, scan_char, scan_byte_char_or_string, scan_string, scan_raw_string};
|
use self::strings::{is_string_literal_start, scan_char, scan_byte_char_or_string, scan_string, scan_raw_string};
|
||||||
|
|
||||||
pub fn next_token(text: &str) -> Token {
|
pub fn next_token(text: &str) -> Token {
|
||||||
assert!(!text.is_empty());
|
assert!(!text.is_empty());
|
||||||
@ -23,10 +23,7 @@ pub fn next_token(text: &str) -> Token {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn next_token_inner(c: char, ptr: &mut Ptr) -> SyntaxKind {
|
fn next_token_inner(c: char, ptr: &mut Ptr) -> SyntaxKind {
|
||||||
// Note: r as in r" or r#" is part of a raw string literal,
|
let ident_start = is_ident_start(c) && !is_string_literal_start(c, ptr.next(), ptr.nnext());
|
||||||
// b as in b' is part of a byte literal.
|
|
||||||
// They are not identifiers, and are handled further down.
|
|
||||||
let ident_start = is_ident_start(c) && !string_literal_start(c, ptr.next(), ptr.nnext());
|
|
||||||
if ident_start {
|
if ident_start {
|
||||||
return scan_ident(c, ptr);
|
return scan_ident(c, ptr);
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ use syntax_kinds::*;
|
|||||||
|
|
||||||
use lexer::ptr::Ptr;
|
use lexer::ptr::Ptr;
|
||||||
|
|
||||||
pub(crate) fn string_literal_start(c: char, c1: Option<char>, c2: Option<char>) -> bool {
|
pub(crate) fn is_string_literal_start(c: char, c1: Option<char>, c2: Option<char>) -> bool {
|
||||||
match (c, c1, c2) {
|
match (c, c1, c2) {
|
||||||
('r', Some('"'), _) |
|
('r', Some('"'), _) |
|
||||||
('r', Some('#'), _) |
|
('r', Some('#'), _) |
|
||||||
|
Loading…
Reference in New Issue
Block a user