From 037ba93c1ce06c4fc4f5f21488d11426c34c6dc3 Mon Sep 17 00:00:00 2001 From: "Jose A. Ortega Ruiz" Date: Fri, 16 Jan 2009 22:07:14 +0100 Subject: [PATCH 1/9] FUEL: Correctly detect vocabs when M-. in a USING:/USE: form. --- misc/fuel/fuel-edit.el | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/misc/fuel/fuel-edit.el b/misc/fuel/fuel-edit.el index 20e1f1eb01..b0756826f1 100644 --- a/misc/fuel/fuel-edit.el +++ b/misc/fuel/fuel-edit.el @@ -33,6 +33,11 @@ ;;; Auxiliar functions: +(defun fuel-edit--looking-at-vocab () + (save-excursion + (fuel-syntax--beginning-of-defun) + (looking-at "USING:\\|USE:"))) + (defun fuel-edit--try-edit (ret) (let* ((err (fuel-eval--retort-error ret)) (loc (fuel-eval--retort-result ret))) @@ -92,9 +97,9 @@ With prefix, asks for the word to edit." (fuel-completion--read-word "Edit word: "))) (cmd `(:fuel* ((:quote ,word) fuel-get-edit-location))) (marker (and (not arg) (point-marker)))) - (condition-case nil - (fuel-edit--try-edit (fuel-eval--send/wait cmd)) - (error (fuel-edit-vocabulary nil word))) + (if (and (not arg) (fuel-edit--looking-at-vocab)) + (fuel-edit-vocabulary nil word) + (fuel-edit--try-edit (fuel-eval--send/wait cmd))) (when marker (ring-insert find-tag-marker-ring marker)))) (defun fuel-edit-word-doc-at-point (&optional arg word) From 8d18fc10aa98fe8553d29f8b9276c98218ba56ef Mon Sep 17 00:00:00 2001 From: "Jose A. Ortega Ruiz" Date: Fri, 16 Jan 2009 22:20:40 +0100 Subject: [PATCH 2/9] FUEL: C: font lock fix. --- misc/fuel/fuel-font-lock.el | 3 +++ misc/fuel/fuel-syntax.el | 3 +++ 2 files changed, 6 insertions(+) diff --git a/misc/fuel/fuel-font-lock.el b/misc/fuel/fuel-font-lock.el index 10561ded68..1dee0326ae 100644 --- a/misc/fuel/fuel-font-lock.el +++ b/misc/fuel/fuel-font-lock.el @@ -88,6 +88,9 @@ `((,fuel-syntax--stack-effect-regex . 'factor-font-lock-stack-effect) (,fuel-syntax--brace-words-regex 1 'factor-font-lock-parsing-word) (,fuel-syntax--vocab-ref-regexp 2 'factor-font-lock-vocabulary-name) + (,fuel-syntax--constructor-regex (1 'factor-font-lock-word) + (2 'factor-font-lock-type-name) + (3 'factor-font-lock-invalid-syntax nil t)) (,fuel-syntax--declaration-words-regex . 'factor-font-lock-declaration) (,fuel-syntax--word-definition-regex 2 'factor-font-lock-word) (,fuel-syntax--alias-definition-regex (1 'factor-font-lock-word) diff --git a/misc/fuel/fuel-syntax.el b/misc/fuel/fuel-syntax.el index 4112e3507d..c2b7391383 100644 --- a/misc/fuel/fuel-syntax.el +++ b/misc/fuel/fuel-syntax.el @@ -208,6 +208,9 @@ (format ":[^ ]* [^ ]+\\(%s\\)*" fuel-syntax--stack-effect-regex) "M[^:]*: [^ ]+ [^ ]+")) +(defconst fuel-syntax--constructor-regex + "\\_ Date: Fri, 16 Jan 2009 17:02:54 -0600 Subject: [PATCH 3/9] Updating non-core libraries for monotonic? change --- basis/compiler/cfg/linear-scan/linear-scan-tests.factor | 2 +- basis/grouping/grouping-tests.factor | 3 ++- basis/io/files/unix/unix-tests.factor | 3 ++- basis/roman/roman.factor | 3 ++- core/generic/standard/standard-tests.factor | 3 ++- core/kernel/kernel-tests.factor | 2 +- core/math/floats/floats-tests.factor | 3 ++- core/sorting/sorting-tests.factor | 2 +- core/vocabs/loader/loader-tests.factor | 2 +- extra/project-euler/052/052.factor | 3 ++- 10 files changed, 16 insertions(+), 10 deletions(-) diff --git a/basis/compiler/cfg/linear-scan/linear-scan-tests.factor b/basis/compiler/cfg/linear-scan/linear-scan-tests.factor index 7420b4fd17..4ddd1fdc0b 100644 --- a/basis/compiler/cfg/linear-scan/linear-scan-tests.factor +++ b/basis/compiler/cfg/linear-scan/linear-scan-tests.factor @@ -1,7 +1,7 @@ IN: compiler.cfg.linear-scan.tests USING: tools.test random sorting sequences sets hashtables assocs kernel fry arrays splitting namespaces math accessors vectors -math.order +math.order grouping cpu.architecture compiler.cfg.instructions compiler.cfg.registers diff --git a/basis/grouping/grouping-tests.factor b/basis/grouping/grouping-tests.factor index 647f95f2cb..c91e5a56d6 100644 --- a/basis/grouping/grouping-tests.factor +++ b/basis/grouping/grouping-tests.factor @@ -1,4 +1,5 @@ -USING: grouping tools.test kernel sequences arrays ; +USING: grouping tools.test kernel sequences arrays +math ; IN: grouping.tests [ { 1 2 3 } 0 group ] must-fail diff --git a/basis/io/files/unix/unix-tests.factor b/basis/io/files/unix/unix-tests.factor index 003cb40621..d2f4494b0c 100644 --- a/basis/io/files/unix/unix-tests.factor +++ b/basis/io/files/unix/unix-tests.factor @@ -1,7 +1,8 @@ USING: tools.test io.files io.files.temp io.pathnames io.directories io.files.info io.files.info.unix continuations kernel io.files.unix math.bitwise calendar accessors -math.functions math unix.users unix.groups arrays sequences ; +math.functions math unix.users unix.groups arrays sequences +grouping ; IN: io.files.unix.tests [ "/usr/libexec/" ] [ "/usr/libexec/awk/" parent-directory ] unit-test diff --git a/basis/roman/roman.factor b/basis/roman/roman.factor index c9394b07ed..81a6d69a09 100644 --- a/basis/roman/roman.factor +++ b/basis/roman/roman.factor @@ -2,7 +2,8 @@ ! See http://factorcode.org/license.txt for BSD license. USING: arrays assocs kernel math math.order math.vectors namespaces make quotations sequences splitting.monotonic -sequences.private strings unicode.case lexer parser ; +sequences.private strings unicode.case lexer parser +grouping ; IN: roman Date: Sat, 17 Jan 2009 00:17:02 +0100 Subject: [PATCH 4/9] FUEL: TYPEDEF: font lock. --- misc/fuel/fuel-font-lock.el | 3 +++ misc/fuel/fuel-syntax.el | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/misc/fuel/fuel-font-lock.el b/misc/fuel/fuel-font-lock.el index 1dee0326ae..2d1b5b2de4 100644 --- a/misc/fuel/fuel-font-lock.el +++ b/misc/fuel/fuel-font-lock.el @@ -91,6 +91,9 @@ (,fuel-syntax--constructor-regex (1 'factor-font-lock-word) (2 'factor-font-lock-type-name) (3 'factor-font-lock-invalid-syntax nil t)) + (,fuel-syntax--typedef-regex (1 'factor-font-lock-type-name) + (2 'factor-font-lock-type-name) + (3 'factor-font-lock-invalid-syntax nil t)) (,fuel-syntax--declaration-words-regex . 'factor-font-lock-declaration) (,fuel-syntax--word-definition-regex 2 'factor-font-lock-word) (,fuel-syntax--alias-definition-regex (1 'factor-font-lock-word) diff --git a/misc/fuel/fuel-syntax.el b/misc/fuel/fuel-syntax.el index c2b7391383..2e7ca493ec 100644 --- a/misc/fuel/fuel-syntax.el +++ b/misc/fuel/fuel-syntax.el @@ -187,6 +187,7 @@ "QUALIFIED-WITH:" "QUALIFIED:" "RENAME:" "SINGLETON:" "SLOT:" "SYMBOL:" + "TYPEDEF:" "USE:" "VAR:"))) @@ -211,6 +212,9 @@ (defconst fuel-syntax--constructor-regex "\\_ Date: Sat, 17 Jan 2009 00:33:14 +0100 Subject: [PATCH 5/9] FUEL: RENAME: font lock. --- misc/fuel/fuel-font-lock.el | 4 ++++ misc/fuel/fuel-syntax.el | 3 +++ 2 files changed, 7 insertions(+) diff --git a/misc/fuel/fuel-font-lock.el b/misc/fuel/fuel-font-lock.el index 2d1b5b2de4..4b5520b8f9 100644 --- a/misc/fuel/fuel-font-lock.el +++ b/misc/fuel/fuel-font-lock.el @@ -94,6 +94,10 @@ (,fuel-syntax--typedef-regex (1 'factor-font-lock-type-name) (2 'factor-font-lock-type-name) (3 'factor-font-lock-invalid-syntax nil t)) + (,fuel-syntax--rename-regex (1 'factor-font-lock-word) + (2 'factor-font-lock-vocabulary-name) + (3 'factor-font-lock-word) + (4 'factor-font-lock-invalid-syntax nil t)) (,fuel-syntax--declaration-words-regex . 'factor-font-lock-declaration) (,fuel-syntax--word-definition-regex 2 'factor-font-lock-word) (,fuel-syntax--alias-definition-regex (1 'factor-font-lock-word) diff --git a/misc/fuel/fuel-syntax.el b/misc/fuel/fuel-syntax.el index 2e7ca493ec..ca247cf8f0 100644 --- a/misc/fuel/fuel-syntax.el +++ b/misc/fuel/fuel-syntax.el @@ -215,6 +215,9 @@ (defconst fuel-syntax--typedef-regex "\\_ +\\(\\w+\\)\\( .*\\)?$") + ;;; Factor syntax table From 923bd07ad45c3958c7eac35d252e752c65d2901a Mon Sep 17 00:00:00 2001 From: "Jose A. Ortega Ruiz" Date: Sat, 17 Jan 2009 05:35:16 +0100 Subject: [PATCH 6/9] FUEL: Kind of subtle bug in C-cC-eu caused by syntax table tweakings. --- misc/fuel/fuel-debug-uses.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/misc/fuel/fuel-debug-uses.el b/misc/fuel/fuel-debug-uses.el index af4f2ae60b..4842f960d1 100644 --- a/misc/fuel/fuel-debug-uses.el +++ b/misc/fuel/fuel-debug-uses.el @@ -47,7 +47,8 @@ (substring-no-properties (thing-at-point 'line))))) (when in-usings (setq line (concat "! " line))) (push line lines)) - (when (and in-usings (looking-at ".*\\_<;\\_>")) (setq in-usings nil)) + (when (and in-usings (looking-at "\\(^\\|.* \\);\\( \\|\n\\)")) + (setq in-usings nil)) (forward-line)) (reverse lines)))))) From c9829a1c089bf218764158ae9b7de36a5b593f1f Mon Sep 17 00:00:00 2001 From: "Jose A. Ortega Ruiz" Date: Sat, 17 Jan 2009 23:11:00 +0100 Subject: [PATCH 7/9] FUEL: Better font lock for empty USING: ; form (semicolon as parsing word). --- misc/fuel/fuel-font-lock.el | 2 ++ misc/fuel/fuel-syntax.el | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/misc/fuel/fuel-font-lock.el b/misc/fuel/fuel-font-lock.el index 4b5520b8f9..fe20024fcd 100644 --- a/misc/fuel/fuel-font-lock.el +++ b/misc/fuel/fuel-font-lock.el @@ -82,6 +82,8 @@ ((looking-at "\\(TUPLE\\|SYMBOLS\\|VARS\\): ") 'factor-font-lock-symbol) (t 'default)))) + ((char-equal (char-after (nth 8 state)) ?U) + 'factor-font-lock-parsing-word) (t 'factor-font-lock-comment))) (defconst fuel-font-lock--font-lock-keywords diff --git a/misc/fuel/fuel-syntax.el b/misc/fuel/fuel-syntax.el index ca247cf8f0..8d2948af58 100644 --- a/misc/fuel/fuel-syntax.el +++ b/misc/fuel/fuel-syntax.el @@ -249,10 +249,10 @@ ("\\_<<\\(\"\\)\\_>" (1 "\"")) ("\\_<\\(\"\\)>\\_>" (1 "\"")) ;; Multiline constructs - ("\\_b")) + ("\\_<\\(U\\)SING: \\(;\\)" (1 "b")) ("\\_\\)" (2 "\\)" (2 "" (1 ">b")) ;; Let and lambda: ("\\_<\\(!(\\) .* \\()\\)" (1 "<") (2 ">")) From 66f5694462f15a4a2d5641fa04b6768cb4888a43 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sat, 17 Jan 2009 22:15:57 -0600 Subject: [PATCH 8/9] document more core/ words --- core/assocs/assocs-docs.factor | 7 ++++ core/byte-arrays/byte-arrays-docs.factor | 4 +++ core/math/math-docs.factor | 6 +++- core/sequences/sequences-docs.factor | 46 ++++++++++++++++++++++-- 4 files changed, 60 insertions(+), 3 deletions(-) diff --git a/core/assocs/assocs-docs.factor b/core/assocs/assocs-docs.factor index 2f486cd948..627d4aeb80 100644 --- a/core/assocs/assocs-docs.factor +++ b/core/assocs/assocs-docs.factor @@ -115,6 +115,7 @@ $nl { $subsection assoc-map } { $subsection assoc-push-if } { $subsection assoc-filter } +{ $subsection assoc-filter-as } { $subsection assoc-contains? } { $subsection assoc-all? } "Additional combinators:" @@ -232,6 +233,12 @@ HELP: assoc-filter { $values { "assoc" assoc } { "quot" { $quotation "( key value -- ? )" } } { "subassoc" "a new assoc" } } { $description "Outputs an assoc of the same type as " { $snippet "assoc" } " consisting of all entries for which the predicate quotation yields true." } ; +HELP: assoc-filter-as +{ $values { "assoc" assoc } { "quot" { $quotation "( key value -- ? )" } } { "exemplar" assoc } { "subassoc" "a new assoc" } } +{ $description "Outputs an assoc of the same type as " { $snippet "exemplar" } " consisting of all entries for which the predicate quotation yields true." } ; + +{ assoc-filter assoc-filter-as } related-words + HELP: assoc-contains? { $values { "assoc" assoc } { "quot" { $quotation "( key value -- ? )" } } { "?" "a boolean" } } { $description "Tests if the assoc contains an entry satisfying a predicate by applying the quotation to each entry in turn. Iteration stops if an entry is found for which the quotation outputs a true value." } ; diff --git a/core/byte-arrays/byte-arrays-docs.factor b/core/byte-arrays/byte-arrays-docs.factor index 25bff0fce5..f1d94a46f7 100644 --- a/core/byte-arrays/byte-arrays-docs.factor +++ b/core/byte-arrays/byte-arrays-docs.factor @@ -30,6 +30,10 @@ HELP: ( n -- byte-array ) { $values { "n" "a non-negative integer" } { "byte-array" "a new byte array" } } { $description "Creates a new byte array holding " { $snippet "n" } " bytes." } ; +HELP: (byte-array) +{ $values { "n" "a non-negative integer" } { "byte-array" "a new byte array" } } +{ $description "Creates a new byte array with unspecified contents of length " { $snippet "n" } " bytes." } ; + HELP: >byte-array { $values { "seq" "a sequence" } { "byte-array" byte-array } } { $description diff --git a/core/math/math-docs.factor b/core/math/math-docs.factor index 2f7ab75103..348d27ba0f 100644 --- a/core/math/math-docs.factor +++ b/core/math/math-docs.factor @@ -1,5 +1,5 @@ USING: help.markup help.syntax kernel sequences quotations -math.private ; +math.private byte-arrays io.binary ; IN: math HELP: number= @@ -306,6 +306,10 @@ HELP: find-last-integer { $description "Applies the quotation to each integer from " { $snippet "n" } " down to 0, inclusive. Iteration stops when the quotation outputs a true value or 0 is reached. If the quotation yields a true value for some integer, the word outputs that integer. Otherwise, the word outputs " { $link f } "." } { $notes "This word is used to implement " { $link find-last } "." } ; +HELP: byte-array>bignum +{ $values { "byte-array" byte-array } { "n" integer } } +{ $description "Converts a byte-array, interpreted as little-endian, into a bignum integer. User code should call " { $link >le } " or " { $link >be } " instead." } ; + ARTICLE: "division-by-zero" "Division by zero" "Floating point division never raises an error if the denominator is zero. This means that if at least one of the two inputs to " { $link / } ", " { $link /f } " or " { $link mod } " is a float, the result will be a floating point infinity or not a number value." $nl diff --git a/core/sequences/sequences-docs.factor b/core/sequences/sequences-docs.factor index 0b9dbcdfa7..1aeed75470 100644 --- a/core/sequences/sequences-docs.factor +++ b/core/sequences/sequences-docs.factor @@ -679,12 +679,28 @@ HELP: append } } ; +HELP: append-as +{ $values { "seq1" sequence } { "seq2" sequence } { "exemplar" sequence } { "newseq" sequence } } +{ $description "Outputs a new sequence of the same type as " { $snippet "exemplar" } " consisting of the elements of " { $snippet "seq1" } " followed by " { $snippet "seq2" } "." } +{ $errors "Throws an error if " { $snippet "seq1" } " or " { $snippet "seq2" } " contain elements not permitted in sequences of the same class as " { $snippet "exemplar" } "." } +{ $examples + { $example "USING: prettyprint sequences ;" + "{ 1 2 } B{ 3 4 } B{ } append-as ." + "B{ 1 2 3 4 }" + } + { $example "USING: prettyprint sequences strings ;" + "\"go\" \"ing\" SBUF\" \" append-as ." + "SBUF\" going\"" + } +} ; + +{ append append-as } related-words + HELP: prepend { $values { "seq1" sequence } { "seq2" sequence } { "newseq" sequence } } { $description "Outputs a new sequence of the same type as " { $snippet "seq2" } " consisting of the elements of " { $snippet "seq2" } " followed by " { $snippet "seq1" } "." } { $errors "Throws an error if " { $snippet "seq1" } " contains elements not permitted in sequences of the same class as " { $snippet "seq2" } "." } -{ $examples - { $example "USING: prettyprint sequences ;" +{ $examples { $example "USING: prettyprint sequences ;" "{ 1 2 } B{ 3 4 } prepend ." "B{ 3 4 1 2 }" } @@ -705,6 +721,19 @@ HELP: 3append } } ; +HELP: 3append-as +{ $values { "seq1" sequence } { "seq2" sequence } { "seq3" sequence } { "exemplar" sequence } { "newseq" sequence } } +{ $description "Outputs a new sequence consisting of the elements of " { $snippet "seq1" } ", " { $snippet "seq2" } " and " { $snippet "seq3" } " in turn of the same type as " { $snippet "exemplar" } "." } +{ $errors "Throws an error if " { $snippet "seq1" } ", " { $snippet "seq2" } ", or " { $snippet "seq3" } " contain elements not permitted in sequences of the same class as " { $snippet "exemplar" } "." } +{ $examples + { $example "USING: prettyprint sequences ;" + "\"a\" \"b\" \"c\" SBUF\" \" 3append-as ." + "SBUF\" abc\"" + } +} ; + +{ 3append 3append-as } related-words + HELP: surround { $values { "seq1" sequence } { "seq2" sequence } { "seq3" sequence } { "newseq" sequence } } { $description "Outputs a new sequence with " { $snippet "seq1" } " inserted between " { $snippet "seq2" } " and " { $snippet "seq3" } "." } @@ -891,6 +920,16 @@ HELP: produce { $unchecked-example "USING: kernel prettyprint random sequences ;" "[ 10 random dup 1 > ] [ ] [ drop ] produce ." "{ 8 2 2 9 }" } } ; +HELP: produce-as +{ $values { "pred" { $quotation "( -- ? )" } } { "quot" { $quotation "( -- obj )" } } { "tail" "a quotation" } { "exemplar" sequence } { "seq" "a sequence" } } +{ $description "Calls " { $snippet "pred" } " repeatedly. If the predicate yields " { $link f } ", stops, otherwise, calls " { $snippet "quot" } " to yield a value. Values are accumulated and returned in a sequence of type " { $snippet "exemplar" } " at the end." } +{ $examples + "The following example divides a number by two until we reach zero, and accumulates intermediate results:" + { $example "USING: kernel math prettyprint sequences ;" "1337 [ dup 0 > ] [ 2/ dup ] [ ] V{ } produce-as nip ." "V{ 668 334 167 83 41 20 10 5 2 1 0 }" } + "The " { $snippet "tail" } " quotation is used when the predicate produces more than one output value. In this case, we have to drop this value even if the predicate fails in order for stack inference to calculate a stack effect for the " { $link produce } " call:" + { $unchecked-example "USING: kernel prettyprint random sequences ;" "[ 10 random dup 1 > ] [ ] [ drop ] B{ } produce-as ." "B{ 8 2 2 9 }" } +} ; + HELP: sigma { $values { "seq" sequence } { "quot" quotation } { "n" number } } { $description "Like map sum, but without creating an intermediate sequence." } @@ -1359,8 +1398,10 @@ ARTICLE: "sequences-reshape" "Reshaping sequences" ARTICLE: "sequences-appending" "Appending sequences" { $subsection append } +{ $subsection append-as } { $subsection prepend } { $subsection 3append } +{ $subsection 3append-as } { $subsection surround } { $subsection glue } { $subsection concat } @@ -1417,6 +1458,7 @@ ARTICLE: "sequences-combinators" "Sequence combinators" { $subsection map-index } { $subsection accumulate } { $subsection produce } +{ $subsection produce-as } "Filtering:" { $subsection push-if } { $subsection filter } From df7ad34db205028bf3b29b943f4cce02ea849ca6 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 18 Jan 2009 17:28:36 -0600 Subject: [PATCH 9/9] Credit where credit is due --- basis/unix/authors.txt | 1 + basis/unix/unix.factor | 1 + 2 files changed, 2 insertions(+) diff --git a/basis/unix/authors.txt b/basis/unix/authors.txt index 1901f27a24..e1907c6d91 100644 --- a/basis/unix/authors.txt +++ b/basis/unix/authors.txt @@ -1 +1,2 @@ Slava Pestov +Eduardo Cavazos diff --git a/basis/unix/unix.factor b/basis/unix/unix.factor index 52e7473800..c2b5ad4ea4 100644 --- a/basis/unix/unix.factor +++ b/basis/unix/unix.factor @@ -1,4 +1,5 @@ ! Copyright (C) 2005, 2008 Slava Pestov. +! Copyright (C) 2008 Eduardo Cavazos. ! See http://factorcode.org/license.txt for BSD license. USING: alien alien.c-types alien.syntax kernel libc sequences continuations byte-arrays strings math namespaces