aboutsummaryrefslogtreecommitdiff
path: root/src/lexer/strings.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lexer/strings.rs')
-rw-r--r--src/lexer/strings.rs33
1 files changed, 16 insertions, 17 deletions
diff --git a/src/lexer/strings.rs b/src/lexer/strings.rs
index 116d31760..00a84ec85 100644
--- a/src/lexer/strings.rs
+++ b/src/lexer/strings.rs
@@ -1,17 +1,17 @@
1use {SyntaxKind}; 1use SyntaxKind;
2use syntax_kinds::*; 2use syntax_kinds::*;
3 3
4use lexer::ptr::Ptr; 4use lexer::ptr::Ptr;
5 5
6pub(crate) fn is_string_literal_start(c: char, c1: Option<char>, c2: Option<char>) -> bool { 6pub(crate) fn is_string_literal_start(c: char, c1: Option<char>, c2: Option<char>) -> bool {
7 match (c, c1, c2) { 7 match (c, c1, c2) {
8 ('r', Some('"'), _) | 8 ('r', Some('"'), _)
9 ('r', Some('#'), _) | 9 | ('r', Some('#'), _)
10 ('b', Some('"'), _) | 10 | ('b', Some('"'), _)
11 ('b', Some('\''), _) | 11 | ('b', Some('\''), _)
12 ('b', Some('r'), Some('"')) | 12 | ('b', Some('r'), Some('"'))
13 ('b', Some('r'), Some('#')) => true, 13 | ('b', Some('r'), Some('#')) => true,
14 _ => false 14 _ => false,
15 } 15 }
16} 16}
17 17
@@ -50,20 +50,20 @@ pub(crate) fn scan_byte_char_or_string(ptr: &mut Ptr) -> SyntaxKind {
50pub(crate) fn scan_string(ptr: &mut Ptr) { 50pub(crate) fn scan_string(ptr: &mut Ptr) {
51 while let Some(c) = ptr.bump() { 51 while let Some(c) = ptr.bump() {
52 if c == '"' { 52 if c == '"' {
53 return 53 return;
54 } 54 }
55 } 55 }
56} 56}
57 57
58pub(crate) fn scan_raw_string(ptr: &mut Ptr) { 58pub(crate) fn scan_raw_string(ptr: &mut Ptr) {
59 if !ptr.next_is('"') { 59 if !ptr.next_is('"') {
60 return 60 return;
61 } 61 }
62 ptr.bump(); 62 ptr.bump();
63 63
64 while let Some(c) = ptr.bump() { 64 while let Some(c) = ptr.bump() {
65 if c == '"' { 65 if c == '"' {
66 return 66 return;
67 } 67 }
68 } 68 }
69} 69}
@@ -71,32 +71,32 @@ pub(crate) fn scan_raw_string(ptr: &mut Ptr) {
71fn scan_byte(ptr: &mut Ptr) { 71fn scan_byte(ptr: &mut Ptr) {
72 if ptr.next_is('\'') { 72 if ptr.next_is('\'') {
73 ptr.bump(); 73 ptr.bump();
74 return 74 return;
75 } 75 }
76 ptr.bump(); 76 ptr.bump();
77 if ptr.next_is('\'') { 77 if ptr.next_is('\'') {
78 ptr.bump(); 78 ptr.bump();
79 return 79 return;
80 } 80 }
81} 81}
82 82
83fn scan_byte_string(ptr: &mut Ptr) { 83fn scan_byte_string(ptr: &mut Ptr) {
84 while let Some(c) = ptr.bump() { 84 while let Some(c) = ptr.bump() {
85 if c == '"' { 85 if c == '"' {
86 return 86 return;
87 } 87 }
88 } 88 }
89} 89}
90 90
91fn scan_raw_byte_string(ptr: &mut Ptr) { 91fn scan_raw_byte_string(ptr: &mut Ptr) {
92 if !ptr.next_is('"') { 92 if !ptr.next_is('"') {
93 return 93 return;
94 } 94 }
95 ptr.bump(); 95 ptr.bump();
96 96
97 while let Some(c) = ptr.bump() { 97 while let Some(c) = ptr.bump() {
98 if c == '"' { 98 if c == '"' {
99 return 99 return;
100 } 100 }
101 } 101 }
102} 102}
@@ -105,4 +105,3 @@ fn scan_char_or_byte(ptr: &mut Ptr) {
105 //FIXME: deal with escape sequencies 105 //FIXME: deal with escape sequencies
106 ptr.bump(); 106 ptr.bump();
107} 107}
108