From 0cb35fccbba1bf28ec91487fd06247a56feb0514 Mon Sep 17 00:00:00 2001 From: Capital-Ex Date: Tue, 6 Sep 2022 00:53:51 -0400 Subject: [PATCH] Update String Regex --- extra/lint/vocabs/vocabs-tests.factor | 6 ++++++ extra/lint/vocabs/vocabs.factor | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/extra/lint/vocabs/vocabs-tests.factor b/extra/lint/vocabs/vocabs-tests.factor index 61e5ffa29f..c34cea6ea3 100644 --- a/extra/lint/vocabs/vocabs-tests.factor +++ b/extra/lint/vocabs/vocabs-tests.factor @@ -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-char-backslash "CHAR: \\ USING: math.functions ;" 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 diff --git a/extra/lint/vocabs/vocabs.factor b/extra/lint/vocabs/vocabs.factor index c701a05145..8b692cc1c0 100644 --- a/extra/lint/vocabs/vocabs.factor +++ b/extra/lint/vocabs/vocabs.factor @@ -1,7 +1,7 @@ ! 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 ; @@ -35,7 +35,7 @@ SYMBOL: old-dictionary "USING: [^;]+ ;|USE: \\S+" all-matching-subseqs ; : clean-up-source ( string -- string ) - "\"(\\\\\"|[^\"])*\"|(R/ (\\\\/|[^/])*/)|\\\\\\s+(USE:|USING:)|POSTPONE:\\s+(USE:|USING:)|! [^\n]*" "" re-replace ; + "\"(\\\\\"|[^\"])*\"|R/ (\\\\/|[^/])*/|\\\\\\s+(USE:|USING:)|POSTPONE:\\s+(USE:|USING:)|! [^\n]*|CHAR:\\s+\\S+\\s+" "" re-replace ; : strip-syntax ( seq -- seq ) [ "USING: | ;|USE: " " " re-replace ] map ; -- 2.34.1