Some string tokenizing - not done
This commit is contained in:
parent
7e505dd88e
commit
8bf5f40a2a
@ -103,7 +103,25 @@ fn handle_digit(c: char, input: &mut CharIter) -> TokenType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn handle_quote(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 {
|
fn handle_alphabetic(c: char, input: &mut CharIter) -> TokenType {
|
||||||
|
Loading…
Reference in New Issue
Block a user