]> gitweb.factorcode.org Git - factor.git/commitdiff
command-line, parser, syntax: move the MAIN: invocation from run-file to run-script...
authorJoe Groff <arcata@gmail.com>
Thu, 18 Aug 2011 04:29:02 +0000 (21:29 -0700)
committerJoe Groff <arcata@gmail.com>
Thu, 18 Aug 2011 04:29:02 +0000 (21:29 -0700)
basis/command-line/command-line-docs.factor
basis/command-line/command-line.factor
core/parser/parser-docs.factor
core/parser/parser.factor
core/syntax/syntax-docs.factor

index 264e4e8c8bee9b4d9f3faf06af200d9811bdb4b2..db9a6b8e121d957642718d42296e3011de7a4833 100644 (file)
@@ -135,7 +135,7 @@ $nl
 ARTICLE: "cli" "Command line arguments"
 "Factor command line usage:"
 { $code "factor [VM args...] [script] [args...]" }
-"Zero or more VM arguments can be passed in, followed by an optional script file name. If the script file is specified, it will be run on startup using " { $link run-file } ". Any arguments after the script file are stored in the following variable, with no further processing by Factor itself:"
+"Zero or more VM arguments can be passed in, followed by an optional script file name. If the script file is specified, it will be run on startup using " { $link run-script } ". Any arguments after the script file are stored in the following variable, with no further processing by Factor itself:"
 { $subsections 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>" }
@@ -159,4 +159,9 @@ $nl
 "There is a way to override the default vocabulary to run on startup, if no script name or " { $snippet "-run" } " switch is specified:"
 { $subsections main-vocab-hook } ;
 
+HELP: run-script
+{ $values { "file" "a pathname string" } }
+{ $description "Parses the Factor source code stored in a file and runs it. The initial vocabulary search path is used. If the source file contains a " { $link POSTPONE: MAIN: } " declaration, the main entry point of the file will be also be executed. Loading messages will be suppressed." }
+{ $errors "Throws an error if loading the file fails, there input is malformed, or if a runtime error occurs while calling the parsed quotation or executing the main entry point." }  ;
+
 ABOUT: "cli"
index 88ade747d2b3cc5d0f5fb1120128f7a55e5cfedd..e902bbc396f3cb2d9b7a3d9e66f147055f98f2a4 100644 (file)
@@ -2,7 +2,8 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: init continuations hashtables io io.encodings.utf8
 io.files io.pathnames kernel kernel.private namespaces parser
-sequences strings system splitting vocabs.loader alien.strings ;
+sequences source-files strings system splitting vocabs.loader
+alien.strings accessors ;
 IN: command-line
 
 SYMBOL: script
@@ -39,7 +40,10 @@ SYMBOL: command-line
     "=" split1 [ var-param ] [ bool-param ] if* ;
 
 : run-script ( file -- )
-    t "quiet" set-global run-file ;
+    t "quiet" [
+        [ run-file ]
+        [ source-file main>> [ execute( -- ) ] when* ] bi
+    ] with-variable ;
 
 : parse-command-line ( args -- )
     [ command-line off script off ] [
index aadd651a01ba5fea3496131ef441401fde09b7a1..24ddc0b7c9f82d1ed83758bbb3bdae6266f6e4de 100644 (file)
@@ -238,8 +238,8 @@ HELP: parse-file
 
 HELP: run-file
 { $values { "file" "a pathname string" } }
-{ $description "Parses the Factor source code stored in a file and runs it. The initial vocabulary search path is used. If the source file contains a " { $link POSTPONE: MAIN: } " declaration, the main entry point of the file will be also be executed." }
-{ $errors "Throws an error if loading the file fails, there input is malformed, or if a runtime error occurs while calling the parsed quotation or executing the main entry point." } ;
+{ $description "Parses the Factor source code stored in a file and runs it. The initial vocabulary search path is used." }
+{ $errors "Throws an error if loading the file fails, there input is malformed, or if a runtime error occurs while calling the parsed quotation." }  ;
 
 HELP: ?run-file
 { $values { "path" "a pathname string" } }
index f9883837fb0bbe8187741a7b21a1f92cf4a2b9d7..be43979b31a6181b9f89cf5ab1096cfc89acad47 100644 (file)
@@ -203,8 +203,7 @@ print-use-hook [ [ ] ] initialize
     ] recover ;
 
 : run-file ( file -- )
-    [ parse-file call( -- ) ]
-    [ source-file main>> [ execute( -- ) ] when* ] bi ;
+    parse-file call( -- ) ;
 
 : ?run-file ( path -- )
     dup exists? [ run-file ] [ drop ] if ;
index 7fda5b406b4b0a98e3c3d4435c44c797673042e1..0472d6394d07a2b673c7e3ab3cfad956716824c0 100644 (file)
@@ -1,7 +1,7 @@
 USING: generic help.syntax help.markup kernel math parser words
 effects classes classes.tuple generic.math generic.single arrays
 io.pathnames vocabs.loader io sequences assocs words.symbol
-words.alias words.constant combinators vocabs.parser ;
+words.alias words.constant combinators vocabs.parser command-line ;
 IN: syntax
 
 ARTICLE: "parser-algorithm" "Parser algorithm"
@@ -858,7 +858,7 @@ HELP: C:
 HELP: MAIN:
 { $syntax "MAIN: word" }
 { $values { "word" word } }
-{ $description "Defines the main entry point for the current vocabulary and source file. This word will be executed when this vocabulary is passed to " { $link run } " or the source file is passed to " { $link run-file } "." } ;
+{ $description "Defines the main entry point for the current vocabulary and source file. This word will be executed when this vocabulary is passed to " { $link run } " or the source file is passed to " { $link run-script } "." } ;
 
 HELP: <PRIVATE
 { $syntax "<PRIVATE ... PRIVATE>" }