Allow escaped quotation marks in BLT parser

This commit is contained in:
RunasSudo 2022-11-20 18:57:30 +11:00
parent d068ce6137
commit f7f9727146
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A

View File

@ -255,9 +255,27 @@ impl<N: Number, I: Iterator<Item=char>> BLTParser<N, I> {
if self.lookahead() == '"' {
self.accept(); // Opening quotation mark
let mut result = String::new();
loop {
// Read string contents
if self.lookahead() == '"' {
break;
} else if self.lookahead() == '\\' {
// Escape sequence
self.accept();
if self.lookahead() == '"' || self.lookahead() == '\\' {
result.push(self.accept());
} else {
return Err(ParseError::Unexpected(self.line_no, self.col_no, self.lookahead()));
}
} else {
result.push(self.accept());
}
}
while self.lookahead() != '"' {
// TODO: BufRead::read_until ?
result.push(self.accept());
}
self.accept(); // Closing quotation mark
if !self.eof() {