aboutsummaryrefslogtreecommitdiff
path: root/src/lexer/strings.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2017-12-31 10:32:00 +0000
committerAleksey Kladov <[email protected]>2017-12-31 10:32:00 +0000
commitf1a840cc385798fc2e3e9ac9ddb0dd57fd0ac509 (patch)
tree702e0d346b4d5aab3fe16c554aa878d08aa527c6 /src/lexer/strings.rs
parent9d5138bf11eb0c979c49f904010d2d3690bdf74c (diff)
Lexer: extract string lexing to a separate file
Diffstat (limited to 'src/lexer/strings.rs')
-rw-r--r--src/lexer/strings.rs65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/lexer/strings.rs b/src/lexer/strings.rs
new file mode 100644
index 000000000..40e5e4528
--- /dev/null
+++ b/src/lexer/strings.rs
@@ -0,0 +1,65 @@
1use {SyntaxKind};
2use syntax_kinds::*;
3
4use lexer::ptr::Ptr;
5
6pub(crate) fn string_literal_start(c: char, c1: Option<char>, c2: Option<char>) -> bool {
7 match (c, c1, c2) {
8 ('r', Some('"'), _) |
9 ('r', Some('#'), _) |
10 ('b', Some('"'), _) |
11 ('b', Some('\''), _) |
12 ('b', Some('r'), Some('"')) |
13 ('b', Some('r'), Some('#')) => true,
14 _ => false
15 }
16}
17
18pub(crate) fn scan_char(ptr: &mut Ptr) {
19 if ptr.bump().is_none() {
20 return; // TODO: error reporting is upper in the stack
21 }
22 scan_char_or_byte(ptr);
23 if !ptr.next_is('\'') {
24 return; // TODO: error reporting
25 }
26 ptr.bump();
27}
28
29pub(crate) fn scan_byte_char_or_string(ptr: &mut Ptr) -> SyntaxKind {
30 // unwrapping and not-exhaustive match are ok
31 // because of string_literal_start
32 let c = ptr.bump().unwrap();
33 match c {
34 '\'' => {
35 scan_byte(ptr);
36 CHAR
37 }
38 '"' => {
39 scan_byte_string(ptr);
40 CHAR
41 }
42 'r' => {
43 scan_raw_byte_string(ptr);
44 CHAR
45 }
46 _ => unreachable!(),
47 }
48}
49
50fn scan_byte(ptr: &mut Ptr) {
51
52}
53
54fn scan_byte_string(ptr: &mut Ptr) {
55
56}
57
58fn scan_raw_byte_string(ptr: &mut Ptr) {
59
60}
61
62fn scan_char_or_byte(ptr: &mut Ptr) {
63 //FIXME: deal with escape sequencies
64 ptr.bump();
65} \ No newline at end of file