From 507a22111e605804dede90e00abdd80c73826b04 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Tue, 21 Dec 2021 15:15:15 -0600 Subject: [PATCH] core: Add auto-use to syntax and add -ea parameter to factor command line. ./factor -ea="..." will now auto-use Both of these now work: ./factor -ea="1 1 + ." ./factor -e="auto-use 1 1 + ." --- README.md | 1 + basis/command-line/startup/startup.factor | 6 ++++-- core/bootstrap/syntax.factor | 1 + core/parser/parser.factor | 2 -- core/syntax/syntax.factor | 9 +++++---- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 859eebe6d0..c127539d69 100644 --- 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= evaluate + -ea= evaluate with auto-use -no-user-init suppress loading of .factor-rc -roots= a list of path-delimited extra vocab roots diff --git a/basis/command-line/startup/startup.factor b/basis/command-line/startup/startup.factor index d046fe281d..27c7071286 100644 --- a/basis/command-line/startup/startup.factor +++ b/basis/command-line/startup/startup.factor @@ -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= evaluate + -ea= evaluate with auto-use -no-user-init suppress loading of .factor-rc -datastack= datastack size in KiB [" write cell 32 * number>string write "] -retainstack= 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 diff --git a/core/bootstrap/syntax.factor b/core/bootstrap/syntax.factor index 0ba566bb8c..60d573b43a 100644 --- a/core/bootstrap/syntax.factor +++ b/core/bootstrap/syntax.factor @@ -67,6 +67,7 @@ IN: bootstrap.syntax "\\" "M\\" "]" + "auto-use" "delimiter" "deprecated" "f" diff --git a/core/parser/parser.factor b/core/parser/parser.factor index be7fdb106a..25e5175d13 100644 --- a/core/parser/parser.factor +++ b/core/parser/parser.factor @@ -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>> diff --git a/core/syntax/syntax.factor b/core/syntax/syntax.factor index d0797897df..7a181425b2 100644 --- a/core/syntax/syntax.factor +++ b/core/syntax/syntax.factor @@ -105,12 +105,13 @@ IN: bootstrap.syntax "POSTPONE:" [ scan-word suffix! ] define-core-syntax "\\" [ scan-word suffix! ] define-core-syntax "M\\" [ scan-word scan-word lookup-method 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 -- 2.34.1