diff options
Diffstat (limited to 'src/lexer')
-rw-r--r-- | src/lexer/mod.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/lexer/mod.rs b/src/lexer/mod.rs index f46746bee..7c4259763 100644 --- a/src/lexer/mod.rs +++ b/src/lexer/mod.rs | |||
@@ -16,6 +16,17 @@ use self::strings::{is_string_literal_start, scan_char, scan_byte_char_or_string | |||
16 | mod comments; | 16 | mod comments; |
17 | use self::comments::{scan_shebang, scan_comment}; | 17 | use self::comments::{scan_shebang, scan_comment}; |
18 | 18 | ||
19 | pub fn tokenize(text: &str) -> Vec<Token> { | ||
20 | let mut text = text; | ||
21 | let mut acc = Vec::new(); | ||
22 | while !text.is_empty() { | ||
23 | let token = next_token(text); | ||
24 | acc.push(token); | ||
25 | let len: u32 = token.len.into(); | ||
26 | text = &text[len as usize..]; | ||
27 | } | ||
28 | acc | ||
29 | } | ||
19 | pub fn next_token(text: &str) -> Token { | 30 | pub fn next_token(text: &str) -> Token { |
20 | assert!(!text.is_empty()); | 31 | assert!(!text.is_empty()); |
21 | let mut ptr = Ptr::new(text); | 32 | let mut ptr = Ptr::new(text); |