]> gitweb.factorcode.org Git - factor.git/commitdiff
strings.parser: adding line continuations.
authorJohn Benediktsson <mrjbq7@gmail.com>
Thu, 24 Dec 2020 21:43:48 +0000 (13:43 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Thu, 24 Dec 2020 21:43:48 +0000 (13:43 -0800)
core/strings/parser/parser-tests.factor
core/strings/parser/parser.factor

index 706f38d885dbe9e650df719005cb1c86f8dc6b72..eae2eb0bc3682383ec856eba90c88cb9f726a691 100644 (file)
@@ -23,3 +23,7 @@ USING: accessors eval kernel lexer strings.parser tools.test ;
 
 { "\e" } [ "\u00001b" ] unit-test
 { "\e" } [ "\x1b" ] unit-test
+
+{ "foo" } [ "\"\\\nfoo\"" eval( -- obj ) ] unit-test
+{ "foo" } [ "\"foo\\\n\"" eval( -- obj ) ] unit-test
+{ "foo bar" } [ "\"foo \\\nbar\"" eval( -- obj ) ] unit-test
index 67f8dd787581366e514db65394e50f5c48affb63..0fe17af62722770ccd246a6ab58dcb9a19601846 100644 (file)
@@ -50,6 +50,7 @@ name>char-hook [
     unclip-slice {
         { CHAR: u [ unicode-escape ] }
         { CHAR: x [ hex-escape ] }
+        { CHAR: \n [ f swap ] }
         [ escape swap ]
     } case ;
 
@@ -59,7 +60,7 @@ name>char-hook [
     { sbuf object object } declare
     [
         cut-slice [ append! ] dip
-        rest-slice next-escape [ suffix! ] dip
+        rest-slice next-escape [ [ suffix! ] when* ] dip
         CHAR: \\ over index (unescape-string)
     ] [
         append!