From 73ace376787a0b174aeeab177b8709d3844b1208 Mon Sep 17 00:00:00 2001 From: Ryan Gonzalez Date: Sat, 22 Aug 2015 15:13:46 -0500 Subject: [PATCH 1/3] Fix #831 Blame dot not matching newlines --- hy/lex/lexer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hy/lex/lexer.py b/hy/lex/lexer.py index 1480413..4a770f5 100644 --- a/hy/lex/lexer.py +++ b/hy/lex/lexer.py @@ -50,7 +50,7 @@ partial_string = r'''(?x) " # start string (?: | [^"\\] # non-quote or backslash - | \\. # or escaped single character + | \\(.|\n) # or escaped single character or newline | \\x[0-9a-fA-F]{2} # or escaped raw character | \\u[0-9a-fA-F]{4} # or unicode escape | \\U[0-9a-fA-F]{8} # or long unicode escape From a2f95366fe2ac493e41b07ca4599ed90d30b49de Mon Sep 17 00:00:00 2001 From: Ryan Gonzalez Date: Sat, 22 Aug 2015 15:26:23 -0500 Subject: [PATCH 2/3] Add tests for #831 --- tests/lex/test_lex.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/lex/test_lex.py b/tests/lex/test_lex.py index 56ed52a..4d354d3 100644 --- a/tests/lex/test_lex.py +++ b/tests/lex/test_lex.py @@ -100,6 +100,12 @@ def test_lex_strings(): """ Make sure that strings are valid expressions""" objs = tokenize("\"foo\" ") assert objs == [HyString("foo")] + # Make sure backslash-escaped newlines work (see issue #831) + objs = tokenize(r""" +"a\ +bc" +""") + assert objs == [HyString("abc")] def test_lex_integers(): From f88f6e597b508c92cd0d63b3b10ec6b7cfaf65c8 Mon Sep 17 00:00:00 2001 From: Ryan Gonzalez Date: Sat, 22 Aug 2015 18:37:53 -0500 Subject: [PATCH 3/3] Reformat string literals in test_lex_strings --- tests/lex/test_lex.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/lex/test_lex.py b/tests/lex/test_lex.py index 4d354d3..4413a6b 100644 --- a/tests/lex/test_lex.py +++ b/tests/lex/test_lex.py @@ -98,7 +98,7 @@ def test_lex_symbols(): def test_lex_strings(): """ Make sure that strings are valid expressions""" - objs = tokenize("\"foo\" ") + objs = tokenize('"foo"') assert objs == [HyString("foo")] # Make sure backslash-escaped newlines work (see issue #831) objs = tokenize(r"""