aboutsummaryrefslogtreecommitdiff
path: root/src/parser.rs
diff options
context:
space:
mode:
authorHuon Wilson <dbau.pp+github@gmail.com>2014-07-18 20:19:21 +1000
committerHuon Wilson <dbau.pp+github@gmail.com>2014-07-18 20:20:45 +1000
commite756f56b62053a34aa26a00e28dbe4ce29cd9125 (patch)
tree2ccbf27ac04539985419897bf0225267c22f2541 /src/parser.rs
parent05f8c0bc41a10f1e98e420f8d02d778541d13d48 (diff)
downloadmilf-rs-e756f56b62053a34aa26a00e28dbe4ce29cd9125.tar.gz
milf-rs-e756f56b62053a34aa26a00e28dbe4ce29cd9125.zip
Disambiguate "" empty strings from multiline strings properly.
Previously `""` would go into multiline mode and thus *require* a following ".
Diffstat (limited to 'src/parser.rs')
-rw-r--r--src/parser.rs13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/parser.rs b/src/parser.rs
index ec9adf9..27edd2f 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -265,11 +265,16 @@ impl<'a> Parser<'a> {
let mut multiline = false;
let mut ret = String::new();
- // detect multiline literals
+ // detect multiline literals, but be careful about empty ""
+ // strings
if self.eat('"') {
- multiline = true;
- if !self.expect('"') { return None }
- self.eat('\n');
+ if self.eat('"') {
+ multiline = true;
+ self.eat('\n');
+ } else {
+ // empty
+ return Some(String(ret))
+ }
}
loop {