2009-01-03 10:37:28 -05:00
|
|
|
! Copyright (C) 2008, 2009 Jose Antonio Ortega Ruiz.
|
2008-12-05 22:34:25 -05:00
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2018-01-27 21:48:09 -05:00
|
|
|
USING: accessors assocs compiler.units continuations fry fuel.eval
|
2015-10-06 07:54:33 -04:00
|
|
|
fuel.help fuel.xref help.topics io.pathnames kernel namespaces parser
|
2018-01-27 21:48:09 -05:00
|
|
|
parser.notes sequences source-files tools.scaffold vocabs vocabs.files
|
2017-01-10 06:17:12 -05:00
|
|
|
vocabs.hierarchy vocabs.loader vocabs.metadata vocabs.parser words ;
|
2008-12-05 22:34:25 -05:00
|
|
|
IN: fuel
|
|
|
|
|
2009-01-11 18:52:31 -05:00
|
|
|
! Evaluation
|
2008-12-08 20:36:55 -05:00
|
|
|
: fuel-eval-restartable ( -- )
|
2017-01-08 07:18:50 -05:00
|
|
|
t eval-res-flag set-global ; inline
|
2008-12-08 20:36:55 -05:00
|
|
|
|
|
|
|
: fuel-eval-non-restartable ( -- )
|
2017-01-08 07:18:50 -05:00
|
|
|
f eval-res-flag set-global ; inline
|
2008-12-08 20:36:55 -05:00
|
|
|
|
2009-01-11 18:52:31 -05:00
|
|
|
: fuel-eval-in-context ( lines in usings -- )
|
2017-01-08 07:18:50 -05:00
|
|
|
eval-in-context ;
|
2008-12-05 22:34:25 -05:00
|
|
|
|
2017-06-25 20:03:41 -04:00
|
|
|
: fuel-retort ( -- ) f f "" send-retort ; inline
|
2008-12-05 22:34:25 -05:00
|
|
|
|
2008-12-23 16:37:25 -05:00
|
|
|
! Loading files
|
|
|
|
|
2009-01-11 18:52:31 -05:00
|
|
|
<PRIVATE
|
|
|
|
|
2008-12-30 22:05:34 -05:00
|
|
|
SYMBOL: :uses
|
2009-04-15 19:12:31 -04:00
|
|
|
SYMBOL: :uses-suggestions
|
|
|
|
|
2018-01-22 14:33:27 -05:00
|
|
|
: is-use-restart? ( restart -- ? )
|
2009-04-15 19:12:31 -04:00
|
|
|
name>> [ "Use the " head? ] [ " vocabulary" tail? ] bi and ;
|
|
|
|
|
2009-04-19 17:52:24 -04:00
|
|
|
: get-restart-vocab ( restart -- vocab/f )
|
|
|
|
obj>> dup word? [ vocabulary>> ] [ drop f ] if ;
|
2009-04-15 19:12:31 -04:00
|
|
|
|
2018-01-22 14:33:27 -05:00
|
|
|
: is-suggested-restart? ( restart -- ? )
|
|
|
|
dup is-use-restart? [
|
2009-04-15 19:12:31 -04:00
|
|
|
get-restart-vocab :uses-suggestions get member?
|
|
|
|
] [ drop f ] if ;
|
|
|
|
|
|
|
|
: try-suggested-restarts ( -- )
|
2018-01-22 14:33:27 -05:00
|
|
|
restarts get [ is-suggested-restart? ] filter
|
2013-03-23 23:04:11 -04:00
|
|
|
dup length 1 = [ first continue-restart ] [ drop ] if ;
|
2008-12-30 22:05:34 -05:00
|
|
|
|
2018-02-07 12:38:28 -05:00
|
|
|
SYMBOL: auto-uses
|
|
|
|
|
2017-01-10 06:17:12 -05:00
|
|
|
: set-use-hook ( -- )
|
2018-02-07 12:38:28 -05:00
|
|
|
[
|
|
|
|
manifest get auto-used>> clone :uses prefix
|
|
|
|
clone auto-uses set-global
|
|
|
|
] print-use-hook set ;
|
2008-12-30 22:05:34 -05:00
|
|
|
|
2009-01-11 18:52:31 -05:00
|
|
|
PRIVATE>
|
|
|
|
|
2018-02-07 12:38:28 -05:00
|
|
|
: fuel-use-suggested-vocabs ( ..a suggestions quot: ( ..a -- ..b )
|
|
|
|
-- ..b result )
|
|
|
|
f auto-uses set-global
|
2009-04-15 19:12:31 -04:00
|
|
|
[ :uses-suggestions set ] dip
|
2018-02-07 12:38:28 -05:00
|
|
|
[ try-suggested-restarts rethrow ] recover
|
|
|
|
auto-uses get-global ; inline
|
2009-04-15 19:12:31 -04:00
|
|
|
|
2018-02-07 12:38:28 -05:00
|
|
|
: fuel-run-file ( path -- result )
|
|
|
|
f auto-uses set-global
|
|
|
|
'[ set-use-hook _ run-file ] with-scope
|
|
|
|
auto-uses get-global ; inline
|
2008-12-18 09:38:40 -05:00
|
|
|
|
2010-03-06 00:51:13 -05:00
|
|
|
: fuel-with-autouse ( ..a quot: ( ..a -- ..b ) -- ..b )
|
2018-02-07 12:38:28 -05:00
|
|
|
'[ set-use-hook _ call ] with-scope ; inline
|
2018-01-27 21:48:09 -05:00
|
|
|
|
|
|
|
: fuel-get-uses ( name lines -- )
|
|
|
|
'[
|
|
|
|
[
|
|
|
|
_ [
|
|
|
|
parser-quiet? on
|
|
|
|
_ parse-fresh drop
|
|
|
|
] with-source-file
|
|
|
|
] with-compilation-unit
|
|
|
|
] fuel-with-autouse ;
|
2008-12-23 16:37:25 -05:00
|
|
|
|
2008-12-17 18:49:01 -05:00
|
|
|
! Edit locations
|
2018-02-07 12:38:28 -05:00
|
|
|
: fuel-get-word-location ( word -- result )
|
|
|
|
word-location ;
|
2008-12-17 18:49:01 -05:00
|
|
|
|
2018-02-07 12:38:28 -05:00
|
|
|
: fuel-get-vocab-location ( vocab -- result )
|
|
|
|
vocab-location ;
|
2009-01-11 18:52:31 -05:00
|
|
|
|
2018-02-07 12:38:28 -05:00
|
|
|
: fuel-get-doc-location ( word -- result )
|
|
|
|
doc-location ;
|
2008-12-20 19:43:28 -05:00
|
|
|
|
2018-02-07 12:38:28 -05:00
|
|
|
: fuel-get-article-location ( name -- result )
|
|
|
|
article-location ;
|
2009-01-03 20:36:58 -05:00
|
|
|
|
2018-02-07 12:38:28 -05:00
|
|
|
: fuel-get-vocabs ( -- reuslt )
|
|
|
|
all-disk-vocab-names ;
|
2008-12-15 17:44:13 -05:00
|
|
|
|
2018-02-07 12:38:28 -05:00
|
|
|
: fuel-get-vocabs/prefix ( prefix -- result )
|
|
|
|
get-vocabs/prefix ;
|
2008-12-15 20:09:18 -05:00
|
|
|
|
2018-02-07 12:38:28 -05:00
|
|
|
: fuel-get-words ( prefix names -- result )
|
|
|
|
get-vocabs-words/prefix ;
|
2008-12-15 17:44:13 -05:00
|
|
|
|
2009-01-22 10:11:44 -05:00
|
|
|
! Cross-references
|
2008-12-15 17:44:13 -05:00
|
|
|
|
2018-02-07 12:38:28 -05:00
|
|
|
: fuel-callers-xref ( word -- result ) callers-xref ;
|
2009-01-11 18:52:31 -05:00
|
|
|
|
2018-02-07 12:38:28 -05:00
|
|
|
: fuel-callees-xref ( word -- result ) callees-xref ;
|
2009-01-11 18:52:31 -05:00
|
|
|
|
2018-02-07 12:38:28 -05:00
|
|
|
: fuel-apropos-xref ( str -- result ) apropos-xref ;
|
2009-01-11 18:52:31 -05:00
|
|
|
|
2018-02-07 12:38:28 -05:00
|
|
|
: fuel-vocab-xref ( vocab -- result ) vocab-xref ;
|
2008-12-05 22:34:25 -05:00
|
|
|
|
2018-02-07 12:38:28 -05:00
|
|
|
: fuel-vocab-uses-xref ( vocab -- result ) vocab-uses-xref ;
|
2009-01-22 15:13:38 -05:00
|
|
|
|
2018-02-07 12:38:28 -05:00
|
|
|
: fuel-vocab-usage-xref ( vocab -- result ) vocab-usage-xref ;
|
2009-01-22 15:13:38 -05:00
|
|
|
|
2009-01-03 10:37:28 -05:00
|
|
|
! Help support
|
|
|
|
|
2018-02-07 12:38:28 -05:00
|
|
|
: fuel-get-article ( name -- result )
|
|
|
|
fuel.help:get-article ;
|
2009-01-03 20:36:58 -05:00
|
|
|
|
2018-02-07 12:38:28 -05:00
|
|
|
: fuel-get-article-title ( name -- result )
|
|
|
|
articles get at [ article-title ] [ f ] if* ;
|
2009-01-03 20:36:58 -05:00
|
|
|
|
2018-02-07 12:38:28 -05:00
|
|
|
: fuel-word-help ( name -- result ) word-help ;
|
2009-01-06 17:08:33 -05:00
|
|
|
|
2018-02-07 12:38:28 -05:00
|
|
|
: fuel-word-def ( name -- result ) word-def ;
|
2009-01-12 22:06:21 -05:00
|
|
|
|
2018-02-07 12:38:28 -05:00
|
|
|
: fuel-vocab-help ( name -- result ) fuel.help:vocab-help ;
|
2009-01-06 17:08:33 -05:00
|
|
|
|
2018-02-07 12:38:28 -05:00
|
|
|
: fuel-word-synopsis ( word -- synopsis )
|
|
|
|
word-synopsis ;
|
2009-02-18 19:33:47 -05:00
|
|
|
|
2018-02-07 12:38:28 -05:00
|
|
|
: fuel-vocab-summary ( name -- summary )
|
|
|
|
fuel.help:vocab-summary ;
|
2009-01-06 17:08:33 -05:00
|
|
|
|
2018-02-07 12:38:28 -05:00
|
|
|
: fuel-index ( quot -- result )
|
|
|
|
call( -- seq ) format-index ;
|
2009-01-22 10:11:44 -05:00
|
|
|
|
2018-02-07 12:38:28 -05:00
|
|
|
: fuel-get-vocabs/tag ( tag -- result )
|
|
|
|
get-vocabs/tag ;
|
2009-01-06 17:08:33 -05:00
|
|
|
|
2018-02-07 12:38:28 -05:00
|
|
|
: fuel-get-vocabs/author ( author -- result )
|
|
|
|
get-vocabs/author ;
|
2009-01-11 18:52:31 -05:00
|
|
|
|
2009-01-11 14:07:34 -05:00
|
|
|
! Scaffold support
|
|
|
|
|
2017-01-10 06:17:12 -05:00
|
|
|
: scaffold-name ( devname -- )
|
2009-06-01 17:09:30 -04:00
|
|
|
[ developer-name set ] when* ;
|
|
|
|
|
2018-02-07 12:38:28 -05:00
|
|
|
: fuel-scaffold-vocab ( root name devname -- result )
|
2017-01-10 06:17:12 -05:00
|
|
|
[ scaffold-name dup [ scaffold-vocab ] dip ] with-scope
|
2018-02-07 12:38:28 -05:00
|
|
|
dup require vocab-source-path absolute-path ;
|
2009-01-11 14:07:34 -05:00
|
|
|
|
2018-02-07 12:38:28 -05:00
|
|
|
: fuel-scaffold-help ( name devname -- result )
|
2017-01-10 06:17:12 -05:00
|
|
|
[ scaffold-name dup require dup scaffold-docs ] with-scope
|
2018-02-07 12:38:28 -05:00
|
|
|
vocab-docs-path absolute-path ;
|
2009-01-11 20:10:13 -05:00
|
|
|
|
2018-02-07 12:38:28 -05:00
|
|
|
: fuel-scaffold-tests ( name devname -- result )
|
2017-01-10 06:17:12 -05:00
|
|
|
[ scaffold-name dup require dup scaffold-tests ] with-scope
|
2020-03-05 12:33:41 -05:00
|
|
|
vocab-tests-path absolute-path ;
|
2010-02-21 06:34:08 -05:00
|
|
|
|
2018-02-07 12:38:28 -05:00
|
|
|
: fuel-scaffold-authors ( name devname -- result )
|
2017-01-10 06:17:12 -05:00
|
|
|
[ scaffold-name dup require dup scaffold-authors ] with-scope
|
2020-03-05 12:33:41 -05:00
|
|
|
vocab-authors-path absolute-path ;
|
2010-02-21 06:34:08 -05:00
|
|
|
|
2018-02-07 12:38:28 -05:00
|
|
|
: fuel-scaffold-tags ( name tags -- result )
|
2010-02-21 06:34:08 -05:00
|
|
|
[ scaffold-tags ]
|
2020-03-05 12:33:41 -05:00
|
|
|
[ drop vocab-tags-path absolute-path ] 2bi ;
|
2010-02-21 06:34:08 -05:00
|
|
|
|
2018-02-07 12:38:28 -05:00
|
|
|
: fuel-scaffold-summary ( name summary -- result )
|
2010-02-21 06:34:08 -05:00
|
|
|
[ scaffold-summary ]
|
2020-03-05 12:33:41 -05:00
|
|
|
[ drop vocab-summary-path absolute-path ] 2bi ;
|
2010-02-21 06:34:08 -05:00
|
|
|
|
2018-02-07 12:38:28 -05:00
|
|
|
: fuel-scaffold-platforms ( name platforms -- result )
|
2010-02-22 23:17:49 -05:00
|
|
|
[ scaffold-platforms ]
|
2020-03-05 12:33:41 -05:00
|
|
|
[ drop vocab-platforms-path absolute-path ] 2bi ;
|
2010-02-22 23:17:49 -05:00
|
|
|
|
2018-02-07 12:38:28 -05:00
|
|
|
: fuel-scaffold-get-root ( name -- result )
|
|
|
|
find-vocab-root ;
|