From 2ba0fb486922d08aba48d831daee11ae99437555 Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Sun, 21 Nov 2021 00:51:27 -0800 Subject: [PATCH] Put cut around string parsing --- schala-lang/src/parsing/combinator.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/schala-lang/src/parsing/combinator.rs b/schala-lang/src/parsing/combinator.rs index 8fca4ce..872f9e6 100644 --- a/schala-lang/src/parsing/combinator.rs +++ b/schala-lang/src/parsing/combinator.rs @@ -842,7 +842,14 @@ fn bare_string_literal(input: Span) -> ParseResult { alt((value("\\", tag("\\")), value("\"", tag("\"")), value("\n", tag("n")), value("\t", tag("t")))); alt(( map(tag(r#""""#), |_| String::new()), - delimited(char('"'), escaped_transform(none_of(r#""\"#), '\\', string_escape_transforms), char('"')), + preceded( + peek(char('"')), + cut(delimited( + char('"'), + escaped_transform(none_of(r#""\"#), '\\', string_escape_transforms), + char('"'), + )), + ), ))(input) }