From 91b3b7e8fc5fabfc4592e08db79d78fba5917d8f Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Mon, 20 Oct 2008 04:13:52 -0500 Subject: [PATCH 01/86] add function --- basis/unix/stat/netbsd/netbsd.factor | 1 + 1 file changed, 1 insertion(+) diff --git a/basis/unix/stat/netbsd/netbsd.factor b/basis/unix/stat/netbsd/netbsd.factor index aefa9fd2cf..0bcb886417 100644 --- a/basis/unix/stat/netbsd/netbsd.factor +++ b/basis/unix/stat/netbsd/netbsd.factor @@ -35,3 +35,4 @@ C-STRUCT: statvfs { { "char" _VFS_NAMELEN } "f_mntonname" } { { "char" _VFS_NAMELEN } "f_mntfromname" } ; +FUNCTION: int statvfs ( char* path, statvfs* buf ) ; From 001dc3b2518d6549b93ff7c493040b84e997f69e Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Mon, 22 Dec 2008 06:42:08 -0800 Subject: [PATCH 02/86] Cleanup uuid a bit more, thanks Slava! --- basis/uuid/uuid.factor | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/basis/uuid/uuid.factor b/basis/uuid/uuid.factor index 337ea22df5..209485b3bc 100644 --- a/basis/uuid/uuid.factor +++ b/basis/uuid/uuid.factor @@ -52,13 +52,10 @@ IN: uuid : string>uuid ( string -- n ) [ CHAR: - = not ] filter 16 base> ; -: uuid>byte-array ( n -- byte-array ) - 16 >be ; - PRIVATE> : uuid-parse ( string -- byte-array ) - string>uuid uuid>byte-array ; + string>uuid 16 >be ; : uuid-unparse ( byte-array -- string ) be> uuid>string ; From 8bb9429589055b51434a8147a5b1ddb93313253e Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 26 Jan 2009 15:47:52 -0800 Subject: [PATCH 03/86] ensure accumulator comes back as a vector from literals --- extra/literals/literals-tests.factor | 6 ++++++ extra/literals/literals.factor | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/extra/literals/literals-tests.factor b/extra/literals/literals-tests.factor index 185d672dd3..34ea4d6415 100644 --- a/extra/literals/literals-tests.factor +++ b/extra/literals/literals-tests.factor @@ -11,4 +11,10 @@ IN: literals.tests [ { 7 11 } ] [ { $ seven-eleven } ] unit-test [ { 6 6 6 } ] [ { $ six-six-six } ] unit-test +[ { 6 6 6 7 } ] [ { $ six-six-six 7 } ] unit-test + [ { 8 8 8 } ] [ { $[ six-six-six [ 2 + ] tri@ ] } ] unit-test + +[ { 0.5 2.0 } ] [ { $[ 1.0 2.0 / ] 2.0 } ] unit-test + +[ { 1.0 { 0.5 1.5 } 4.0 } ] [ { 1.0 { $[ 1.0 2.0 / ] 1.5 } $[ 2.0 2.0 * ] } ] unit-test diff --git a/extra/literals/literals.factor b/extra/literals/literals.factor index a450c2118e..6df51a35ef 100644 --- a/extra/literals/literals.factor +++ b/extra/literals/literals.factor @@ -1,6 +1,6 @@ ! (c) Joe Groff, see license for details -USING: continuations kernel parser words quotations ; +USING: continuations kernel parser words quotations vectors ; IN: literals -: $ scan-word [ execute ] curry with-datastack ; parsing -: $[ \ ] parse-until >quotation with-datastack ; parsing +: $ scan-word [ execute ] curry with-datastack >vector ; parsing +: $[ \ ] parse-until >quotation with-datastack >vector ; parsing From 3ad52dd85b3f371f8fdb4ad9924979a74596c6ec Mon Sep 17 00:00:00 2001 From: "Jose A. Ortega Ruiz" Date: Wed, 28 Jan 2009 21:23:21 +0100 Subject: [PATCH 04/86] FUEL: New refactoring: extract region as ARTICLE: (C-cC-xa). --- misc/fuel/README | 1 + misc/fuel/fuel-mode.el | 1 + misc/fuel/fuel-refactor.el | 47 ++++++++++++++++++++++++++++++-------- misc/fuel/fuel-syntax.el | 7 +++--- 4 files changed, 43 insertions(+), 13 deletions(-) diff --git a/misc/fuel/README b/misc/fuel/README index cf96e29f52..198c9bb275 100644 --- a/misc/fuel/README +++ b/misc/fuel/README @@ -129,6 +129,7 @@ beast. | | (fuel-refactor-extract-vocab) | | C-cC-xi | replace word by its definition (fuel-refactor-inline-word) | | C-cC-xw | rename all uses of a word (fuel-refactor-rename-word) | + | C-cC-xa | extract region as a separate ARTICLE: form | |-----------------+------------------------------------------------------------| *** In the listener: diff --git a/misc/fuel/fuel-mode.el b/misc/fuel/fuel-mode.el index 88ad73864a..504308fccd 100644 --- a/misc/fuel/fuel-mode.el +++ b/misc/fuel/fuel-mode.el @@ -198,6 +198,7 @@ interacting with a factor listener is at your disposal. (fuel-mode--key ?e ?w 'fuel-edit-word) (fuel-mode--key ?e ?x 'fuel-eval-definition) +(fuel-mode--key ?x ?a 'fuel-refactor-extract-article) (fuel-mode--key ?x ?i 'fuel-refactor-inline-word) (fuel-mode--key ?x ?r 'fuel-refactor-extract-region) (fuel-mode--key ?x ?s 'fuel-refactor-extract-sexp) diff --git a/misc/fuel/fuel-refactor.el b/misc/fuel/fuel-refactor.el index 061adbb82c..bd62227755 100644 --- a/misc/fuel/fuel-refactor.el +++ b/misc/fuel/fuel-refactor.el @@ -78,17 +78,19 @@ (when found (setq result (fuel-refactor--reuse-p (car found))))) (and result found)))) +(defsubst fuel-refactor--insertion-point () + (max (save-excursion (fuel-syntax--beginning-of-defun) (point)) + (save-excursion + (re-search-backward fuel-syntax--end-of-def-regex nil t) + (forward-line 1) + (skip-syntax-forward "-")))) + (defun fuel-refactor--insert-word (word stack-effect code) - (let ((beg (save-excursion (fuel-syntax--beginning-of-defun) (point))) - (end (save-excursion - (re-search-backward fuel-syntax--end-of-def-regex nil t) - (forward-line 1) - (skip-syntax-forward "-")))) - (let ((start (goto-char (max beg end)))) - (open-line 1) - (insert ": " word " " stack-effect "\n" code " ;\n") - (indent-region start (point)) - (move-overlay fuel-stack--overlay start (point))))) + (let ((start (goto-char (fuel-refactor--insertion-point)))) + (open-line 1) + (insert ": " word " " stack-effect "\n" code " ;\n") + (indent-region start (point)) + (move-overlay fuel-stack--overlay start (point)))) (defun fuel-refactor--extract-other (start end code) (unwind-protect @@ -233,5 +235,30 @@ The region is extended to the closest definition boundaries." (mark-defun) (mark)))) +;;; Extract article: + +(defun fuel-refactor-extract-article (begin end) + "Extracts region as a new ARTICLE form." + (interactive "r") + (let ((topic (read-string "Article topic: ")) + (title (read-string "Article title: "))) + (kill-region begin end) + (insert (format "{ $subsection %s }\n" topic)) + (end-of-line 0) + (save-excursion + (goto-char (fuel-refactor--insertion-point)) + (open-line 1) + (let ((start (point))) + (insert (format "ARTICLE: %S %S\n" topic title)) + (yank) + (when (looking-at "^ *$") (end-of-line 0)) + (insert " ;") + (unwind-protect + (progn + (move-overlay fuel-stack--overlay start (point)) + (sit-for fuel-stack-highlight-period)) + (delete-overlay fuel-stack--overlay)))))) + + (provide 'fuel-refactor) ;;; fuel-refactor.el ends here diff --git a/misc/fuel/fuel-syntax.el b/misc/fuel/fuel-syntax.el index ad5a025a88..80bfd0afcb 100644 --- a/misc/fuel/fuel-syntax.el +++ b/misc/fuel/fuel-syntax.el @@ -158,7 +158,9 @@ "PREDICATE" "PRIMITIVE" "UNION")) -(defconst fuel-syntax--no-indent-def-starts '("SINGLETONS" +(defconst fuel-syntax--no-indent-def-starts '("ARTICLE" + "HELP" + "SINGLETONS" "SYMBOLS" "TUPLE" "VARS")) @@ -179,13 +181,12 @@ (defconst fuel-syntax--single-liner-regex (regexp-opt '("ABOUT:" - "ARTICLE:" "ALIAS:" "CONSTANT:" "C:" "DEFER:" "FORGET:" "GENERIC:" "GENERIC#" - "HELP:" "HEX:" "HOOK:" + "HEX:" "HOOK:" "IN:" "INSTANCE:" "LIBRARY:" "MAIN:" "MATH:" "MIXIN:" From 3cd8fbc6835b73d849da5251956c6178d297a371 Mon Sep 17 00:00:00 2001 From: "Jose A. Ortega Ruiz" Date: Wed, 28 Jan 2009 21:32:19 +0100 Subject: [PATCH 05/86] FUEL: Note about .factor-boot-rc added. --- misc/fuel/README | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/misc/fuel/README b/misc/fuel/README index 198c9bb275..d712560b03 100644 --- a/misc/fuel/README +++ b/misc/fuel/README @@ -53,6 +53,14 @@ beast. factor image (overwriting the current one) with all the needed vocabs. + Alternatively, you can add the following line to your + .factor-boot-rc file: + + "fuel" require + + This will ensure that the image generated while bootstrapping + Factor contains fuel and the vocabularies it depends on. + *** Connecting to a running Factor 'run-factor' starts a new factor listener process managed by Emacs. From 2ea9d0bce1f401229f9b58bb1a1fac96f312a3bc Mon Sep 17 00:00:00 2001 From: "Jose A. Ortega Ruiz" Date: Fri, 30 Jan 2009 00:20:58 +0100 Subject: [PATCH 06/86] FUEL: Better handling of $see in help browser. --- extra/fuel/help/help.factor | 12 ++++++------ misc/fuel/fuel-markup.el | 9 +++++---- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/extra/fuel/help/help.factor b/extra/fuel/help/help.factor index e70327bd35..55183734b3 100644 --- a/extra/fuel/help/help.factor +++ b/extra/fuel/help/help.factor @@ -2,15 +2,15 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays assocs combinators help help.crossref -help.markup help.topics io io.streams.string kernel make memoize -namespaces parser prettyprint sequences summary tools.vocabs -tools.vocabs.browser vocabs vocabs.loader words ; +help.markup help.topics io io.streams.string kernel make namespaces +parser prettyprint sequences summary tools.vocabs tools.vocabs.browser +vocabs vocabs.loader words ; IN: fuel.help > ] dip = ] curry all-words swap filter dup empty? not [ first ] [ drop f ] if ; @@ -102,11 +102,11 @@ PRIVATE> : (fuel-vocab-help) ( name -- str ) dup empty? [ fuel-vocab-children-help ] [ (fuel-vocab-element) ] if ; -MEMO: (fuel-get-vocabs/author) ( author -- element ) +: (fuel-get-vocabs/author) ( author -- element ) [ "Vocabularies by " prepend \ $heading swap 2array ] [ authored fuel-vocab-list ] bi 2array ; -MEMO: (fuel-get-vocabs/tag) ( tag -- element ) +: (fuel-get-vocabs/tag) ( tag -- element ) [ "Vocabularies tagged " prepend \ $heading swap 2array ] [ tagged fuel-vocab-list ] bi 2array ; diff --git a/misc/fuel/fuel-markup.el b/misc/fuel/fuel-markup.el index 7a8fa0c234..2784335fbb 100644 --- a/misc/fuel/fuel-markup.el +++ b/misc/fuel/fuel-markup.el @@ -585,12 +585,13 @@ (defun fuel-markup--see (e) (let* ((word (nth 1 e)) - (cmd (and word `(:fuel* (,(format "%s" word) fuel-word-see) "fuel" t))) - (res (and cmd - (fuel-eval--retort-result (fuel-eval--send/wait cmd 100))))) + (cmd (and word `(:fuel* ((:quote ,(format "%S" word)) see) "fuel"))) + (ret (and cmd (fuel-eval--send/wait cmd))) + (res (and (not (fuel-eval--retort-error ret)) + (fuel-eval--retort-output ret)))) (if res (fuel-markup--code (list '$code res)) - (fuel-markup--snippet (list '$snippet word))))) + (fuel-markup--snippet (list '$snippet " " word))))) (defun fuel-markup--null (e)) From a5cc358f196a1674aae07154c9cccbfb8e458d98 Mon Sep 17 00:00:00 2001 From: "Jose A. Ortega Ruiz" Date: Fri, 30 Jan 2009 00:33:13 +0100 Subject: [PATCH 07/86] FUEL: Bug fix: escape ';' in fuel pretty print. --- extra/fuel/pprint/pprint.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/fuel/pprint/pprint.factor b/extra/fuel/pprint/pprint.factor index 25f3aec14d..9dcbd76368 100644 --- a/extra/fuel/pprint/pprint.factor +++ b/extra/fuel/pprint/pprint.factor @@ -12,7 +12,7 @@ GENERIC: fuel-pprint ( obj -- ) Date: Fri, 30 Jan 2009 00:40:17 +0100 Subject: [PATCH 08/86] FUEL: Even better $see handling in help browser. --- misc/fuel/fuel-markup.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/fuel/fuel-markup.el b/misc/fuel/fuel-markup.el index 2784335fbb..9e508b802d 100644 --- a/misc/fuel/fuel-markup.el +++ b/misc/fuel/fuel-markup.el @@ -585,7 +585,7 @@ (defun fuel-markup--see (e) (let* ((word (nth 1 e)) - (cmd (and word `(:fuel* ((:quote ,(format "%S" word)) see) "fuel"))) + (cmd (and word `(:fuel* ((:quote ,(format "%s" word)) see) "fuel"))) (ret (and cmd (fuel-eval--send/wait cmd))) (res (and (not (fuel-eval--retort-error ret)) (fuel-eval--retort-output ret)))) From 8d522caa82967e2d97bd50cf2a03cb7828528eea Mon Sep 17 00:00:00 2001 From: "Jose A. Ortega Ruiz" Date: Fri, 30 Jan 2009 00:44:15 +0100 Subject: [PATCH 09/86] FUEL: $synopsis markup implemented. --- misc/fuel/fuel-markup.el | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/misc/fuel/fuel-markup.el b/misc/fuel/fuel-markup.el index 9e508b802d..4a5df8e7ea 100644 --- a/misc/fuel/fuel-markup.el +++ b/misc/fuel/fuel-markup.el @@ -593,10 +593,17 @@ (fuel-markup--code (list '$code res)) (fuel-markup--snippet (list '$snippet " " word))))) -(defun fuel-markup--null (e)) - (defun fuel-markup--synopsis (e) - (insert (format " %S " e))) + (let* ((word (nth 1 e)) + (cmd (and word `(:fuel* ((:quote ,(format "%s" word)) synopsis) "fuel"))) + (ret (and cmd (fuel-eval--send/wait cmd))) + (res (and (not (fuel-eval--retort-error ret)) + (fuel-eval--retort-output ret)))) + (if res + (fuel-markup--code (list '$code res)) + (fuel-markup--snippet (list '$snippet " " word))))) + +(defun fuel-markup--null (e)) (provide 'fuel-markup) From ba3c188b3cc1615dc5c95579ff3dab7de052b371 Mon Sep 17 00:00:00 2001 From: "Jose A. Ortega Ruiz" Date: Fri, 30 Jan 2009 00:48:24 +0100 Subject: [PATCH 10/86] FUEL: Small refactoring. --- misc/fuel/fuel-markup.el | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/misc/fuel/fuel-markup.el b/misc/fuel/fuel-markup.el index 4a5df8e7ea..0c2fe91551 100644 --- a/misc/fuel/fuel-markup.el +++ b/misc/fuel/fuel-markup.el @@ -583,9 +583,9 @@ (defun fuel-markup--notes (e) (fuel-markup--elem-with-heading e "Notes")) -(defun fuel-markup--see (e) +(defun fuel-markup--word-info (e s) (let* ((word (nth 1 e)) - (cmd (and word `(:fuel* ((:quote ,(format "%s" word)) see) "fuel"))) + (cmd (and word `(:fuel* ((:quote ,(format "%s" word)) ,s) "fuel"))) (ret (and cmd (fuel-eval--send/wait cmd))) (res (and (not (fuel-eval--retort-error ret)) (fuel-eval--retort-output ret)))) @@ -593,15 +593,11 @@ (fuel-markup--code (list '$code res)) (fuel-markup--snippet (list '$snippet " " word))))) +(defun fuel-markup--see (e) + (fuel-markup--word-info e 'see)) + (defun fuel-markup--synopsis (e) - (let* ((word (nth 1 e)) - (cmd (and word `(:fuel* ((:quote ,(format "%s" word)) synopsis) "fuel"))) - (ret (and cmd (fuel-eval--send/wait cmd))) - (res (and (not (fuel-eval--retort-error ret)) - (fuel-eval--retort-output ret)))) - (if res - (fuel-markup--code (list '$code res)) - (fuel-markup--snippet (list '$snippet " " word))))) + (fuel-markup--word-info e 'synopsis)) (defun fuel-markup--null (e)) From eccabfea120debfadad1550390eaae8176b271a5 Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Thu, 29 Jan 2009 21:41:08 -0600 Subject: [PATCH 11/86] Making XML 30% faster --- basis/xml/char-classes/char-classes.factor | 7 +- basis/xml/errors/errors-tests.factor | 14 +-- basis/xml/state/state.factor | 6 +- basis/xml/tests/state-parser-tests.factor | 2 +- basis/xml/tokenize/tokenize.factor | 114 ++++++++++++--------- 5 files changed, 84 insertions(+), 59 deletions(-) diff --git a/basis/xml/char-classes/char-classes.factor b/basis/xml/char-classes/char-classes.factor index b47d4c66df..d510c8a881 100644 --- a/basis/xml/char-classes/char-classes.factor +++ b/basis/xml/char-classes/char-classes.factor @@ -1,6 +1,7 @@ -! Copyright (C) 2005, 2007 Daniel Ehrenberg +! Copyright (C) 2005, 2009 Daniel Ehrenberg ! See http://factorcode.org/license.txt for BSD license. -USING: kernel sequences unicode.syntax math math.order combinators ; +USING: kernel sequences unicode.syntax math math.order combinators +hints ; IN: xml.char-classes CATEGORY: 1.0name-start* Ll Lu Lo Lt Nl \u000559\u0006E5\u0006E6_: ; @@ -31,3 +32,5 @@ CATEGORY: 1.1name-char Ll Lu Lo Lm Ln Nl Mc Mn Nd Pc Cf _-.\u0000b7: ; { [ dup HEX: E000 < ] [ drop f ] } [ { HEX: FFFE HEX: FFFF } member? not ] } cond ; + +HINTS: text? { object fixnum } ; diff --git a/basis/xml/errors/errors-tests.factor b/basis/xml/errors/errors-tests.factor index 4204979941..8a469bc08f 100644 --- a/basis/xml/errors/errors-tests.factor +++ b/basis/xml/errors/errors-tests.factor @@ -6,11 +6,11 @@ IN: xml.errors.tests '[ _ string>xml ] swap '[ _ = ] must-fail-with ; T{ no-entity f 1 10 "nbsp" } " " xml-error-test -T{ mismatched f 1 8 T{ name f "" "x" "" } T{ name f "" "y" "" } } +T{ mismatched f 1 7 T{ name f "" "x" "" } T{ name f "" "y" "" } } "" xml-error-test -T{ unclosed f 1 4 V{ T{ name f "" "x" "" } } } "" xml-error-test +T{ unclosed f 1 3 V{ T{ name f "" "x" "" } } } "" xml-error-test T{ nonexist-ns f 1 5 "x" } "" xml-error-test -T{ unopened f 1 5 } "" xml-error-test +T{ unopened f 1 4 } "" xml-error-test T{ not-yes/no f 1 41 "maybe" } "" xml-error-test T{ extra-attrs f 1 32 V{ T{ name f "" "foo" f } } @@ -19,13 +19,13 @@ T{ bad-version f 1 28 "5 million" } "" xml-error-test T{ notags f } "" xml-error-test T{ multitags } "" xml-error-test -T{ bad-prolog f 1 26 T{ prolog f "1.0" "UTF-8" f } } +T{ bad-prolog f 1 25 T{ prolog f "1.0" "UTF-8" f } } "" xml-error-test T{ capitalized-prolog f 1 6 "XmL" } "" xml-error-test T{ pre/post-content f "x" t } "x" xml-error-test T{ versionless-prolog f 1 8 } "" xml-error-test -T{ unclosed-quote f 1 13 } "" xml-error-test T{ bad-name f 1 3 "-" } "<-/>" xml-error-test T{ quoteless-attr f 1 12 } "/>" xml-error-test T{ quoteless-attr f 1 10 } "" xml-error-test @@ -37,6 +37,6 @@ T{ bad-cdata f 1 7 } "" xml-error-test T{ pre/post-content f "&" t } " " xml-error-test T{ bad-doctype f 1 17 "a" } "" xml-error-test T{ bad-doctype f 1 22 T{ opener { name T{ name f "" "foo" "" } } { attrs T{ attrs } } } } " ]>" xml-error-test -T{ disallowed-char f 1 3 1 } "\u000001" xml-error-test -T{ missing-close f 1 9 } "