From 8bf5f40a2ae591f458ca791657394f47f2a0dd5e Mon Sep 17 00:00:00 2001 From: greg Date: Wed, 6 Sep 2017 16:52:49 -0700 Subject: [PATCH] Some string tokenizing - not done --- src/schala_lang/parsing.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/schala_lang/parsing.rs b/src/schala_lang/parsing.rs index 1984c94..b2c9d68 100644 --- a/src/schala_lang/parsing.rs +++ b/src/schala_lang/parsing.rs @@ -103,7 +103,25 @@ fn handle_digit(c: char, input: &mut CharIter) -> TokenType { } fn handle_quote(input: &mut CharIter) -> TokenType { - unimplemented!() + let mut buf = String::new(); + while let Some(c) = input.next().map(|(_, c)| { c }) { + if c == '"' { + break; + } else if c == '\\' { + let next = input.peek().map(|&(_, c)| { c }); + if next == Some('n') { + input.next(); + buf.push('\n') + } else if next == Some('"') { + input.next(); + buf.push('"'); + } + //TODO handle more escapes + } else { + buf.push(c); + } + } + TokenType::StrLiteral(Rc::new(buf)) } fn handle_alphabetic(c: char, input: &mut CharIter) -> TokenType {