Some string tokenizing - not done

This commit is contained in:
greg 2017-09-06 16:52:49 -07:00
parent 7e505dd88e
commit 8bf5f40a2a

View File

@ -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 {