More work on auto-use
parent
5494f61df9
commit
274655e77c
|
@ -5,6 +5,7 @@ hashtables namespaces make parser prettyprint sequences strings
|
||||||
io.styles vectors words math sorting splitting classes slots fry
|
io.styles vectors words math sorting splitting classes slots fry
|
||||||
sets vocabs help.stylesheet help.topics vocabs.loader quotations
|
sets vocabs help.stylesheet help.topics vocabs.loader quotations
|
||||||
combinators see present ;
|
combinators see present ;
|
||||||
|
FROM: prettyprint.sections => with-pprint ;
|
||||||
IN: help.markup
|
IN: help.markup
|
||||||
|
|
||||||
PREDICATE: simple-element < array
|
PREDICATE: simple-element < array
|
||||||
|
@ -348,8 +349,6 @@ M: f ($instance)
|
||||||
drop
|
drop
|
||||||
"Throws an error if the I/O operation fails." $errors ;
|
"Throws an error if the I/O operation fails." $errors ;
|
||||||
|
|
||||||
FROM: prettyprint.private => with-pprint ;
|
|
||||||
|
|
||||||
: $prettyprinting-note ( children -- )
|
: $prettyprinting-note ( children -- )
|
||||||
drop {
|
drop {
|
||||||
"This word should only be called from inside the "
|
"This word should only be called from inside the "
|
||||||
|
|
|
@ -7,8 +7,7 @@ USING: vocabs.prettyprint tools.test io.streams.string multiline eval ;
|
||||||
<< manifest get pprint-manifest >> "> ;
|
<< manifest get pprint-manifest >> "> ;
|
||||||
|
|
||||||
[
|
[
|
||||||
<" USING: kernel namespaces syntax vocabs.parser
|
<" USING: kernel namespaces vocabs.parser vocabs.prettyprint ;">
|
||||||
vocabs.prettyprint ;">
|
|
||||||
]
|
]
|
||||||
[ [ manifest-test-1 eval( -- ) ] with-string-writer ] unit-test
|
[ [ manifest-test-1 eval( -- ) ] with-string-writer ] unit-test
|
||||||
|
|
||||||
|
@ -19,8 +18,7 @@ vocabs.prettyprint ;">
|
||||||
<< manifest get pprint-manifest >> "> ;
|
<< manifest get pprint-manifest >> "> ;
|
||||||
|
|
||||||
[
|
[
|
||||||
<" USING: kernel namespaces syntax vocabs.parser
|
<" USING: kernel namespaces vocabs.parser vocabs.prettyprint ;
|
||||||
vocabs.prettyprint ;
|
|
||||||
IN: vocabs.prettyprint.tests">
|
IN: vocabs.prettyprint.tests">
|
||||||
]
|
]
|
||||||
[ [ manifest-test-2 eval( -- ) ] with-string-writer ] unit-test
|
[ [ manifest-test-2 eval( -- ) ] with-string-writer ] unit-test
|
||||||
|
@ -36,8 +34,7 @@ IN: vocabs.prettyprint.tests">
|
||||||
<< manifest get pprint-manifest >> "> ;
|
<< manifest get pprint-manifest >> "> ;
|
||||||
|
|
||||||
[
|
[
|
||||||
<" USING: kernel namespaces syntax vocabs.parser
|
<" USING: kernel namespaces vocabs.parser vocabs.prettyprint ;
|
||||||
vocabs.prettyprint ;
|
|
||||||
FROM: math => + - ;
|
FROM: math => + - ;
|
||||||
QUALIFIED: system
|
QUALIFIED: system
|
||||||
QUALIFIED-WITH: assocs a
|
QUALIFIED-WITH: assocs a
|
||||||
|
|
|
@ -77,8 +77,8 @@ PRIVATE>
|
||||||
nl
|
nl
|
||||||
{ { font-style bold } { font-name "sans-serif" } } [
|
{ { font-style bold } { font-name "sans-serif" } } [
|
||||||
"Restarts were invoked adding vocabularies to the search path." print
|
"Restarts were invoked adding vocabularies to the search path." print
|
||||||
"To avoid doing this in the future, add the following USING:" print
|
"To avoid doing this in the future, add the following forms" print
|
||||||
"and IN: forms at the top of the source file:" print nl
|
"at the top of the source file:" print nl
|
||||||
] with-style
|
] with-style
|
||||||
{ { page-color T{ rgba f 0.8 0.8 0.8 1.0 } } }
|
{ { page-color T{ rgba f 0.8 0.8 0.8 1.0 } } }
|
||||||
[ manifest get pprint-manifest ] with-nesting
|
[ manifest get pprint-manifest ] with-nesting
|
||||||
|
|
|
@ -38,17 +38,13 @@ M: parsing-word stack-effect drop (( parsed -- parsed )) ;
|
||||||
|
|
||||||
: CREATE-WORD ( -- word ) CREATE dup reset-generic ;
|
: CREATE-WORD ( -- word ) CREATE dup reset-generic ;
|
||||||
|
|
||||||
SYMBOL: amended-use
|
|
||||||
|
|
||||||
SYMBOL: auto-use?
|
SYMBOL: auto-use?
|
||||||
|
|
||||||
: no-word-restarted ( restart-value -- word )
|
: no-word-restarted ( restart-value -- word )
|
||||||
dup word? [
|
dup word? [
|
||||||
dup vocabulary>>
|
dup vocabulary>>
|
||||||
[ use-vocab ]
|
[ auto-use-vocab ]
|
||||||
[ amended-use get dup [ push ] [ 2drop ] if ]
|
[ "Added \"" "\" vocabulary to search path" surround note. ] bi
|
||||||
[ "Added \"" "\" vocabulary to search path" surround note. ]
|
|
||||||
tri
|
|
||||||
] [ create-in ] if ;
|
] [ create-in ] if ;
|
||||||
|
|
||||||
: no-word ( name -- newword )
|
: no-word ( name -- newword )
|
||||||
|
@ -198,9 +194,8 @@ print-use-hook [ [ ] ] initialize
|
||||||
|
|
||||||
: parse-fresh ( lines -- quot )
|
: parse-fresh ( lines -- quot )
|
||||||
[
|
[
|
||||||
V{ } clone amended-use set
|
|
||||||
parse-lines
|
parse-lines
|
||||||
amended-use get empty? [ print-use-hook get call( -- ) ] unless
|
auto-used? [ print-use-hook get call( -- ) ] when
|
||||||
] with-file-vocabs ;
|
] with-file-vocabs ;
|
||||||
|
|
||||||
: parsing-file ( file -- )
|
: parsing-file ( file -- )
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: assocs hashtables kernel namespaces sequences
|
USING: assocs hashtables kernel namespaces sequences
|
||||||
sets strings vocabs sorting accessors arrays compiler.units
|
sets strings vocabs sorting accessors arrays compiler.units
|
||||||
combinators vectors splitting continuations ;
|
combinators vectors splitting continuations math ;
|
||||||
IN: vocabs.parser
|
IN: vocabs.parser
|
||||||
|
|
||||||
ERROR: no-word-error name ;
|
ERROR: no-word-error name ;
|
||||||
|
@ -12,22 +12,28 @@ TUPLE: manifest
|
||||||
current-vocab
|
current-vocab
|
||||||
{ search-vocabs vector }
|
{ search-vocabs vector }
|
||||||
{ qualified-vocabs vector }
|
{ qualified-vocabs vector }
|
||||||
{ extra-words vector } ;
|
{ extra-words vector }
|
||||||
|
{ auto-used vector } ;
|
||||||
|
|
||||||
: <manifest> ( -- manifest )
|
: <manifest> ( -- manifest )
|
||||||
manifest new
|
manifest new
|
||||||
V{ } clone >>search-vocabs
|
V{ } clone >>search-vocabs
|
||||||
V{ } clone >>qualified-vocabs
|
V{ } clone >>qualified-vocabs
|
||||||
V{ } clone >>extra-words ;
|
V{ } clone >>extra-words
|
||||||
|
V{ } clone >>auto-used ;
|
||||||
|
|
||||||
M: manifest clone
|
M: manifest clone
|
||||||
call-next-method
|
call-next-method
|
||||||
[ clone ] change-search-vocabs
|
[ clone ] change-search-vocabs
|
||||||
[ clone ] change-qualified-vocabs
|
[ clone ] change-qualified-vocabs
|
||||||
[ clone ] change-extra-words ;
|
[ clone ] change-extra-words
|
||||||
|
[ clone ] change-auto-used ;
|
||||||
|
|
||||||
TUPLE: extra-words words ;
|
TUPLE: extra-words words ;
|
||||||
|
|
||||||
|
M: extra-words equal?
|
||||||
|
over extra-words? [ [ words>> ] bi@ eq? ] [ 2drop f ] if ;
|
||||||
|
|
||||||
C: <extra-words> extra-words
|
C: <extra-words> extra-words
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
@ -83,6 +89,11 @@ TUPLE: no-current-vocab ;
|
||||||
|
|
||||||
: use-vocab ( vocab -- ) (use-vocab) push ;
|
: use-vocab ( vocab -- ) (use-vocab) push ;
|
||||||
|
|
||||||
|
: auto-use-vocab ( vocab -- )
|
||||||
|
[ use-vocab ] [ manifest get auto-used>> push ] bi ;
|
||||||
|
|
||||||
|
: auto-used? ( -- ? ) manifest get auto-used>> length 0 > ;
|
||||||
|
|
||||||
: unuse-vocab ( vocab -- ) (use-vocab) delq ;
|
: unuse-vocab ( vocab -- ) (use-vocab) delq ;
|
||||||
|
|
||||||
: only-use-vocabs ( vocabs -- )
|
: only-use-vocabs ( vocabs -- )
|
||||||
|
@ -128,7 +139,7 @@ TUPLE: rename word vocab words ;
|
||||||
|
|
||||||
: use-words ( assoc -- ) (use-words) push ;
|
: use-words ( assoc -- ) (use-words) push ;
|
||||||
|
|
||||||
: unuse-words ( assoc -- ) (use-words) delq ;
|
: unuse-words ( assoc -- ) (use-words) delete ;
|
||||||
|
|
||||||
ERROR: ambiguous-use-error words ;
|
ERROR: ambiguous-use-error words ;
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
USING: accessors assocs compiler.units continuations fuel.eval fuel.help
|
USING: accessors assocs compiler.units continuations fuel.eval fuel.help
|
||||||
fuel.remote fuel.xref help.topics io.pathnames kernel namespaces parser
|
fuel.remote fuel.xref help.topics io.pathnames kernel namespaces parser
|
||||||
sequences tools.scaffold vocabs.loader words ;
|
sequences tools.scaffold vocabs.loader vocabs.parser words ;
|
||||||
|
|
||||||
IN: fuel
|
IN: fuel
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ SYMBOL: :uses-suggestions
|
||||||
dup length 1 = [ first restart ] [ drop ] if ;
|
dup length 1 = [ first restart ] [ drop ] if ;
|
||||||
|
|
||||||
: fuel-set-use-hook ( -- )
|
: fuel-set-use-hook ( -- )
|
||||||
[ amended-use get clone :uses prefix fuel-eval-set-result ]
|
[ manifest get auto-used>> clone :uses prefix fuel-eval-set-result ]
|
||||||
print-use-hook set ;
|
print-use-hook set ;
|
||||||
|
|
||||||
: (fuel-get-uses) ( lines -- )
|
: (fuel-get-uses) ( lines -- )
|
||||||
|
|
Loading…
Reference in New Issue