]> gitweb.factorcode.org Git - factor.git/commitdiff
Update String Regex
authorCapital-Ex <capitalex@protonmail.com>
Tue, 6 Sep 2022 04:53:51 +0000 (00:53 -0400)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 6 Sep 2022 15:41:04 +0000 (08:41 -0700)
extra/lint/vocabs/vocabs-tests.factor
extra/lint/vocabs/vocabs.factor

index 61e5ffa29fb8d44e5c56a00c6f138312d0eef5d9..c34cea6ea3b439c34ce8c2f94521174857754e42 100644 (file)
@@ -41,6 +41,7 @@ CONSTANT: ignore-in-string-four     "\"asdfasdf USE: asdfasdf\" \"asdfasff USING
 CONSTANT: ignore-string-with-quote  "\"\\\"USE:\" : nop ( -- ) ;"
 CONSTANT: ignore-use-regex          "R/ USE: ignore/ : nop ( -- ) ;"
 CONSTANT: ignore-using-regex        "R/ USING: ignore ;/ : nop ( -- ) ;"
 CONSTANT: ignore-string-with-quote  "\"\\\"USE:\" : nop ( -- ) ;"
 CONSTANT: ignore-use-regex          "R/ USE: ignore/ : nop ( -- ) ;"
 CONSTANT: ignore-using-regex        "R/ USING: ignore ;/ : nop ( -- ) ;"
+CONSTANT: ignore-char-backslash     "CHAR: \\ USING: math.functions ;"
 CONSTANT: empty-using-statement     "USING: ; nop ( -- ) ;"
 : ---- ( -- ) "-------------------------------------------------------------------------" print ;
 PRIVATE>
 CONSTANT: empty-using-statement     "USING: ; nop ( -- ) ;"
 : ---- ( -- ) "-------------------------------------------------------------------------" print ;
 PRIVATE>
@@ -68,6 +69,11 @@ PRIVATE>
 
 ----
 
 
 ----
 
+"It should ignore CHAR: \\: " print
+{ { "math.functions" } } [ ignore-char-backslash find-unused-in-string ] unit-test
+
+----
+
 "It should ignore USE: and USING: that are in RegEx: " print
 { { } } [ ignore-use-regex   find-unused-in-string ] unit-test
 { { } } [ ignore-using-regex find-unused-in-string ] unit-test
 "It should ignore USE: and USING: that are in RegEx: " print
 { { } } [ ignore-use-regex   find-unused-in-string ] unit-test
 { { } } [ ignore-using-regex find-unused-in-string ] unit-test
index c701a05145b70ec9b3db9029dd6628d4f1898f39..8b692cc1c05b2586314238605aa7dd0b96340618 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2022 CapitalEx
 ! See http://factorcode.org/license.txt for BSD license.
 ! Copyright (C) 2022 CapitalEx
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays assocs compiler.units continuations
-formatting hash-sets hashtables io io.encodings.utf8 io.files
+USING: accessors arrays assocs compiler.units formatting 
+hash-sets hashtables io io.encodings.utf8 io.files
 kernel namespaces regexp sequences sequences.deep sets sorting
 splitting unicode vocabs vocabs.loader ;
 FROM: namespaces => set ;
 kernel namespaces regexp sequences sequences.deep sets sorting
 splitting unicode vocabs vocabs.loader ;
 FROM: namespaces => set ;
@@ -35,7 +35,7 @@ SYMBOL: old-dictionary
     "USING: [^;]+ ;|USE: \\S+" <regexp> all-matching-subseqs ;
 
 : clean-up-source ( string -- string ) 
     "USING: [^;]+ ;|USE: \\S+" <regexp> all-matching-subseqs ;
 
 : clean-up-source ( string -- string ) 
-    "\"(\\\\\"|[^\"])*\"|(R/ (\\\\/|[^/])*/)|\\\\\\s+(USE:|USING:)|POSTPONE:\\s+(USE:|USING:)|! [^\n]*" <regexp> "" re-replace ;
+    "\"(\\\\\"|[^\"])*\"|R/ (\\\\/|[^/])*/|\\\\\\s+(USE:|USING:)|POSTPONE:\\s+(USE:|USING:)|! [^\n]*|CHAR:\\s+\\S+\\s+" <regexp> "" re-replace ;
 
 : strip-syntax ( seq -- seq )
     [ "USING: | ;|USE: " <regexp> " " re-replace ] map ;
 
 : strip-syntax ( seq -- seq )
     [ "USING: | ;|USE: " <regexp> " " re-replace ] map ;