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>
----
+"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
! 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 ;
"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 ;