From e756f56b62053a34aa26a00e28dbe4ce29cd9125 Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Fri, 18 Jul 2014 20:19:21 +1000 Subject: Disambiguate "" empty strings from multiline strings properly. Previously `""` would go into multiline mode and thus *require* a following ". --- src/parser.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/parser.rs') 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 { -- cgit v1.2.3