]> gitweb.factorcode.org Git - factor.git/commitdiff
core: Add auto-use to syntax and add -ea parameter to factor command line.
authorDoug Coleman <doug.coleman@gmail.com>
Tue, 21 Dec 2021 21:15:15 +0000 (15:15 -0600)
committerDoug Coleman <doug.coleman@gmail.com>
Tue, 21 Dec 2021 21:18:34 +0000 (15:18 -0600)
./factor -ea="..." will now auto-use

Both of these now work:
./factor -ea="1 1 + ."
./factor -e="auto-use 1 1 + ."

README.md
basis/command-line/startup/startup.factor
core/bootstrap/syntax.factor
core/parser/parser.factor
core/syntax/syntax.factor

index 859eebe6d09da7424628096ef1620728668c28ce..c127539d690d43c3bc290152b0ec5085ae6cf277 100644 (file)
--- a/README.md
+++ b/README.md
@@ -112,6 +112,7 @@ Common arguments:
         -run=listener    run terminal listener
         -run=ui.tools    run Factor development UI
     -e=<code>        evaluate <code>
+    -ea=<code>       evaluate <code> with auto-use
     -no-user-init    suppress loading of .factor-rc
     -roots=<paths>   a list of path-delimited extra vocab roots
 
index d046fe281dfc0bfc14ce3d613a680d6643fe79d8..27c7071286b56e2b302c3981c277f86375b242c5 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2011 Joe Groff.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: combinators command-line eval io io.pathnames kernel
-layouts math math.parser namespaces system vocabs.loader ;
+layouts math math.parser namespaces parser system vocabs.loader ;
 IN: command-line.startup
 
 : help? ( -- ? )
@@ -19,6 +19,7 @@ Options:
         -run=listener   run terminal listener
         -run=ui.tools   run Factor development UI
     -e=<code>           evaluate <code>
+    -ea=<code>          evaluate <code> with auto-use
     -no-user-init       suppress loading of .factor-rc
     -datastack=<int>    datastack size in KiB [" write cell 32 * number>string write "]
     -retainstack=<int>  retainstack size in KiB [" write cell 32 * number>string write "]
@@ -49,8 +50,9 @@ from within Factor for more information.
         [
             load-vocab-roots
             run-user-init
-            "e" get script get or [
+            "e" get "ea" get script get or or [
                 "e" get [ eval( -- ) ] when*
+                "ea" get [ t auto-use? [ eval( -- ) ] with-variable ] when*
                 script get [ run-script ] when*
             ] [
                 "run" get run
index 0ba566bb8c706b17bd54f5c3f01534e81846bbec..60d573b43a21e27a2f3cb88a4e9250dd7cc5fab6 100644 (file)
@@ -67,6 +67,7 @@ IN: bootstrap.syntax
         "\\"
         "M\\"
         "]"
+        "auto-use"
         "delimiter"
         "deprecated"
         "f"
index be7fdb106a129d90e56727b871e421691b9c1820..25e5175d13880e5943f2cef091ac851d6be2e14d 100644 (file)
@@ -21,8 +21,6 @@ M: parsing-word stack-effect drop ( parsed -- parsed ) ;
 
 SYMBOL: auto-use?
 
-: auto-use ( -- ) auto-use? on ;
-
 : no-word-restarted ( restart-value -- word )
     dup word? [
         dup vocabulary>>
index d0797897df5018132aa7c5a0d0d944db05cb0e76..7a181425b2b2a0797c333afb38048fc436d1b501 100644 (file)
@@ -105,12 +105,13 @@ IN: bootstrap.syntax
     "POSTPONE:" [ scan-word suffix! ] define-core-syntax
     "\\" [ scan-word <wrapper> suffix! ] define-core-syntax
     "M\\" [ scan-word scan-word lookup-method <wrapper> suffix! ] define-core-syntax
-    "inline" [ last-word make-inline ] define-core-syntax
-    "recursive" [ last-word make-recursive ] define-core-syntax
-    "foldable" [ last-word make-foldable ] define-core-syntax
-    "flushable" [ last-word make-flushable ] define-core-syntax
+    "auto-use" [ auto-use? on ] define-core-syntax
     "delimiter" [ last-word t "delimiter" set-word-prop ] define-core-syntax
     "deprecated" [ last-word make-deprecated ] define-core-syntax
+    "flushable" [ last-word make-flushable ] define-core-syntax
+    "foldable" [ last-word make-foldable ] define-core-syntax
+    "inline" [ last-word make-inline ] define-core-syntax
+    "recursive" [ last-word make-recursive ] define-core-syntax
 
     "SYNTAX:" [
         scan-new-word parse-definition define-syntax