From 56a986a1bcc084c66b194e3d90db1417bfa90321 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sat, 20 Feb 2016 00:29:39 -0400 Subject: - Fixed a bug when lexing text that contains escaped characters. --- src/lux/lexer.clj | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/lux/lexer.clj b/src/lux/lexer.clj index cbb351703..90b1f2bf1 100644 --- a/src/lux/lexer.clj +++ b/src/lux/lexer.clj @@ -65,9 +65,12 @@ post-quotes (if (.endsWith pre-quotes "\\") (if eol? (fail "[Lexer Error] Can't leave dangling back-slash \\") - (|do [_ (&reader/read-regex #"^([\"])") - next-part (lex-text-body offset)] - (return (str "\"" next-part)))) + (if (if-let [^String back-slashes (re-find #"\\+$" pre-quotes)] + (odd? (.length back-slashes))) + (|do [_ (&reader/read-regex #"^([\"])") + next-part (lex-text-body offset)] + (return (str "\"" next-part))) + (lex-text-body offset))) (if eol? (|do [[_ _ ^String line-prefix] (&reader/read-regex #"^( +|$)") :let [empty-line? (= "" line-prefix)] -- cgit v1.2.3