This commit is contained in:
ConnorSkees 2020-02-24 09:37:32 -05:00
parent e8ee76f7dc
commit 776e6444e6

View File

@ -286,14 +286,22 @@ impl Value {
} }
} }
} }
q @ TokenKind::Symbol(Symbol::DoubleQuote) | q @ TokenKind::Symbol(Symbol::DoubleQuote)
q @ TokenKind::Symbol(Symbol::SingleQuote) => { | q @ TokenKind::Symbol(Symbol::SingleQuote) => {
let mut s = String::new(); let mut s = String::new();
let mut is_escaped = false; let mut is_escaped = false;
while let Some(tok) = toks.next() { while let Some(tok) = toks.next() {
match tok.kind { match tok.kind {
TokenKind::Symbol(Symbol::DoubleQuote) if !is_escaped && q == TokenKind::Symbol(Symbol::DoubleQuote) => break, TokenKind::Symbol(Symbol::DoubleQuote)
TokenKind::Symbol(Symbol::SingleQuote) if !is_escaped && q == TokenKind::Symbol(Symbol::SingleQuote) => break, if !is_escaped && q == TokenKind::Symbol(Symbol::DoubleQuote) =>
{
break
}
TokenKind::Symbol(Symbol::SingleQuote)
if !is_escaped && q == TokenKind::Symbol(Symbol::SingleQuote) =>
{
break
}
TokenKind::Symbol(Symbol::BackSlash) if !is_escaped => is_escaped = true, TokenKind::Symbol(Symbol::BackSlash) if !is_escaped => is_escaped = true,
TokenKind::Symbol(Symbol::BackSlash) => s.push('\\'), TokenKind::Symbol(Symbol::BackSlash) => s.push('\\'),
TokenKind::Interpolation => { TokenKind::Interpolation => {
@ -315,7 +323,7 @@ impl Value {
let quotes = match q { let quotes = match q {
TokenKind::Symbol(Symbol::DoubleQuote) => QuoteKind::Double, TokenKind::Symbol(Symbol::DoubleQuote) => QuoteKind::Double,
TokenKind::Symbol(Symbol::SingleQuote) => QuoteKind::Single, TokenKind::Symbol(Symbol::SingleQuote) => QuoteKind::Single,
_ => unreachable!() _ => unreachable!(),
}; };
Ok(Value::Ident(s, quotes)) Ok(Value::Ident(s, quotes))
} }