Simplify quoted identifier tokenization

This commit is contained in:
Nickolay Ponomarev 2019-01-31 13:11:17 +03:00
parent 2e9da53ed3
commit b3693bfa63

View file

@ -290,23 +290,17 @@ impl<'a> Tokenizer<'a> {
} }
Ok(Some(Token::SingleQuotedString(s))) Ok(Some(Token::SingleQuotedString(s)))
} }
// string // delimited (quoted) identifier
'"' => { '"' => {
let mut s = String::new(); let mut s = String::new();
chars.next(); // consume let quote_start = chars.next().unwrap(); // consumes the opening quote
while let Some(&ch) = chars.peek() { while let Some(ch) = chars.next() {
match ch { match ch {
'"' => { '"' => break,
chars.next(); // consume _ => s.push(ch),
break;
}
_ => {
chars.next(); // consume
s.push(ch);
} }
} }
} Ok(Some(Token::make_word(&s, Some(quote_start))))
Ok(Some(Token::make_word(&s, Some('"'))))
} }
// numbers // numbers
'0'...'9' => { '0'...'9' => {