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." }
|
||||
{ $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
|
||||
{ $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 } "." } ;
|
||||
|
||||
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
|
||||
{ $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
|
||||
] 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
|
||||
] unit-test
|
||||
|
|
|
@ -464,19 +464,6 @@ SYMBOL: interactive-vocabs
|
|||
"Loading " write <pathname> . flush
|
||||
] 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 )
|
||||
diff [
|
||||
drop where dup [ first ] when
|
||||
|
@ -491,32 +478,22 @@ SYMBOL: interactive-vocabs
|
|||
new-definitions old-definitions
|
||||
[ get second ] bi@ ;
|
||||
|
||||
: smudged-usage ( -- usages referenced removed )
|
||||
removed-definitions filter-moved [
|
||||
outside-usages
|
||||
[
|
||||
empty? [ drop f ] [
|
||||
{
|
||||
{ [ dup pathname? ] [ f ] }
|
||||
{ [ dup method-body? ] [ f ] }
|
||||
{ [ t ] [ t ] }
|
||||
} cond nip
|
||||
] if
|
||||
] assoc-subset
|
||||
dup values concat prune swap keys
|
||||
] keep ;
|
||||
: forget-removed-definitions ( -- )
|
||||
removed-definitions filter-moved forget-all ;
|
||||
|
||||
: reset-removed-classes ( -- )
|
||||
removed-classes
|
||||
filter-moved [ class? ] subset [ reset-class ] each ;
|
||||
|
||||
: fix-class-words ( -- )
|
||||
#! If a class word had a compound definition which was
|
||||
#! removed, it must go back to being a symbol.
|
||||
new-definitions get first2
|
||||
filter-moved [ [ reset-generic ] [ define-symbol ] bi ] each
|
||||
removed-classes
|
||||
filter-moved [ class? ] subset [ reset-class ] each ;
|
||||
filter-moved [ [ reset-generic ] [ define-symbol ] bi ] each ;
|
||||
|
||||
: forget-smudged ( -- )
|
||||
smudged-usage forget-all
|
||||
over empty? [ 2dup smudged-usage-warning ] unless 2drop
|
||||
forget-removed-definitions
|
||||
reset-removed-classes
|
||||
fix-class-words ;
|
||||
|
||||
: finish-parsing ( lines quot -- )
|
||||
|
|
|
@ -56,10 +56,14 @@ uses definitions ;
|
|||
M: pathname where pathname-string 1 2array ;
|
||||
|
||||
: forget-source ( path -- )
|
||||
dup source-file
|
||||
dup unxref-source
|
||||
source-file-definitions [ keys forget-all ] each
|
||||
source-files get delete-at ;
|
||||
[
|
||||
source-file
|
||||
[ unxref-source ]
|
||||
[ definitions>> [ keys forget-all ] each ]
|
||||
bi
|
||||
]
|
||||
[ source-files get delete-at ]
|
||||
bi ;
|
||||
|
||||
M: pathname forget*
|
||||
pathname-string forget-source ;
|
||||
|
@ -78,9 +82,3 @@ SYMBOL: file
|
|||
source-file-definitions old-definitions set
|
||||
[ ] [ file get rollback-source-file ] cleanup
|
||||
] 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