]> gitweb.factorcode.org Git - factor.git/commitdiff
formatting: better error messages for unknown directives.
authorJohn Benediktsson <mrjbq7@gmail.com>
Thu, 18 Jan 2018 16:53:29 +0000 (08:53 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Thu, 18 Jan 2018 16:54:06 +0000 (08:54 -0800)
basis/formatting/formatting.factor

index b2171d8b3ae9a01f6040c28a25915368e67d871e..f4e0a4a1eee4c1f2c2a9a319290ec1cd6b505c67 100644 (file)
@@ -9,6 +9,8 @@ math.functions.integer-logs splitting multiline ;
 FROM: math.parser.private => format-float ;
 IN: formatting
 
+ERROR: unknown-format-directive value ;
+
 <PRIVATE
 
 : compose-all ( seq -- quot )
@@ -91,8 +93,6 @@ IN: formatting
         [ [ ".0" ?tail drop ] [ drop ] if-zero ] bi
     ] [ format-decimal-simple ] if ;
 
-ERROR: unknown-printf-directive ;
-
 EBNF: parse-printf [=[
 
 zero      = "0"                  => [[ CHAR: 0 ]]
@@ -126,7 +126,7 @@ fmt-E     = digits "E"           => [[ first '[ _ format-scientific >upper ] ]]
 fmt-f     = digits "f"           => [[ first '[ _ format-decimal ] ]]
 fmt-x     = "x"                  => [[ [ >integer >hex ] ]]
 fmt-X     = "X"                  => [[ [ >integer >hex >upper ] ]]
-unknown   = (.)*                 => [[ unknown-printf-directive ]]
+unknown   = (.)*                 => [[ "" like unknown-format-directive ]]
 
 strings_  = fmt-c|fmt-C|fmt-s|fmt-S|fmt-u
 strings   = pad width strings_   => [[ <reversed> compose-all ]]
@@ -235,7 +235,7 @@ fmt-X     = "X"                  => [[ [ >time ] ]]
 fmt-y     = "y"                  => [[ [ year>> 100 mod pad-00 ] ]]
 fmt-Y     = "Y"                  => [[ [ year>> number>string ] ]]
 fmt-Z     = "Z"                  => [[ [ "Not yet implemented" throw ] ]]
-unknown   = (.)*                 => [[ "Unknown directive" throw ]]
+unknown   = (.)*                 => [[ "" like unknown-format-directive ]]
 
 formats_  = fmt-%|fmt-a|fmt-A|fmt-b|fmt-B|fmt-c|fmt-d|fmt-H|fmt-I|
             fmt-j|fmt-m|fmt-M|fmt-p|fmt-S|fmt-U|fmt-w|fmt-W|fmt-x|