Tighten code

This commit is contained in:
greg 2017-12-04 02:00:00 -08:00
parent a1e38aba8e
commit 8534fb4118

View File

@ -128,13 +128,10 @@ fn tokenize(input: &mut Peekable<Chars>) -> Vec<Token> {
let string: String = input.scan(false, |escape, cur_char| { let string: String = input.scan(false, |escape, cur_char| {
let seen_escape = *escape; let seen_escape = *escape;
*escape = cur_char == '\\' && !seen_escape; *escape = cur_char == '\\' && !seen_escape;
match (cur_char, seen_escape) {
if cur_char == '"' && !seen_escape { ('"', false) => None,
None ('\\', false) => Some(None),
} else if cur_char == '\\' && !seen_escape { (c, _) => Some(Some(c))
Some(None)
} else {
Some(Some(cur_char))
} }
}).filter_map(|x| x).collect(); }).filter_map(|x| x).collect();
tokens.push(StringLiteral(string)); tokens.push(StringLiteral(string));