aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/libsyntax2/src/lexer/strings.rs28
-rw-r--r--crates/libsyntax2/tests/data/lexer/0006_chars.rs2
-rw-r--r--crates/libsyntax2/tests/data/lexer/0006_chars.txt10
3 files changed, 27 insertions, 13 deletions
diff --git a/crates/libsyntax2/src/lexer/strings.rs b/crates/libsyntax2/src/lexer/strings.rs
index fbae767e5..795ea97b7 100644
--- a/crates/libsyntax2/src/lexer/strings.rs
+++ b/crates/libsyntax2/src/lexer/strings.rs
@@ -15,14 +15,23 @@ pub(crate) fn is_string_literal_start(c: char, c1: Option<char>, c2: Option<char
15} 15}
16 16
17pub(crate) fn scan_char(ptr: &mut Ptr) { 17pub(crate) fn scan_char(ptr: &mut Ptr) {
18 if ptr.bump().is_none() { 18 loop {
19 return; // TODO: error reporting is upper in the stack 19 if ptr.next_is('\\') {
20 } 20 ptr.bump();
21 scan_char_or_byte(ptr); 21 if ptr.next_is('\\') || ptr.next_is('\'') {
22 if !ptr.next_is('\'') { 22 ptr.bump();
23 return; // TODO: error reporting 23 }
24 continue;
25 }
26 if ptr.next_is('\'') {
27 ptr.bump();
28 return;
29 }
30 if ptr.next_is('\n') {
31 break;
32 }
33 ptr.bump();
24 } 34 }
25 ptr.bump();
26} 35}
27 36
28pub(crate) fn scan_byte_char_or_string(ptr: &mut Ptr) -> SyntaxKind { 37pub(crate) fn scan_byte_char_or_string(ptr: &mut Ptr) -> SyntaxKind {
@@ -111,8 +120,3 @@ fn scan_raw_byte_string(ptr: &mut Ptr) {
111 } 120 }
112 } 121 }
113} 122}
114
115fn scan_char_or_byte(ptr: &mut Ptr) {
116 //FIXME: deal with escape sequencies
117 ptr.bump();
118}
diff --git a/crates/libsyntax2/tests/data/lexer/0006_chars.rs b/crates/libsyntax2/tests/data/lexer/0006_chars.rs
index 03598d908..454ee0a5f 100644
--- a/crates/libsyntax2/tests/data/lexer/0006_chars.rs
+++ b/crates/libsyntax2/tests/data/lexer/0006_chars.rs
@@ -1 +1 @@
'x' ' ' '0' 'x' ' ' '0' 'hello' '\x7f' '\n' '\\' '\''
diff --git a/crates/libsyntax2/tests/data/lexer/0006_chars.txt b/crates/libsyntax2/tests/data/lexer/0006_chars.txt
index ecaf22355..950954fbc 100644
--- a/crates/libsyntax2/tests/data/lexer/0006_chars.txt
+++ b/crates/libsyntax2/tests/data/lexer/0006_chars.txt
@@ -3,4 +3,14 @@ WHITESPACE 1 " "
3CHAR 3 "\' \'" 3CHAR 3 "\' \'"
4WHITESPACE 1 " " 4WHITESPACE 1 " "
5CHAR 3 "\'0\'" 5CHAR 3 "\'0\'"
6WHITESPACE 1 " "
7CHAR 7 "\'hello\'"
8WHITESPACE 1 " "
9CHAR 6 "\'\\x7f\'"
10WHITESPACE 1 " "
11CHAR 4 "\'\\n\'"
12WHITESPACE 1 " "
13CHAR 4 "\'\\\\\'"
14WHITESPACE 1 " "
15CHAR 4 "\'\\\'\'"
6WHITESPACE 1 "\n" 16WHITESPACE 1 "\n"