From aba1dbabcf35be21a60191f0088912f82530c523 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Br=C3=BCschweiler?= Date: Wed, 11 Feb 2009 20:56:09 +0100 Subject: [PATCH 01/13] infix: added meta information and fixed up docs somewhat --- extra/infix/ast/ast.factor | 2 + extra/infix/authors.txt | 1 + extra/infix/infix-docs.factor | 55 +++++++++++++++++++- extra/infix/infix-tests.factor | 2 + extra/infix/infix.factor | 2 + extra/infix/parser/parser-tests.factor | 2 + extra/infix/parser/parser.factor | 2 + extra/infix/summary.txt | 1 + extra/infix/tags.txt | 1 + extra/infix/tokenizer/tokenizer-tests.factor | 2 + extra/infix/tokenizer/tokenizer.factor | 2 + 11 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 extra/infix/authors.txt create mode 100644 extra/infix/summary.txt create mode 100644 extra/infix/tags.txt diff --git a/extra/infix/ast/ast.factor b/extra/infix/ast/ast.factor index 0bc22feeb7..1908b3d39b 100644 --- a/extra/infix/ast/ast.factor +++ b/extra/infix/ast/ast.factor @@ -1,3 +1,5 @@ +! Copyright (C) 2009 Philipp Brüschweiler +! See http://factorcode.org/license.txt for BSD license. IN: infix.ast TUPLE: ast-number value ; diff --git a/extra/infix/authors.txt b/extra/infix/authors.txt new file mode 100644 index 0000000000..156a81af57 --- /dev/null +++ b/extra/infix/authors.txt @@ -0,0 +1 @@ +Philipp Brüschweiler diff --git a/extra/infix/infix-docs.factor b/extra/infix/infix-docs.factor index 7a4febb514..4a2ec963ee 100644 --- a/extra/infix/infix-docs.factor +++ b/extra/infix/infix-docs.factor @@ -1,4 +1,6 @@ -USING: help.syntax help.markup prettyprint locals ; +! Copyright (C) 2009 Philipp Brüschweiler +! See http://factorcode.org/license.txt for BSD license. +USING: help.syntax help.markup math prettyprint locals sequences ; IN: infix HELP: [infix @@ -36,3 +38,54 @@ HELP: [infix| } ; { POSTPONE: [infix POSTPONE: [infix| } related-words + +ARTICLE: "infix" "Infix notation" +"The " { $vocab-link "infix" } " vocabulary implements support for infix notation in Factor source code." +{ $subsection POSTPONE: [infix } +{ $subsection POSTPONE: [infix| } +$nl +"The usual infix math operators are supported:" +{ $list + { $link + } + { $link - } + { $link * } + { $link / } + { { $snippet "%" } ", which is the infix operator for " { $link mod } "." } +} +"The standard precedence rules apply: Grouping with parentheses before " { $snippet "*" } ", " { $snippet "/" } "and " { $snippet "%" } " before " { $snippet "+" } " and " { $snippet "-" } "." +{ $example + "USING: infix prettyprint ;" + "[infix 5-40/10*2 infix] ." + "-3" +} +$nl +"You can call Factor words in infix expressions just as you would in C. There are some restrictions on which words are legal to use though:" +{ $list + "The word must return exactly one value." + "The word name must consist of the letters a-z, A-Z, _ or 0-9, and the first character can't be a number." +} +{ $example + "USING: infix locals math math.functions prettyprint ;" + ":: binary_entropy ( p -- h )" + " [infix -(p*log(p) + (1-p)*log(1-p)) / log(2) infix] ;" + "[infix binary_entropy( sqrt(0.25) ) infix] ." + "1.0" +} +$nl +"You can access " { $vocab-link "sequences" } " inside infix expressions with the familiar " { $snippet "arr[index]" } " notation." +{ $example + "USING: arrays infix prettyprint ;" + "[infix| myarr [ { 1 2 3 4 } ] | myarr[4/2]*3 infix] ." + "9" +} +"Please note: in Factor " { $emphasis "fixnums are sequences too." } " If you are not careful with sequence accesses you may introduce subtle bugs:" +{ $example + "USING: arrays infix locals prettyprint ;" + ":: add-2nd-element ( x y -- res )" + " [infix x[1] + y[1] infix] ;" + "{ 1 2 3 } 5 add-2nd-element ." + "3" +} +; + +ABOUT: "infix" diff --git a/extra/infix/infix-tests.factor b/extra/infix/infix-tests.factor index 5ee6468131..7e8e2dfcc9 100644 --- a/extra/infix/infix-tests.factor +++ b/extra/infix/infix-tests.factor @@ -1,3 +1,5 @@ +! Copyright (C) 2009 Philipp Brüschweiler +! See http://factorcode.org/license.txt for BSD license. USING: infix infix.private kernel locals math math.functions tools.test ; IN: infix.tests diff --git a/extra/infix/infix.factor b/extra/infix/infix.factor index 31cd1cbe1f..3e2ba49e3c 100644 --- a/extra/infix/infix.factor +++ b/extra/infix/infix.factor @@ -1,3 +1,5 @@ +! Copyright (C) 2009 Philipp Brüschweiler +! See http://factorcode.org/license.txt for BSD license. USING: accessors assocs combinators combinators.short-circuit effects fry infix.parser infix.ast kernel locals.parser locals.types math multiline namespaces parser quotations diff --git a/extra/infix/parser/parser-tests.factor b/extra/infix/parser/parser-tests.factor index 0a0288c41b..d6b5d0559c 100644 --- a/extra/infix/parser/parser-tests.factor +++ b/extra/infix/parser/parser-tests.factor @@ -1,3 +1,5 @@ +! Copyright (C) 2009 Philipp Brüschweiler +! See http://factorcode.org/license.txt for BSD license. USING: infix.ast infix.parser infix.tokenizer tools.test ; IN: infix.parser.tests diff --git a/extra/infix/parser/parser.factor b/extra/infix/parser/parser.factor index beaf3c335d..2f9ab03d18 100644 --- a/extra/infix/parser/parser.factor +++ b/extra/infix/parser/parser.factor @@ -1,3 +1,5 @@ +! Copyright (C) 2009 Philipp Brüschweiler +! See http://factorcode.org/license.txt for BSD license. USING: infix.ast infix.tokenizer kernel math peg.ebnf sequences strings vectors ; IN: infix.parser diff --git a/extra/infix/summary.txt b/extra/infix/summary.txt new file mode 100644 index 0000000000..63d366d203 --- /dev/null +++ b/extra/infix/summary.txt @@ -0,0 +1 @@ +Support for infix notation in Factor programs diff --git a/extra/infix/tags.txt b/extra/infix/tags.txt new file mode 100644 index 0000000000..f4274299b1 --- /dev/null +++ b/extra/infix/tags.txt @@ -0,0 +1 @@ +extensions diff --git a/extra/infix/tokenizer/tokenizer-tests.factor b/extra/infix/tokenizer/tokenizer-tests.factor index 7e1fb005ef..f9c908414a 100644 --- a/extra/infix/tokenizer/tokenizer-tests.factor +++ b/extra/infix/tokenizer/tokenizer-tests.factor @@ -1,3 +1,5 @@ +! Copyright (C) 2009 Philipp Brüschweiler +! See http://factorcode.org/license.txt for BSD license. USING: infix.ast infix.tokenizer tools.test ; IN: infix.tokenizer.tests diff --git a/extra/infix/tokenizer/tokenizer.factor b/extra/infix/tokenizer/tokenizer.factor index 8c1a1b4a18..f5bce4b6d7 100644 --- a/extra/infix/tokenizer/tokenizer.factor +++ b/extra/infix/tokenizer/tokenizer.factor @@ -1,3 +1,5 @@ +! Copyright (C) 2009 Philipp Brüschweiler +! See http://factorcode.org/license.txt for BSD license. USING: infix.ast kernel peg peg.ebnf math.parser sequences strings ; IN: infix.tokenizer From 31d86e300cf0ade1ee73657449c95fd349d62414 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 11 Feb 2009 13:56:54 -0600 Subject: [PATCH 02/13] fix html help-lint --- basis/html/html-docs.factor | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/basis/html/html-docs.factor b/basis/html/html-docs.factor index 8c4b2934d0..83fe4d3a63 100644 --- a/basis/html/html-docs.factor +++ b/basis/html/html-docs.factor @@ -1,6 +1,7 @@ +USING: help.markup help.syntax strings xml.data ; IN: html -USING: help.markup help.syntax strings ; HELP: simple-page -{ $values { "title" string } { "head" "XML data" } { "body" "XML data" } } -{ $description "Constructs a simple XHTML page with a " { $snippet "head" } " and " { $snippet "body" } " tag. The given XML data is spliced into the two child tags, and a title is also added to the head tag." } ; \ No newline at end of file +{ $values { "title" string } { "head" "XML data" } { "body" "XML data" } +{ "xml" xml } } +{ $description "Constructs a simple XHTML page with a " { $snippet "head" } " and " { $snippet "body" } " tag. The given XML data is spliced into the two child tags, and a title is also added to the head tag." } ; From ed1ace93e7f595370d71f580f85fac3813a423a5 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 11 Feb 2009 14:01:52 -0600 Subject: [PATCH 03/13] add checksums.txt to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 435595f502..22dda8efb4 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,4 @@ build-support/wordsize *.bak .#* *.swo +checksums.txt From 94a5582edc79d19b18b552e628e4e91304b85c27 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 11 Feb 2009 14:05:57 -0600 Subject: [PATCH 04/13] tweak fortran-invoke so that unit tests can set fortran-abi without being shouted over --- basis/alien/fortran/fortran.factor | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/basis/alien/fortran/fortran.factor b/basis/alien/fortran/fortran.factor index a2ffc55c02..915b7d3d4f 100644 --- a/basis/alien/fortran/fortran.factor +++ b/basis/alien/fortran/fortran.factor @@ -423,7 +423,6 @@ PRIVATE> : (fortran-invoke) ( return library function parameters -- quot ) { - [ 2drop nip set-fortran-abi ] [ 2nip [] ] [ nip nip nip [fortran-args>c-args] ] [ [fortran-invoke] ] @@ -431,7 +430,7 @@ PRIVATE> } 4 ncleave 4 nappend ; MACRO: fortran-invoke ( return library function parameters -- ) - (fortran-invoke) ; + { [ 2drop nip set-fortran-abi ] [ (fortran-invoke) ] } 4 ncleave ; :: define-fortran-function ( return library function parameters -- ) function create-in dup reset-generic From 633ffaa9ddde3c00f3e52044199493903630458c Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 11 Feb 2009 14:06:46 -0600 Subject: [PATCH 05/13] play horseshoes in math.blas.vectors tests to deal with excessively accurate x87 math --- basis/math/blas/vectors/vectors-tests.factor | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/basis/math/blas/vectors/vectors-tests.factor b/basis/math/blas/vectors/vectors-tests.factor index da271a4fc7..ef2f7ad6f9 100644 --- a/basis/math/blas/vectors/vectors-tests.factor +++ b/basis/math/blas/vectors/vectors-tests.factor @@ -1,4 +1,4 @@ -USING: kernel math.blas.vectors sequences tools.test ; +USING: kernel math.blas.vectors math.functions sequences tools.test ; IN: math.blas.vectors.tests ! clone @@ -126,11 +126,11 @@ unit-test ! Vnorm -[ 5.0 ] [ svector{ 3.0 4.0 } Vnorm ] unit-test -[ 5.0 ] [ dvector{ 3.0 4.0 } Vnorm ] unit-test +[ t ] [ svector{ 3.0 4.0 } Vnorm 5.0 0.000001 ~ ] unit-test +[ t ] [ dvector{ 3.0 4.0 } Vnorm 5.0 0.000001 ~ ] unit-test -[ 13.0 ] [ cvector{ C{ 3.0 4.0 } 12.0 } Vnorm ] unit-test -[ 13.0 ] [ zvector{ C{ 3.0 4.0 } 12.0 } Vnorm ] unit-test +[ t ] [ cvector{ C{ 3.0 4.0 } 12.0 } Vnorm 13.0 0.000001 ~ ] unit-test +[ t ] [ zvector{ C{ 3.0 4.0 } 12.0 } Vnorm 13.0 0.000001 ~ ] unit-test ! Vasum From e8657995b650b3eab66a5310aca126e444de61c8 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 11 Feb 2009 18:35:08 -0600 Subject: [PATCH 06/13] code annotations toy --- extra/annotations/annotations.factor | 41 ++++++++++++++++++++++++++++ extra/annotations/authors.txt | 2 ++ extra/annotations/summary.txt | 1 + extra/annotations/tags.txt | 2 ++ 4 files changed, 46 insertions(+) create mode 100644 extra/annotations/annotations.factor create mode 100644 extra/annotations/authors.txt create mode 100644 extra/annotations/summary.txt create mode 100644 extra/annotations/tags.txt diff --git a/extra/annotations/annotations.factor b/extra/annotations/annotations.factor new file mode 100644 index 0000000000..5102a36a71 --- /dev/null +++ b/extra/annotations/annotations.factor @@ -0,0 +1,41 @@ +! (c)2009 Joe Groff, Doug Coleman. see BSD license +USING: accessors combinators.short-circuit definitions functors +kernel lexer namespaces parser prettyprint sequences words ; +IN: annotations + +<< + +: (parse-annotation) ( accum -- accum ) + lexer get [ line-text>> parsed ] [ next-line ] bi ; + +: (non-annotation-usage) ( word -- usages ) + smart-usage + [ { [ word? ] [ vocabulary>> "annotations" = not ] } 1&& ] + filter ; + +FUNCTOR: define-annotation ( NAME -- ) + +(NAME) DEFINES (${NAME}) +!NAME DEFINES !${NAME} +NAMEs DEFINES ${NAME}s +NAMEs. DEFINES ${NAME}s. + +WHERE + +: (NAME) ( str -- ) drop ; inline +: !NAME (parse-annotation) \ (NAME) parsed ; parsing + +: NAMEs ( -- usages ) + \ (NAME) (non-annotation-usage) ; +: NAMEs. ( -- ) + NAMEs sorted-definitions. ; + +;FUNCTOR + +{ + "XXX" "TODO" "FIXME" "BUG" "REVIEW" "LICENSE" + "AUTHOR" "BROKEN" "HACK" "LOL" "NOTE" +} [ define-annotation ] each + +>> + diff --git a/extra/annotations/authors.txt b/extra/annotations/authors.txt new file mode 100644 index 0000000000..0bc3c5ad4d --- /dev/null +++ b/extra/annotations/authors.txt @@ -0,0 +1,2 @@ +Joe Groff +Doug Coleman diff --git a/extra/annotations/summary.txt b/extra/annotations/summary.txt new file mode 100644 index 0000000000..732ed6f988 --- /dev/null +++ b/extra/annotations/summary.txt @@ -0,0 +1 @@ +Code annotation comment syntax diff --git a/extra/annotations/tags.txt b/extra/annotations/tags.txt new file mode 100644 index 0000000000..278296de5e --- /dev/null +++ b/extra/annotations/tags.txt @@ -0,0 +1,2 @@ +comments +annotation From 6c723642bd5ae573ded152c9bee1bdfa50178fd3 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 11 Feb 2009 18:42:01 -0600 Subject: [PATCH 07/13] annotations tests --- extra/annotations/annotations-tests.factor | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 extra/annotations/annotations-tests.factor diff --git a/extra/annotations/annotations-tests.factor b/extra/annotations/annotations-tests.factor new file mode 100644 index 0000000000..72fd0f8b74 --- /dev/null +++ b/extra/annotations/annotations-tests.factor @@ -0,0 +1,17 @@ +USING: annotations math sorting tools.test ; +IN: annotations.tests + +: three ( -- x ) + !BROKEN find a dictionary + "threa" ; + +: four ( -- x ) + !BROKEN this code is broken + 2 2 + 1+ ; + +: five ( -- x ) + !TODO return 5 + f ; + +[ { four three } ] [ BROKENs natural-sort ] unit-test +[ { five } ] [ TODOs ] unit-test From 87c9ab72c325d2ea376a9ea5dd45bbd6db161b9e Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 11 Feb 2009 18:58:42 -0600 Subject: [PATCH 08/13] don't want to filter nonword annotation usages --- extra/annotations/annotations-tests.factor | 16 +++++++++++++--- extra/annotations/annotations.factor | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/extra/annotations/annotations-tests.factor b/extra/annotations/annotations-tests.factor index 72fd0f8b74..d5a13e48d8 100644 --- a/extra/annotations/annotations-tests.factor +++ b/extra/annotations/annotations-tests.factor @@ -1,9 +1,12 @@ -USING: annotations math sorting tools.test ; +USING: accessors annotations combinators.short-circuit +io.pathnames kernel math sequences sorting tools.test ; IN: annotations.tests +!NOTE testing toplevel form + : three ( -- x ) - !BROKEN find a dictionary - "threa" ; + !BROKEN english plz + "þrij" ; : four ( -- x ) !BROKEN this code is broken @@ -13,5 +16,12 @@ IN: annotations.tests !TODO return 5 f ; +[ t ] [ + NOTEs { + [ length 1 = ] + [ first string>> file-name "annotations-tests.factor" = ] + } 1&& +] unit-test + [ { four three } ] [ BROKENs natural-sort ] unit-test [ { five } ] [ TODOs ] unit-test diff --git a/extra/annotations/annotations.factor b/extra/annotations/annotations.factor index 5102a36a71..c61250b89d 100644 --- a/extra/annotations/annotations.factor +++ b/extra/annotations/annotations.factor @@ -10,7 +10,7 @@ IN: annotations : (non-annotation-usage) ( word -- usages ) smart-usage - [ { [ word? ] [ vocabulary>> "annotations" = not ] } 1&& ] + [ { [ word? ] [ vocabulary>> "annotations" = ] } 1&& not ] filter ; FUNCTOR: define-annotation ( NAME -- ) From ff33f38a0296c5122f89080312f0fab4e656536e Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 11 Feb 2009 19:58:28 -0600 Subject: [PATCH 09/13] annotations docs --- extra/annotations/annotations-docs.factor | 42 +++++++++++++++++++++++ extra/annotations/annotations.factor | 6 ++-- 2 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 extra/annotations/annotations-docs.factor diff --git a/extra/annotations/annotations-docs.factor b/extra/annotations/annotations-docs.factor new file mode 100644 index 0000000000..c340554119 --- /dev/null +++ b/extra/annotations/annotations-docs.factor @@ -0,0 +1,42 @@ +USING: accessors arrays combinators definitions generalizations +help help.markup help.topics kernel sequences sorting vocabs +words ; +IN: annotations + + + +"Code annotations" +{ + "The " { $vocab-link "annotations" } " vocabulary provides syntax for comment-like annotations that can be looked up with Factor's " { $link usage } " mechanism." +} +annotation-tags natural-sort +[ + [ \ $subsection swap comment-word 2array ] map append + "To look up annotations:" suffix +] [ + [ \ $subsection swap comment-usage.-word 2array ] map append +] bi +
"annotations" add-article + +"annotations" vocab "annotations" >>help drop + +annotation-tags [ + { + [ [ \ $syntax ] dip "!" " your comment here" surround 2array ] + [ [ \ $description "Treats the rest of the line after the exclamation point as a code annotation that can be looked up with the " \ $link ] dip comment-usage.-word 2array " word." 4array ] + [ [ \ $unchecked-example ] dip ": foo ( x y z -- w )\n !" " --w-ó()ò-w-- kilroy was here\n + * ;" surround 2array 3array ] + [ comment-word set-word-help ] + + [ [ \ $description "Displays a list of words, help articles, and vocabularies that contain " \ $link ] dip comment-word 2array " annotations." 4array 1array ] + [ comment-usage.-word set-word-help ] + + [ [ { $values { "usages" sequence } } \ $description "Returns a list of words, help articles, and vocabularies that contain " \ $link ] dip [ comment-word 2array " annotations. For a more user-friendly display, use the " \ $link ] [ comment-usage.-word 2array " word." 6 narray 2array ] bi ] + [ comment-usage-word set-word-help ] + + [ [ comment-word ] [ comment-usage-word ] [ comment-usage.-word ] tri 3array related-words ] + } cleave +] each diff --git a/extra/annotations/annotations.factor b/extra/annotations/annotations.factor index c61250b89d..6685e4e036 100644 --- a/extra/annotations/annotations.factor +++ b/extra/annotations/annotations.factor @@ -32,10 +32,12 @@ WHERE ;FUNCTOR -{ +CONSTANT: annotation-tags { "XXX" "TODO" "FIXME" "BUG" "REVIEW" "LICENSE" "AUTHOR" "BROKEN" "HACK" "LOL" "NOTE" -} [ define-annotation ] each +} + +annotation-tags [ define-annotation ] each >> From 0bc16d0cf82757516eff54ab37bb8823c52901cc Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 11 Feb 2009 20:11:33 -0600 Subject: [PATCH 10/13] documentation ambiguity --- basis/math/blas/vectors/vectors-docs.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/math/blas/vectors/vectors-docs.factor b/basis/math/blas/vectors/vectors-docs.factor index 296437c32b..badc317189 100644 --- a/basis/math/blas/vectors/vectors-docs.factor +++ b/basis/math/blas/vectors/vectors-docs.factor @@ -93,7 +93,7 @@ HELP: Viamax HELP: Vamax { $values { "x" blas-vector-base } { "max" number } } -{ $description "Return the value of the element in " { $snippet "x" } " with the largest norm-1. If more than one element has the same norm-1, returns the first element. Corresponds to the IxAMAX routines in BLAS." } ; +{ $description "Return the value of the element in " { $snippet "x" } " with the largest norm-1. If more than one element has the same norm-1, returns the element closest to the beginning. Corresponds to the IxAMAX routines in BLAS." } ; { Viamax Vamax } related-words From 19eb0471bb27673b09a96724045c25f1506eafe4 Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Thu, 12 Feb 2009 01:31:54 -0600 Subject: [PATCH 11/13] Creating XML component --- basis/html/components/components-docs.factor | 6 +++++- basis/html/components/components.factor | 5 +++++ basis/html/templates/chloe/chloe-docs.factor | 5 +++-- basis/html/templates/chloe/chloe.factor | 1 + 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/basis/html/components/components-docs.factor b/basis/html/components/components-docs.factor index b432cc0cc6..37dbeba6c1 100644 --- a/basis/html/components/components-docs.factor +++ b/basis/html/components/components-docs.factor @@ -57,7 +57,10 @@ HELP: hidden { $description "Hidden components render as a hidden form field. For example, a page for editing a weblog post might contain a hidden field with the post ID." } ; HELP: html -{ $description "HTML components render HTML verbatim, without any escaping. Care must be taken to only render trusted input, to avoid cross-site scripting attacks." } ; +{ $description "HTML components render HTML verbatim from a string, without any escaping. Care must be taken to only render trusted input, to avoid cross-site scripting attacks." } ; + +HELP: xml +{ $description "XML components render XML verbatim, from an XML chunk. Care must be taken to only render trusted input, to avoid cross-site scripting attacks." } ; HELP: inspector { $description "Inspector components render an arbitrary object by passing it to the " { $link describe } " word." } ; @@ -90,6 +93,7 @@ $nl { $subsection inspector } { $subsection comparison } { $subsection html } +{ $subsection xml } "Tuple components:" { $subsection field } { $subsection password } diff --git a/basis/html/components/components.factor b/basis/html/components/components.factor index 2b18e28351..9dddb85619 100644 --- a/basis/html/components/components.factor +++ b/basis/html/components/components.factor @@ -171,3 +171,8 @@ M: comparison render* SINGLETON: html M: html render* 2drop ; + +! XML component +SINGLETON: xml + +M: xml render* 2drop ; diff --git a/basis/html/templates/chloe/chloe-docs.factor b/basis/html/templates/chloe/chloe-docs.factor index 18e6db66f6..fcfd454478 100644 --- a/basis/html/templates/chloe/chloe-docs.factor +++ b/basis/html/templates/chloe/chloe-docs.factor @@ -1,8 +1,8 @@ IN: html.templates.chloe -USING: help.markup help.syntax html.components html.forms +USING: xml.data help.markup help.syntax html.components html.forms html.templates html.templates.chloe.syntax html.templates.chloe.compiler html.templates.chloe.components -math xml.data strings quotations namespaces ; +math strings quotations namespaces ; HELP: { $values { "path" "a pathname string without the trailing " { $snippet ".xml" } " extension" } { "chloe" chloe } } @@ -70,6 +70,7 @@ ARTICLE: "html.templates.chloe.tags.component" "Component Chloe tags" { { $snippet "t:field" } { $link field } } { { $snippet "t:hidden" } { $link hidden } } { { $snippet "t:html" } { $link html } } + { { $snippet "t:xml" } { $link xml } } { { $snippet "t:inspector" } { $link inspector } } { { $snippet "t:label" } { $link label } } { { $snippet "t:link" } { $link link } } diff --git a/basis/html/templates/chloe/chloe.factor b/basis/html/templates/chloe/chloe.factor index eafa3c3a5d..439b207063 100644 --- a/basis/html/templates/chloe/chloe.factor +++ b/basis/html/templates/chloe/chloe.factor @@ -95,6 +95,7 @@ COMPONENT: password COMPONENT: choice COMPONENT: checkbox COMPONENT: code +COMPONENT: xml SYMBOL: template-cache From 6215c38676f038d1313fe14d8058a1c9e7fb407c Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Thu, 12 Feb 2009 01:32:06 -0600 Subject: [PATCH 12/13] Fixing minor CSV bug --- basis/csv/csv-tests.factor | 5 ++--- basis/csv/csv.factor | 9 ++++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/basis/csv/csv-tests.factor b/basis/csv/csv-tests.factor index 50bc3836f5..6ba8e2d5b8 100644 --- a/basis/csv/csv-tests.factor +++ b/basis/csv/csv-tests.factor @@ -7,9 +7,6 @@ IN: csv.tests : named-unit-test ( name output input -- ) unit-test drop ; inline -! tests nicked from the wikipedia csv article -! http://en.wikipedia.org/wiki/Comma-separated_values - "Fields are separated by commas" [ { { "1997" "Ford" "E350" } } ] [ "1997,Ford,E350" csv ] named-unit-test @@ -90,3 +87,5 @@ IN: csv.tests { { "writing,some,csv,tests" } } dup "csv-test2-" unique-file utf8 [ csv>file ] [ file>csv ] 2bi = ] unit-test + +[ { { "hello" "" "" "" "goodbye" "" } } ] [ "hello,,\"\",,goodbye," csv ] unit-test diff --git a/basis/csv/csv.factor b/basis/csv/csv.factor index 152b3dcbba..5902999a76 100755 --- a/basis/csv/csv.factor +++ b/basis/csv/csv.factor @@ -46,13 +46,15 @@ DEFER: quoted-field ( -- endchar ) : (row) ( -- sep ) field , - dup delimiter get = [ drop (row) ] when ; + dup delimiter> = [ drop (row) ] when ; : row ( -- eof? array[string] ) [ (row) ] { } make ; : (csv) ( -- ) - row harvest [ , ] unless-empty [ (csv) ] when ; + row + dup [ empty? ] all? [ drop ] [ , ] if + [ (csv) ] when ; PRIVATE> @@ -60,7 +62,8 @@ PRIVATE> [ row nip ] with-input-stream ; : csv ( stream -- rows ) - [ [ (csv) ] { } make ] with-input-stream ; + [ [ (csv) ] { } make ] with-input-stream + dup peek { "" } = [ but-last ] when ; : file>csv ( path encoding -- csv ) csv ; From eaaf2af7b77233698f41fc1388ec8462ab6e75cc Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Thu, 12 Feb 2009 01:39:14 -0600 Subject: [PATCH 13/13] Fixing db.sqlite bug: database schema don't need primary keys --- basis/db/sqlite/sqlite-tests.factor | 22 ++++++++++++++++++++++ basis/db/sqlite/sqlite.factor | 12 +++++++----- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/basis/db/sqlite/sqlite-tests.factor b/basis/db/sqlite/sqlite-tests.factor index 6fb1cd19ad..69d5f1dd43 100644 --- a/basis/db/sqlite/sqlite-tests.factor +++ b/basis/db/sqlite/sqlite-tests.factor @@ -73,3 +73,25 @@ IN: db.sqlite.tests "select * from person" sql-query length ] with-db ] unit-test + +! You don't need a primary key +USING: accessors arrays sorting ; +TUPLE: things one two ; + +things "THINGS" { + { "one" "ONE" INTEGER +not-null+ } + { "two" "TWO" INTEGER +not-null+ } +} define-persistent + +[ { { 0 0 } { 0 1 } { 1 0 } { 1 1 } } ] [ + test.db [ + things create-table + 0 0 things boa insert-tuple + 0 1 things boa insert-tuple + 1 1 things boa insert-tuple + 1 0 things boa insert-tuple + f f things boa select-tuples + [ [ one>> ] [ two>> ] bi 2array ] map natural-sort + things drop-table + ] with-db +] unit-test diff --git a/basis/db/sqlite/sqlite.factor b/basis/db/sqlite/sqlite.factor index fe3bb64d45..9b05cf9825 100755 --- a/basis/db/sqlite/sqlite.factor +++ b/basis/db/sqlite/sqlite.factor @@ -138,11 +138,13 @@ M: sqlite-db-connection create-sql-statement ( class -- statement ) modifiers 0% ] interleave - ", " 0% - find-primary-key - "primary key(" 0% - [ "," 0% ] [ column-name>> 0% ] interleave - "));" 0% + find-primary-key [ + ", " 0% + "primary key(" 0% + [ "," 0% ] [ column-name>> 0% ] interleave + ")" 0% + ] unless-empty + ");" 0% ] query-make ; M: sqlite-db-connection drop-sql-statement ( class -- statement )