Allow escaped quotation marks in BLT parser
This commit is contained in:
parent
d068ce6137
commit
f7f9727146
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user