]> gitweb.factorcode.org Git - factor.git/commitdiff
strings.parser: use unexpected instead of string errors.
authorJohn Benediktsson <mrjbq7@gmail.com>
Mon, 7 Dec 2020 21:13:36 +0000 (13:13 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 7 Dec 2020 21:13:36 +0000 (13:13 -0800)
core/strings/parser/parser-tests.factor
core/strings/parser/parser.factor

index 474542852a0d99237b15b4bfb91004bd2dca97f0..706f38d885dbe9e650df719005cb1c86f8dc6b72 100644 (file)
@@ -1,4 +1,4 @@
-USING: accessors kernel eval strings.parser tools.test ;
+USING: accessors eval kernel lexer strings.parser tools.test ;
 
 { "Hello\n\rworld" } [ "Hello\\n\\rworld" unescape-string ] unit-test
 
@@ -14,11 +14,10 @@ USING: accessors kernel eval strings.parser tools.test ;
 { "foobarbaz" } [ "\"foo\\\nbar\\\r\nbaz\"" eval( -- obj ) ] unit-test
 
 { "\"abc\"" } [ "\"\\\"abc\\\"\"" eval( -- string ) ] unit-test
-[ "\"" eval( -- string ) ] [ error>> "Unterminated string" = ] must-fail-with
-[ "\"abc" eval( -- string ) ] [ error>> "Unterminated string" = ] must-fail-with
-[ "\"abc\n\n" eval( -- string ) ] [ error>> "Unterminated string" = ] must-fail-with
-
-[ "\"hello\"length" eval( -- string ) ] [ error>> "Invalid string" = ] must-fail-with
+[ "\"" eval( -- string ) ] [ error>> unexpected? ] must-fail-with
+[ "\"abc" eval( -- string ) ] [ error>> unexpected? ] must-fail-with
+[ "\"abc\n\n" eval( -- string ) ] [ error>> unexpected? ] must-fail-with
+[ "\"hello\"length" eval( -- string ) ] [ error>> unexpected? ] must-fail-with
 
 { "\"\\" } [ "\"\\" ] unit-test
 
index 73dd42485a7b9f343f97e948961fdd42150a9f82..406f6879c9fd05a9850b4fb8a922b6379b2b23eb 100644 (file)
@@ -123,7 +123,7 @@ DEFER: (parse-string)
         dup current-char forbid-tab {
             { CHAR: \s [ advance-char ] }
             { f [ drop ] }
-            [ "Invalid string" throw ]
+            [ "[space]" swap 1string unexpected ]
         } case drop
     ] if ;
  
@@ -138,7 +138,7 @@ DEFER: (parse-string)
             (parse-string)
         ] if*
     ] [
-        "Unterminated string" throw
+        "\"" "[eof]" unexpected
     ] if ;
 
 PRIVATE>