Better command-line processing
parent
3b14c1970a
commit
a558f91d5d
|
@ -59,9 +59,9 @@ SYMBOL: bootstrap-time
|
||||||
"math compiler threads help io tools ui ui.tools unicode handbook" "include" set-global
|
"math compiler threads help io tools ui ui.tools unicode handbook" "include" set-global
|
||||||
"" "exclude" set-global
|
"" "exclude" set-global
|
||||||
|
|
||||||
parse-command-line
|
(command-line) parse-command-line
|
||||||
|
|
||||||
"-no-crossref" cli-args member? [ do-crossref ] unless
|
do-crossref
|
||||||
|
|
||||||
! Set dll paths
|
! Set dll paths
|
||||||
os wince? [ "windows.ce" require ] when
|
os wince? [ "windows.ce" require ] when
|
||||||
|
@ -92,12 +92,7 @@ SYMBOL: bootstrap-time
|
||||||
[
|
[
|
||||||
boot
|
boot
|
||||||
do-init-hooks
|
do-init-hooks
|
||||||
[
|
handle-command-line
|
||||||
parse-command-line
|
|
||||||
run-user-init
|
|
||||||
"run" get run
|
|
||||||
output-stream get [ stream-flush ] when*
|
|
||||||
] [ print-error 1 exit ] recover
|
|
||||||
] set-boot-quot
|
] set-boot-quot
|
||||||
|
|
||||||
millis swap - bootstrap-time set-global
|
millis swap - bootstrap-time set-global
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
USING: help.markup help.syntax parser vocabs.loader strings ;
|
USING: help.markup help.syntax parser vocabs.loader strings
|
||||||
|
command-line.private ;
|
||||||
IN: command-line
|
IN: command-line
|
||||||
|
|
||||||
HELP: run-bootstrap-init
|
HELP: run-bootstrap-init
|
||||||
|
@ -7,7 +8,10 @@ HELP: run-bootstrap-init
|
||||||
HELP: run-user-init
|
HELP: run-user-init
|
||||||
{ $description "Runs the startup initialization file in the user's home directory, unless the " { $snippet "-no-user-init" } " command line switch was given. This file is named " { $snippet ".factor-rc" } " on Unix and " { $snippet "factor-rc" } " on Windows." } ;
|
{ $description "Runs the startup initialization file in the user's home directory, unless the " { $snippet "-no-user-init" } " command line switch was given. This file is named " { $snippet ".factor-rc" } " on Unix and " { $snippet "factor-rc" } " on Windows." } ;
|
||||||
|
|
||||||
HELP: cli-param
|
HELP: load-vocab-roots
|
||||||
|
{ $description "Loads the newline-separated list of additional vocabulary roots from the file named " { $snippet ".factor-roots" } " on Unix and " { $snippet "factor-roots" } " on Windows." } ;
|
||||||
|
|
||||||
|
HELP: param
|
||||||
{ $values { "param" string } }
|
{ $values { "param" string } }
|
||||||
{ $description "Process a command-line switch."
|
{ $description "Process a command-line switch."
|
||||||
$nl
|
$nl
|
||||||
|
@ -17,10 +21,13 @@ $nl
|
||||||
$nl
|
$nl
|
||||||
"Otherwise, sets the global variable named by the parameter to " { $link t } "." } ;
|
"Otherwise, sets the global variable named by the parameter to " { $link t } "." } ;
|
||||||
|
|
||||||
HELP: cli-args
|
HELP: (command-line)
|
||||||
{ $values { "args" "a sequence of strings" } }
|
{ $values { "args" "a sequence of strings" } }
|
||||||
{ $description "Outputs the command line parameters which were passed to the Factor VM on startup." } ;
|
{ $description "Outputs the command line parameters which were passed to the Factor VM on startup." } ;
|
||||||
|
|
||||||
|
HELP: command-line
|
||||||
|
{ $var-description "The command line parameters which follow the name of the script on the command line." } ;
|
||||||
|
|
||||||
HELP: main-vocab-hook
|
HELP: main-vocab-hook
|
||||||
{ $var-description "Global variable holding a quotation which outputs a vocabulary name. UI backends set this so that the UI can automatically start if the prerequisites are met (for example, " { $snippet "$DISPLAY" } " being set on X11)." } ;
|
{ $var-description "Global variable holding a quotation which outputs a vocabulary name. UI backends set this so that the UI can automatically start if the prerequisites are met (for example, " { $snippet "$DISPLAY" } " being set on X11)." } ;
|
||||||
|
|
||||||
|
@ -35,9 +42,6 @@ HELP: ignore-cli-args?
|
||||||
{ $values { "?" "a boolean" } }
|
{ $values { "?" "a boolean" } }
|
||||||
{ $description "On Mac OS X, source files to run are supplied by the Cocoa API, so to avoid running them twice the startup code has to call this word." } ;
|
{ $description "On Mac OS X, source files to run are supplied by the Cocoa API, so to avoid running them twice the startup code has to call this word." } ;
|
||||||
|
|
||||||
HELP: parse-command-line
|
|
||||||
{ $description "Called on startup to process command line arguments. This sets global variables with " { $link cli-param } ", runs source files, and evaluates the string given by the " { $snippet "-e" } " switch, if there is one." } ;
|
|
||||||
|
|
||||||
ARTICLE: "runtime-cli-args" "Command line switches for the VM"
|
ARTICLE: "runtime-cli-args" "Command line switches for the VM"
|
||||||
"A handful of command line switches are processed by the VM and not the library. They control low-level features."
|
"A handful of command line switches are processed by the VM and not the library. They control low-level features."
|
||||||
{ $table
|
{ $table
|
||||||
|
@ -64,9 +68,12 @@ ARTICLE: "bootstrap-cli-args" "Command line switches for bootstrap"
|
||||||
}
|
}
|
||||||
"Bootstrap can load various optional components:"
|
"Bootstrap can load various optional components:"
|
||||||
{ $table
|
{ $table
|
||||||
|
{ { $snippet "math" } "Rational and complex number support." }
|
||||||
|
{ { $snippet "threads" } "Thread support." }
|
||||||
{ { $snippet "compiler" } "The compiler." }
|
{ { $snippet "compiler" } "The compiler." }
|
||||||
{ { $snippet "tools" } "Terminal-based developer tools." }
|
{ { $snippet "tools" } "Terminal-based developer tools." }
|
||||||
{ { $snippet "help" } "The help system." }
|
{ { $snippet "help" } "The help system." }
|
||||||
|
{ { $snippet "help.handbook" } "The help handbook." }
|
||||||
{ { $snippet "ui" } "The graphical user interface." }
|
{ { $snippet "ui" } "The graphical user interface." }
|
||||||
{ { $snippet "ui.tools" } "Graphical developer tools." }
|
{ { $snippet "ui.tools" } "Graphical developer tools." }
|
||||||
{ { $snippet "io" } "Non-blocking I/O and networking." }
|
{ { $snippet "io" } "Non-blocking I/O and networking." }
|
||||||
|
@ -86,7 +93,6 @@ ARTICLE: "standard-cli-args" "Command line switches for general usage"
|
||||||
{ { $snippet "-run=" { $emphasis "vocab" } } { { $snippet { $emphasis "vocab" } } " is the name of a vocabulary with a " { $link POSTPONE: MAIN: } " hook to run on startup, for example " { $vocab-link "listener" } ", " { $vocab-link "ui" } " or " { $vocab-link "none" } "." } }
|
{ { $snippet "-run=" { $emphasis "vocab" } } { { $snippet { $emphasis "vocab" } } " is the name of a vocabulary with a " { $link POSTPONE: MAIN: } " hook to run on startup, for example " { $vocab-link "listener" } ", " { $vocab-link "ui" } " or " { $vocab-link "none" } "." } }
|
||||||
{ { $snippet "-no-user-init" } { "Inhibits the running of user initialization files on startup. See " { $link "rc-files" } "." } }
|
{ { $snippet "-no-user-init" } { "Inhibits the running of user initialization files on startup. See " { $link "rc-files" } "." } }
|
||||||
{ { $snippet "-quiet" } { "If set, " { $link run-file } " and " { $link require } " will not print load messages." } }
|
{ { $snippet "-quiet" } { "If set, " { $link run-file } " and " { $link require } " will not print load messages." } }
|
||||||
{ { $snippet "-script" } { "Equivalent to " { $snippet "-quiet -run=none" } "." $nl "On Unix systems, Factor can be used for scripting - just create an executable text file whose first line is:" { $code "#! /usr/local/bin/factor -script" } "The space after " { $snippet "#!" } " is necessary because of Factor syntax." } }
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
ARTICLE: "factor-boot-rc" "Bootstrap initialization file"
|
ARTICLE: "factor-boot-rc" "Bootstrap initialization file"
|
||||||
|
@ -102,11 +108,18 @@ $nl
|
||||||
"A word to run this file from an existing Factor session:"
|
"A word to run this file from an existing Factor session:"
|
||||||
{ $subsection run-user-init } ;
|
{ $subsection run-user-init } ;
|
||||||
|
|
||||||
|
ARTICLE: "factor-roots" "Additional vocabulary roots file"
|
||||||
|
"The vocabulary roots file is named " { $snippet "factor-roots" } " on Windows and " { $snippet ".factor-roots" } " on Unix. If it exists, it is loaded every time Factor starts. It contains a newline-separated list of " { $link "vocabs.roots" } "."
|
||||||
|
$nl
|
||||||
|
"A word to run this file from an existing Factor session:"
|
||||||
|
{ $subsection load-vocab-roots } ;
|
||||||
|
|
||||||
ARTICLE: "rc-files" "Running code on startup"
|
ARTICLE: "rc-files" "Running code on startup"
|
||||||
"Factor looks for two files in your home directory."
|
"Factor looks for three optional files in your home directory."
|
||||||
{ $subsection "factor-boot-rc" }
|
{ $subsection "factor-boot-rc" }
|
||||||
{ $subsection "factor-rc" }
|
{ $subsection "factor-rc" }
|
||||||
"The " { $snippet "-no-user-init" } " command line switch will inhibit the running of these files."
|
{ $subsection "factor-roots" }
|
||||||
|
"The " { $snippet "-no-user-init" } " command line switch will inhibit loading running of these files."
|
||||||
$nl
|
$nl
|
||||||
"If you are unsure where the files should be located, evaluate the following code:"
|
"If you are unsure where the files should be located, evaluate the following code:"
|
||||||
{ $code
|
{ $code
|
||||||
|
@ -122,8 +135,16 @@ $nl
|
||||||
"100 dpi set-global"
|
"100 dpi set-global"
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
ARTICLE: "cli" "Command line usage"
|
ARTICLE: "cli" "Command line arguments"
|
||||||
"Zero or more command line arguments may be passed to the Factor runtime. Command line arguments starting with a dash (" { $snippet "-" } ") is interpreted as switches. All other arguments are taken to be file names to be run by " { $link run-file } "."
|
"Factor command line usage:"
|
||||||
|
{ $code "factor [system switches...] [script args...]" }
|
||||||
|
"Zero or more system switches can be passed in, followed by an optional script file name. If the script file is specified, it will be run on startup, any arguments after the script file are stored in a variable, with no further processing by Factor itself:"
|
||||||
|
{ $subsection command-line }
|
||||||
|
"Instead of running a script, it is also possible to run a vocabulary; this invokes the vocabulary's " { $link POSTPONE: MAIN: } " word:"
|
||||||
|
{ $code "factor [system switches...] -run=<vocab name>" }
|
||||||
|
"If no script file or " { $snippet "-run=" } " switch is specified, Factor will start " { $link "listener" } " or " { $link "ui-tools" } ", depending on the operating system."
|
||||||
|
$nl
|
||||||
|
"As stated above, arguments in the first part of the command line, before the optional script name, are interpreted by to the Factor system. These arguments all start with a dash (" { $snippet "-" } ")."
|
||||||
$nl
|
$nl
|
||||||
"Switches can take one of the following three forms:"
|
"Switches can take one of the following three forms:"
|
||||||
{ $list
|
{ $list
|
||||||
|
@ -134,9 +155,9 @@ $nl
|
||||||
{ $subsection "runtime-cli-args" }
|
{ $subsection "runtime-cli-args" }
|
||||||
{ $subsection "bootstrap-cli-args" }
|
{ $subsection "bootstrap-cli-args" }
|
||||||
{ $subsection "standard-cli-args" }
|
{ $subsection "standard-cli-args" }
|
||||||
"The list of command line arguments can be obtained and inspected directly:"
|
"The raw list of command line arguments can also be obtained and inspected directly:"
|
||||||
{ $subsection cli-args }
|
{ $subsection (command-line) }
|
||||||
"There is a way to override the default vocabulary to run on startup:"
|
"There is a way to override the default vocabulary to run on startup, if no script name or " { $snippet "-run" } " switch is specified:"
|
||||||
{ $subsection main-vocab-hook } ;
|
{ $subsection main-vocab-hook } ;
|
||||||
|
|
||||||
ABOUT: "cli"
|
ABOUT: "cli"
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
! Copyright (C) 2003, 2008 Slava Pestov.
|
! Copyright (C) 2003, 2008 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: init continuations debugger hashtables io kernel
|
USING: init continuations debugger hashtables io
|
||||||
kernel.private namespaces parser sequences strings system
|
io.encodings.utf8 io.files kernel kernel.private namespaces
|
||||||
splitting io.files eval ;
|
parser sequences strings system splitting eval vocabs.loader ;
|
||||||
IN: command-line
|
IN: command-line
|
||||||
|
|
||||||
|
SYMBOL: script
|
||||||
|
SYMBOL: command-line
|
||||||
|
|
||||||
|
: (command-line) ( -- args ) 10 getenv sift ;
|
||||||
|
|
||||||
: rc-path ( name -- path )
|
: rc-path ( name -- path )
|
||||||
os windows? [ "." prepend ] unless
|
os windows? [ "." prepend ] unless
|
||||||
home prepend-path ;
|
home prepend-path ;
|
||||||
|
@ -19,17 +24,33 @@ IN: command-line
|
||||||
"factor-rc" rc-path ?run-file
|
"factor-rc" rc-path ?run-file
|
||||||
] when ;
|
] when ;
|
||||||
|
|
||||||
: cli-var-param ( name value -- ) swap set-global ;
|
: load-vocab-roots ( -- )
|
||||||
|
"user-init" get [
|
||||||
|
"factor-roots" rc-path dup exists? [
|
||||||
|
utf8 file-lines [ add-vocab-root ] each
|
||||||
|
] [ drop ] if
|
||||||
|
] when ;
|
||||||
|
|
||||||
: cli-bool-param ( name -- ) "no-" ?head not cli-var-param ;
|
<PRIVATE
|
||||||
|
|
||||||
: cli-param ( param -- )
|
: var-param ( name value -- ) swap set-global ;
|
||||||
"=" split1 [ cli-var-param ] [ cli-bool-param ] if* ;
|
|
||||||
|
|
||||||
: cli-arg ( argument -- argument )
|
: bool-param ( name -- ) "no-" ?head not var-param ;
|
||||||
"-" ?head [ cli-param f ] when ;
|
|
||||||
|
|
||||||
: cli-args ( -- args ) 10 getenv ;
|
: param ( param -- )
|
||||||
|
"=" split1 [ var-param ] [ bool-param ] if* ;
|
||||||
|
|
||||||
|
: run-script ( file -- )
|
||||||
|
t "quiet" set-global run-file ;
|
||||||
|
|
||||||
|
PRIVATE>
|
||||||
|
|
||||||
|
: parse-command-line ( args -- )
|
||||||
|
[ command-line off script off ] [
|
||||||
|
unclip "-" ?head
|
||||||
|
[ param parse-command-line ]
|
||||||
|
[ script set command-line set ] if
|
||||||
|
] if-empty ;
|
||||||
|
|
||||||
SYMBOL: main-vocab-hook
|
SYMBOL: main-vocab-hook
|
||||||
|
|
||||||
|
@ -53,14 +74,17 @@ SYMBOL: main-vocab-hook
|
||||||
: ignore-cli-args? ( -- ? )
|
: ignore-cli-args? ( -- ? )
|
||||||
os macosx? "run" get "ui" = and ;
|
os macosx? "run" get "ui" = and ;
|
||||||
|
|
||||||
: script-mode ( -- )
|
: script-mode ( -- ) ;
|
||||||
t "quiet" set-global
|
|
||||||
"none" "run" set-global ;
|
|
||||||
|
|
||||||
: parse-command-line ( -- )
|
: handle-command-line ( -- )
|
||||||
cli-args [ cli-arg ] filter
|
[
|
||||||
"script" get [ script-mode ] when
|
(command-line) parse-command-line
|
||||||
ignore-cli-args? [ drop ] [ [ run-file ] each ] if
|
load-vocab-roots
|
||||||
"e" get [ eval ] when* ;
|
run-user-init
|
||||||
|
"e" get [ eval ] when*
|
||||||
|
ignore-cli-args? not script get and
|
||||||
|
[ run-script ] [ "run" get run ] if*
|
||||||
|
output-stream get [ stream-flush ] when*
|
||||||
|
] [ print-error 1 exit ] recover ;
|
||||||
|
|
||||||
[ default-cli-args ] "command-line" add-init-hook
|
[ default-cli-args ] "command-line" add-init-hook
|
||||||
|
|
|
@ -307,7 +307,7 @@ FUNCTION: bool check_sse2 ( ) ;
|
||||||
: sse2? ( -- ? )
|
: sse2? ( -- ? )
|
||||||
check_sse2 ;
|
check_sse2 ;
|
||||||
|
|
||||||
"-no-sse2" cli-args member? [
|
"-no-sse2" (command-line) member? [
|
||||||
[ optimized-recompile-hook ] recompile-hook
|
[ optimized-recompile-hook ] recompile-hook
|
||||||
[ { check_sse2 } compile ] with-variable
|
[ { check_sse2 } compile ] with-variable
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
USING: help.markup help.syntax io kernel math namespaces parser
|
USING: help.markup help.syntax io kernel math namespaces parser
|
||||||
prettyprint sequences vocabs.loader namespaces stack-checker
|
prettyprint sequences vocabs.loader namespaces stack-checker
|
||||||
help ;
|
help command-line multiline ;
|
||||||
IN: help.cookbook
|
IN: help.cookbook
|
||||||
|
|
||||||
ARTICLE: "cookbook-syntax" "Basic syntax cookbook"
|
ARTICLE: "cookbook-syntax" "Basic syntax cookbook"
|
||||||
|
@ -263,11 +263,30 @@ ARTICLE: "cookbook-application" "Application cookbook"
|
||||||
ARTICLE: "cookbook-scripts" "Scripting cookbook"
|
ARTICLE: "cookbook-scripts" "Scripting cookbook"
|
||||||
"Factor can be used for command-line scripting on Unix-like systems."
|
"Factor can be used for command-line scripting on Unix-like systems."
|
||||||
$nl
|
$nl
|
||||||
"A text file can begin with a comment like the following, and made executable:"
|
"To run a script, simply pass it as an argument to the Factor executable:"
|
||||||
{ $code "#! /usr/bin/env factor -script" }
|
{ $code "./factor cleanup.factor" }
|
||||||
"Running the text file will run it through Factor, assuming the " { $snippet "factor" } " binary is in your " { $snippet "$PATH" } "."
|
"The script may access command line arguments by inspecting the value of the " { $link command-line } " variable. It can also get its own path from the " { $link script } " variable."
|
||||||
$nl
|
$nl
|
||||||
"The space between " { $snippet "#!" } " and " { $snippet "/usr/bin/env" } " is necessary, since " { $link POSTPONE: #! } " is a parsing word, and a syntax error would otherwise result. The " { $snippet "-script" } " switch suppresses compiler messages, and exits Factor when the script finishes."
|
"Here is an example implementing a simplified version of the Unix " { $snippet "ls" } " command in Factor:"
|
||||||
|
{ $code
|
||||||
|
<" USING: command-line namespaces io io.files io.files.listing
|
||||||
|
sequences kernel ;
|
||||||
|
|
||||||
|
command-line get [
|
||||||
|
current-directory get directory.
|
||||||
|
] [
|
||||||
|
dup length 1 = [ first directory. ] [
|
||||||
|
[ [ nl write ":" print ] [ directory. ] bi ] each
|
||||||
|
] if
|
||||||
|
] if-empty">
|
||||||
|
}
|
||||||
|
"You can put it in a file named " { $snippet "ls.factor" } ", and then run it, to list the " { $snippet "/usr/bin" } " directory for example:"
|
||||||
|
{ $code "./factor ls.factor /usr/bin" }
|
||||||
|
"It is also possible to make executable scripts. A Factor file can begin with a comment like the following:"
|
||||||
|
{ $code "#! /usr/bin/env factor" }
|
||||||
|
"If the text file is made executable, then it can be run, assuming the " { $snippet "factor" } " binary is in your " { $snippet "$PATH" } "."
|
||||||
|
$nl
|
||||||
|
"The space between " { $snippet "#!" } " and " { $snippet "/usr/bin/env" } " is necessary, since " { $link POSTPONE: #! } " is a parsing word, and a syntax error would otherwise result."
|
||||||
{ $references
|
{ $references
|
||||||
{ }
|
{ }
|
||||||
"cli"
|
"cli"
|
||||||
|
|
|
@ -54,7 +54,6 @@ TR: convert-separators "/\\" ".." ;
|
||||||
[ monitor-thread ] "Vocabulary monitor" spawn drop ;
|
[ monitor-thread ] "Vocabulary monitor" spawn drop ;
|
||||||
|
|
||||||
[
|
[
|
||||||
"-no-monitors" cli-args member? [
|
"-no-monitors" (command-line) member?
|
||||||
start-monitor-thread
|
[ start-monitor-thread ] unless
|
||||||
] unless
|
|
||||||
] "tools.vocabs.monitor" add-init-hook
|
] "tools.vocabs.monitor" add-init-hook
|
||||||
|
|
|
@ -12,12 +12,12 @@ ARTICLE: "vocabs.roots" "Vocabulary roots"
|
||||||
{ { $snippet "extra" } " - additional contributed libraries." }
|
{ { $snippet "extra" } " - additional contributed libraries." }
|
||||||
{ { $snippet "work" } " - a root for vocabularies which are not intended to be contributed back to Factor." }
|
{ { $snippet "work" } " - a root for vocabularies which are not intended to be contributed back to Factor." }
|
||||||
}
|
}
|
||||||
"Your own vocabularies should go into " { $snippet "extra" } " or " { $snippet "work" } ", depending on whether or not you intend to contribute them back to the Factor project. If you wish to work on vocabularies outside of the Factor source directory, create a " { $link "factor-boot-rc" } " file like the following:"
|
"You can store your own vocabularies in the " { $snippet "work" } " directory. You can also store code outside of the Factor source tree by making Factor aware of it first. There are two ways of doing this."
|
||||||
{ $code
|
$nl
|
||||||
"USING: namespaces sequences vocabs.loader ;"
|
"You can list additional vocabulary roots in a file that Factor reads at startup:"
|
||||||
"\"/home/jane/sources/\" vocab-roots get push"
|
{ $subsection "factor-roots" }
|
||||||
}
|
"Or you can add them dynamically using a word:"
|
||||||
"See " { $link "rc-files" } " for details." ;
|
{ $subsection add-vocab-root } ;
|
||||||
|
|
||||||
ARTICLE: "vocabs.loader" "Vocabulary loader"
|
ARTICLE: "vocabs.loader" "Vocabulary loader"
|
||||||
"The vocabulary loader is defined in the " { $vocab-link "vocabs.loader" } " vocabulary."
|
"The vocabulary loader is defined in the " { $vocab-link "vocabs.loader" } " vocabulary."
|
||||||
|
@ -57,6 +57,11 @@ HELP: vocab-main
|
||||||
HELP: vocab-roots
|
HELP: vocab-roots
|
||||||
{ $var-description "A sequence of pathname strings to search for vocabularies." } ;
|
{ $var-description "A sequence of pathname strings to search for vocabularies." } ;
|
||||||
|
|
||||||
|
HELP: add-vocab-root
|
||||||
|
{ $values { "path" "a pathname string" } }
|
||||||
|
{ $description "Adds a directory pathname to the list of vocabulary roots." }
|
||||||
|
{ $see-also "factor-roots" } ;
|
||||||
|
|
||||||
HELP: find-vocab-root
|
HELP: find-vocab-root
|
||||||
{ $values { "vocab" "a vocabulary specifier" } { "path/f" "a pathname string" } }
|
{ $values { "vocab" "a vocabulary specifier" } { "path/f" "a pathname string" } }
|
||||||
{ $description "Searches for a vocabulary in the vocabulary roots." } ;
|
{ $description "Searches for a vocabulary in the vocabulary roots." } ;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
USING: namespaces make sequences io.files kernel assocs words
|
USING: namespaces make sequences io.files kernel assocs words
|
||||||
vocabs definitions parser continuations io hashtables sorting
|
vocabs definitions parser continuations io hashtables sorting
|
||||||
source-files arrays combinators strings system math.parser
|
source-files arrays combinators strings system math.parser
|
||||||
compiler.errors splitting init accessors ;
|
compiler.errors splitting init accessors sets ;
|
||||||
IN: vocabs.loader
|
IN: vocabs.loader
|
||||||
|
|
||||||
SYMBOL: vocab-roots
|
SYMBOL: vocab-roots
|
||||||
|
@ -15,6 +15,9 @@ V{
|
||||||
"resource:work"
|
"resource:work"
|
||||||
} clone vocab-roots set-global
|
} clone vocab-roots set-global
|
||||||
|
|
||||||
|
: add-vocab-root ( root -- )
|
||||||
|
vocab-roots get adjoin ;
|
||||||
|
|
||||||
: vocab-dir ( vocab -- dir )
|
: vocab-dir ( vocab -- dir )
|
||||||
vocab-name { { CHAR: . CHAR: / } } substitute ;
|
vocab-name { { CHAR: . CHAR: / } } substitute ;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue