From b39d4c54a42357823e31d80c1f0daad9f7a1ccb3 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Tue, 21 Jul 2015 16:26:40 -0700 Subject: [PATCH] regexp: remove R" R[ and R{, there are still plenty of options and better ones to come. --- basis/regexp/regexp.factor | 6 ----- extra/xkcd/xkcd.factor | 2 +- extra/yaml/conversion/conversion.factor | 36 ++++++++++++------------- 3 files changed, 19 insertions(+), 25 deletions(-) diff --git a/basis/regexp/regexp.factor b/basis/regexp/regexp.factor index c0d6333390..699c61e4c6 100644 --- a/basis/regexp/regexp.factor +++ b/basis/regexp/regexp.factor @@ -203,14 +203,11 @@ PRIVATE> { { "R/ " "/" } { "R! " "!" } - { "R\" " "\"" } { "R# " "#" } { "R' " "'" } { "R( " ")" } { "R@ " "@" } - { "R[ " "]" } { "R` " "`" } - { "R{ " "}" } { "R| " "|" } } swap [ subseq? not nip ] curry assoc-find drop ; @@ -231,15 +228,12 @@ PRIVATE> PRIVATE> SYNTAX: R! CHAR: ! parsing-regexp ; -SYNTAX: R" CHAR: " parsing-regexp ; SYNTAX: R# CHAR: # parsing-regexp ; SYNTAX: R' CHAR: ' parsing-regexp ; SYNTAX: R( CHAR: ) parsing-regexp ; SYNTAX: R/ CHAR: / parsing-regexp ; SYNTAX: R@ CHAR: @ parsing-regexp ; -SYNTAX: R[ CHAR: ] parsing-regexp ; SYNTAX: R` CHAR: ` parsing-regexp ; -SYNTAX: R{ CHAR: } parsing-regexp ; SYNTAX: R| CHAR: | parsing-regexp ; USE: vocabs.loader diff --git a/extra/xkcd/xkcd.factor b/extra/xkcd/xkcd.factor index 459323176e..d4410f3291 100644 --- a/extra/xkcd/xkcd.factor +++ b/extra/xkcd/xkcd.factor @@ -13,7 +13,7 @@ IN: xkcd : comic-image ( url -- image ) http-get nip - R" http://imgs\.xkcd\.com/comics/[^\.]+\.(png|jpg)" + R@ http://imgs\.xkcd\.com/comics/[^\.]+\.(png|jpg)@ first-match >string load-http-image ; : comic-image. ( url -- ) diff --git a/extra/yaml/conversion/conversion.factor b/extra/yaml/conversion/conversion.factor index 95cd73dc65..daee389da7 100644 --- a/extra/yaml/conversion/conversion.factor +++ b/extra/yaml/conversion/conversion.factor @@ -15,16 +15,16 @@ CONSTANT: YAML_VALUE_TAG "tag:yaml.org,2002:value" ! http://www.yaml.org/spec/1.2/spec.html ! 10.3. Core Schema -CONSTANT: re-null R" null|Null|NULL|~" -CONSTANT: re-empty R" " -CONSTANT: re-bool R" true|True|TRUE|false|False|FALSE" -CONSTANT: re-int10 R" [-+]?[0-9]+" -CONSTANT: re-int8 R" 0o[0-7]+" -CONSTANT: re-int16 R" 0x[0-9a-fA-F]+" -CONSTANT: re-number R" [-+]?(\.[0-9]+|[0-9]+(\.[0-9]*)?)([eE][-+]?[0-9]+)?" -CONSTANT: re-infinity R" [-+]?\.(inf|Inf|INF)" -CONSTANT: re-nan R" \.(nan|NaN|NAN)" -CONSTANT: re-timestamp R" [0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]|[0-9][0-9][0-9][0-9]-[0-9][0-9]?-[0-9][0-9]?([Tt]|[ \t]+)[0-9][0-9]?:[0-9][0-9]:[0-9][0-9](\.[0-9]*)?([ \t]*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?))?" +CONSTANT: re-null R/ null|Null|NULL|~/ +CONSTANT: re-empty R/ / +CONSTANT: re-bool R/ true|True|TRUE|false|False|FALSE/ +CONSTANT: re-int10 R/ [-+]?[0-9]+/ +CONSTANT: re-int8 R/ 0o[0-7]+/ +CONSTANT: re-int16 R/ 0x[0-9a-fA-F]+/ +CONSTANT: re-number R/ [-+]?(\.[0-9]+|[0-9]+(\.[0-9]*)?)([eE][-+]?[0-9]+)?/ +CONSTANT: re-infinity R/ [-+]?\.(inf|Inf|INF)/ +CONSTANT: re-nan R/ \.(nan|NaN|NAN)/ +CONSTANT: re-timestamp R/ [0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]|[0-9][0-9][0-9][0-9]-[0-9][0-9]?-[0-9][0-9]?([Tt]|[ \t]+)[0-9][0-9]?:[0-9][0-9]:[0-9][0-9](\.[0-9]*)?([ \t]*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?))?/ : resolve-normal-plain-scalar ( str -- tag ) { @@ -41,8 +41,8 @@ CONSTANT: re-timestamp R" [0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]|[0-9][0-9][ [ drop YAML_STR_TAG ] } cond-case ; -CONSTANT: re-merge R" <<" -CONSTANT: re-value R" =" +CONSTANT: re-merge R/ <number ; @@ -107,14 +107,14 @@ CONSTANT: YAML_SET_TAG "tag:yaml.org,2002:set" ! - months, days and hours on 1 digit ! preprocess to fix this mess... : yaml>rfc3339 ( str -- str' ) - R" -[0-9][^0-9]" [ [ CHAR: 0 1 ] dip insert-nth ] re-replace-with - R" -[0-9][^0-9]" [ [ CHAR: 0 1 ] dip insert-nth ] re-replace-with - R" [^0-9][0-9]:" [ [ CHAR: 0 1 ] dip insert-nth ] re-replace-with - R" [ \t]+" " " re-replace + R/ -[0-9][^0-9]/ [ [ CHAR: 0 1 ] dip insert-nth ] re-replace-with + R/ -[0-9][^0-9]/ [ [ CHAR: 0 1 ] dip insert-nth ] re-replace-with + R/ [^0-9][0-9]:/ [ [ CHAR: 0 1 ] dip insert-nth ] re-replace-with + R/ [ \t]+/ " " re-replace CHAR: : over index cut CHAR: space swap remove append ; : construct-timestamp ( obj -- obj' ) - dup R" [0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]" matches? + dup R/ [0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]/ matches? [ ymd>timestamp ] [ yaml>rfc3339 rfc3339>timestamp ] if ; TUPLE: yaml-merge ; -- 2.34.1