From 9ccf339c176e68d26f601f24ed40bfa9429f9b5d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 31 Dec 2017 15:43:12 +0300 Subject: Lexer: minor --- src/lexer/mod.rs | 7 ++----- src/lexer/strings.rs | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/lexer/mod.rs b/src/lexer/mod.rs index be86416c4..3e49b1c2b 100644 --- a/src/lexer/mod.rs +++ b/src/lexer/mod.rs @@ -11,7 +11,7 @@ mod numbers; use self::numbers::scan_number; 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 { 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 { - // Note: r as in r" or r#" is part of a raw string literal, - // 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()); + let ident_start = is_ident_start(c) && !is_string_literal_start(c, ptr.next(), ptr.nnext()); if ident_start { return scan_ident(c, ptr); } diff --git a/src/lexer/strings.rs b/src/lexer/strings.rs index 2c1d86374..116d31760 100644 --- a/src/lexer/strings.rs +++ b/src/lexer/strings.rs @@ -3,7 +3,7 @@ use syntax_kinds::*; use lexer::ptr::Ptr; -pub(crate) fn string_literal_start(c: char, c1: Option, c2: Option) -> bool { +pub(crate) fn is_string_literal_start(c: char, c1: Option, c2: Option) -> bool { match (c, c1, c2) { ('r', Some('"'), _) | ('r', Some('#'), _) | -- cgit v1.2.3