Remove crappy parser feature
parent
dbb0cf55cc
commit
76581ad6d0
|
@ -445,18 +445,10 @@ HELP: eval
|
||||||
{ $description "Parses Factor source code from a string, and calls the resulting quotation." }
|
{ $description "Parses Factor source code from a string, and calls the resulting quotation." }
|
||||||
{ $errors "Throws an error if the input is malformed, or if the evaluation itself throws an error." } ;
|
{ $errors "Throws an error if the input is malformed, or if the evaluation itself throws an error." } ;
|
||||||
|
|
||||||
HELP: outside-usages
|
|
||||||
{ $values { "seq" "a sequence of definitions" } { "usages" "an association list mapping definitions to sequences of definitions" } }
|
|
||||||
{ $description "Outputs an association list mapping elements of " { $snippet "seq" } " to lists of usages which exclude the definitions in " { $snippet "seq" } " themselves." } ;
|
|
||||||
|
|
||||||
HELP: filter-moved
|
HELP: filter-moved
|
||||||
{ $values { "assoc" "an assoc where the keys are definitions" } { "newassoc" "an assoc where the keys are definitions" } }
|
{ $values { "assoc" "an assoc where the keys are definitions" } { "newassoc" "an assoc where the keys are definitions" } }
|
||||||
{ $description "Removes all definitions from the assoc which are no longer present in the current " { $link file } "." } ;
|
{ $description "Removes all definitions from the assoc which are no longer present in the current " { $link file } "." } ;
|
||||||
|
|
||||||
HELP: smudged-usage
|
|
||||||
{ $values { "usages" "a sequence of definitions which reference removed definitions" } { "referenced" "a sequence of definitions removed from this source file which are still referenced elsewhere" } { "removed" "a sequence of definitions removed from this source file" } }
|
|
||||||
{ $description "Collects information about changed word definitioins after parsing." } ;
|
|
||||||
|
|
||||||
HELP: forget-smudged
|
HELP: forget-smudged
|
||||||
{ $description "Forgets removed definitions and prints a warning message if any of them are still referenced from other source files." } ;
|
{ $description "Forgets removed definitions and prints a warning message if any of them are still referenced from other source files." } ;
|
||||||
|
|
||||||
|
|
|
@ -348,47 +348,6 @@ IN: parser.tests
|
||||||
] must-fail
|
] must-fail
|
||||||
] with-file-vocabs
|
] with-file-vocabs
|
||||||
|
|
||||||
[
|
|
||||||
<< file get parsed >> file set
|
|
||||||
|
|
||||||
: ~a ;
|
|
||||||
|
|
||||||
DEFER: ~b
|
|
||||||
|
|
||||||
"IN: parser.tests : ~b ~a ;" <string-reader>
|
|
||||||
"smudgy" parse-stream drop
|
|
||||||
|
|
||||||
: ~c ;
|
|
||||||
: ~d ;
|
|
||||||
|
|
||||||
{ H{ { ~a ~a } { ~b ~b } { ~c ~c } { ~d ~d } } H{ } } old-definitions set
|
|
||||||
|
|
||||||
{ H{ { ~b ~b } { ~d ~d } } H{ } } new-definitions set
|
|
||||||
|
|
||||||
[ V{ ~b } { ~a } { ~a ~c } ] [
|
|
||||||
smudged-usage
|
|
||||||
natural-sort
|
|
||||||
] unit-test
|
|
||||||
] with-scope
|
|
||||||
|
|
||||||
[
|
|
||||||
<< file get parsed >> file set
|
|
||||||
|
|
||||||
GENERIC: ~e
|
|
||||||
|
|
||||||
: ~f ~e ;
|
|
||||||
|
|
||||||
: ~g ;
|
|
||||||
|
|
||||||
{ H{ { ~e ~e } { ~f ~f } { ~g ~g } } H{ } } old-definitions set
|
|
||||||
|
|
||||||
{ H{ { ~g ~g } } H{ } } new-definitions set
|
|
||||||
|
|
||||||
[ V{ } { } { ~e ~f } ]
|
|
||||||
[ smudged-usage natural-sort ]
|
|
||||||
unit-test
|
|
||||||
] with-scope
|
|
||||||
|
|
||||||
[ ] [
|
[ ] [
|
||||||
"IN: parser.tests USE: kernel PREDICATE: foo < object ( x -- y ) ;" eval
|
"IN: parser.tests USE: kernel PREDICATE: foo < object ( x -- y ) ;" eval
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
|
@ -464,19 +464,6 @@ SYMBOL: interactive-vocabs
|
||||||
"Loading " write <pathname> . flush
|
"Loading " write <pathname> . flush
|
||||||
] if ;
|
] if ;
|
||||||
|
|
||||||
: smudged-usage-warning ( usages removed -- )
|
|
||||||
parser-notes? [
|
|
||||||
"Warning: the following definitions were removed from sources," print
|
|
||||||
"but are still referenced from other definitions:" print
|
|
||||||
nl
|
|
||||||
dup sorted-definitions.
|
|
||||||
nl
|
|
||||||
"The following definitions need to be updated:" print
|
|
||||||
nl
|
|
||||||
over sorted-definitions.
|
|
||||||
nl
|
|
||||||
] when 2drop ;
|
|
||||||
|
|
||||||
: filter-moved ( assoc1 assoc2 -- seq )
|
: filter-moved ( assoc1 assoc2 -- seq )
|
||||||
diff [
|
diff [
|
||||||
drop where dup [ first ] when
|
drop where dup [ first ] when
|
||||||
|
@ -491,32 +478,22 @@ SYMBOL: interactive-vocabs
|
||||||
new-definitions old-definitions
|
new-definitions old-definitions
|
||||||
[ get second ] bi@ ;
|
[ get second ] bi@ ;
|
||||||
|
|
||||||
: smudged-usage ( -- usages referenced removed )
|
: forget-removed-definitions ( -- )
|
||||||
removed-definitions filter-moved [
|
removed-definitions filter-moved forget-all ;
|
||||||
outside-usages
|
|
||||||
[
|
: reset-removed-classes ( -- )
|
||||||
empty? [ drop f ] [
|
removed-classes
|
||||||
{
|
filter-moved [ class? ] subset [ reset-class ] each ;
|
||||||
{ [ dup pathname? ] [ f ] }
|
|
||||||
{ [ dup method-body? ] [ f ] }
|
|
||||||
{ [ t ] [ t ] }
|
|
||||||
} cond nip
|
|
||||||
] if
|
|
||||||
] assoc-subset
|
|
||||||
dup values concat prune swap keys
|
|
||||||
] keep ;
|
|
||||||
|
|
||||||
: fix-class-words ( -- )
|
: fix-class-words ( -- )
|
||||||
#! If a class word had a compound definition which was
|
#! If a class word had a compound definition which was
|
||||||
#! removed, it must go back to being a symbol.
|
#! removed, it must go back to being a symbol.
|
||||||
new-definitions get first2
|
new-definitions get first2
|
||||||
filter-moved [ [ reset-generic ] [ define-symbol ] bi ] each
|
filter-moved [ [ reset-generic ] [ define-symbol ] bi ] each ;
|
||||||
removed-classes
|
|
||||||
filter-moved [ class? ] subset [ reset-class ] each ;
|
|
||||||
|
|
||||||
: forget-smudged ( -- )
|
: forget-smudged ( -- )
|
||||||
smudged-usage forget-all
|
forget-removed-definitions
|
||||||
over empty? [ 2dup smudged-usage-warning ] unless 2drop
|
reset-removed-classes
|
||||||
fix-class-words ;
|
fix-class-words ;
|
||||||
|
|
||||||
: finish-parsing ( lines quot -- )
|
: finish-parsing ( lines quot -- )
|
||||||
|
|
|
@ -56,10 +56,14 @@ uses definitions ;
|
||||||
M: pathname where pathname-string 1 2array ;
|
M: pathname where pathname-string 1 2array ;
|
||||||
|
|
||||||
: forget-source ( path -- )
|
: forget-source ( path -- )
|
||||||
dup source-file
|
[
|
||||||
dup unxref-source
|
source-file
|
||||||
source-file-definitions [ keys forget-all ] each
|
[ unxref-source ]
|
||||||
source-files get delete-at ;
|
[ definitions>> [ keys forget-all ] each ]
|
||||||
|
bi
|
||||||
|
]
|
||||||
|
[ source-files get delete-at ]
|
||||||
|
bi ;
|
||||||
|
|
||||||
M: pathname forget*
|
M: pathname forget*
|
||||||
pathname-string forget-source ;
|
pathname-string forget-source ;
|
||||||
|
@ -78,9 +82,3 @@ SYMBOL: file
|
||||||
source-file-definitions old-definitions set
|
source-file-definitions old-definitions set
|
||||||
[ ] [ file get rollback-source-file ] cleanup
|
[ ] [ file get rollback-source-file ] cleanup
|
||||||
] with-scope ; inline
|
] with-scope ; inline
|
||||||
|
|
||||||
: outside-usages ( seq -- usages )
|
|
||||||
dup [
|
|
||||||
over usage
|
|
||||||
[ dup pathname? not swap where and ] subset seq-diff
|
|
||||||
] curry { } map>assoc ;
|
|
||||||
|
|
Loading…
Reference in New Issue