From 76581ad6d08a5564bc4171aa3971eed2263981f2 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 3 Apr 2008 21:43:41 -0500 Subject: [PATCH] Remove crappy parser feature --- core/parser/parser-docs.factor | 8 ------ core/parser/parser-tests.factor | 41 --------------------------- core/parser/parser.factor | 41 ++++++--------------------- core/source-files/source-files.factor | 18 ++++++------ 4 files changed, 17 insertions(+), 91 deletions(-) diff --git a/core/parser/parser-docs.factor b/core/parser/parser-docs.factor index cc4e2c0a42..61fd9f7f30 100755 --- a/core/parser/parser-docs.factor +++ b/core/parser/parser-docs.factor @@ -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." } ; diff --git a/core/parser/parser-tests.factor b/core/parser/parser-tests.factor index 6bd4abb7e1..ab9648c527 100755 --- a/core/parser/parser-tests.factor +++ b/core/parser/parser-tests.factor @@ -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 ;" - "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 diff --git a/core/parser/parser.factor b/core/parser/parser.factor index 902bae29b5..8fcbad4d3c 100755 --- a/core/parser/parser.factor +++ b/core/parser/parser.factor @@ -464,19 +464,6 @@ SYMBOL: interactive-vocabs "Loading " write . 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 -- ) diff --git a/core/source-files/source-files.factor b/core/source-files/source-files.factor index 8dea367b6b..5df5f503f9 100755 --- a/core/source-files/source-files.factor +++ b/core/source-files/source-files.factor @@ -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 ;