mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 15:01:51 +00:00
better char lexing
This commit is contained in:
parent
c7b1be6be3
commit
a5eeef0eee
@ -15,14 +15,23 @@ pub(crate) fn is_string_literal_start(c: char, c1: Option<char>, c2: Option<char
|
||||
}
|
||||
|
||||
pub(crate) fn scan_char(ptr: &mut Ptr) {
|
||||
if ptr.bump().is_none() {
|
||||
return; // TODO: error reporting is upper in the stack
|
||||
loop {
|
||||
if ptr.next_is('\\') {
|
||||
ptr.bump();
|
||||
if ptr.next_is('\\') || ptr.next_is('\'') {
|
||||
ptr.bump();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if ptr.next_is('\'') {
|
||||
ptr.bump();
|
||||
return;
|
||||
}
|
||||
if ptr.next_is('\n') {
|
||||
break;
|
||||
}
|
||||
ptr.bump();
|
||||
}
|
||||
scan_char_or_byte(ptr);
|
||||
if !ptr.next_is('\'') {
|
||||
return; // TODO: error reporting
|
||||
}
|
||||
ptr.bump();
|
||||
}
|
||||
|
||||
pub(crate) fn scan_byte_char_or_string(ptr: &mut Ptr) -> SyntaxKind {
|
||||
@ -111,8 +120,3 @@ fn scan_raw_byte_string(ptr: &mut Ptr) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn scan_char_or_byte(ptr: &mut Ptr) {
|
||||
//FIXME: deal with escape sequencies
|
||||
ptr.bump();
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
'x' ' ' '0'
|
||||
'x' ' ' '0' 'hello' '\x7f' '\n' '\\' '\''
|
||||
|
@ -3,4 +3,14 @@ WHITESPACE 1 " "
|
||||
CHAR 3 "\' \'"
|
||||
WHITESPACE 1 " "
|
||||
CHAR 3 "\'0\'"
|
||||
WHITESPACE 1 " "
|
||||
CHAR 7 "\'hello\'"
|
||||
WHITESPACE 1 " "
|
||||
CHAR 6 "\'\\x7f\'"
|
||||
WHITESPACE 1 " "
|
||||
CHAR 4 "\'\\n\'"
|
||||
WHITESPACE 1 " "
|
||||
CHAR 4 "\'\\\\\'"
|
||||
WHITESPACE 1 " "
|
||||
CHAR 4 "\'\\\'\'"
|
||||
WHITESPACE 1 "\n"
|
||||
|
Loading…
Reference in New Issue
Block a user