Merge branch 'master' of git://factorcode.org/git/factor

db4
Doug Coleman 2010-06-04 08:37:15 -05:00
commit 0fa5a1ca2c
5 changed files with 18 additions and 11 deletions

View File

@ -1,14 +1,18 @@
! Copyright (C) 2006 Chris Double.
! See http://factorcode.org/license.txt for BSD license.
USING: help.markup help.syntax ;
USING: help.markup help.syntax kernel ;
IN: json.reader
HELP: json>
{ $values { "string" "a string in JSON format" } { "object" "a deserialized object" } }
{ $description "Deserializes the JSON formatted string into a Factor object. JSON objects are converted to Factor hashtables. All other JSON objects convert to their obvious Factor equivalents." } ;
HELP: read-jsons
{ $values { "objects" "a vector of deserialized objects" } }
{ $description "Reads JSON formatted strings into a vector of Factor object until the end of the stream is reached. JSON objects are converted to Factor hashtables. All other JSON objects convert to their obvious Factor equivalents." } ;
ARTICLE: "json.reader" "JSON reader"
"The " { $vocab-link "json.reader" } " vocabulary defines a word for parsing strings in JSON format."
{ $subsections json> } ;
{ $subsections json> read-jsons } ;
ABOUT: "json.reader"

View File

@ -1,5 +1,5 @@
USING: assocs arrays json.reader kernel strings tools.test
hashtables json ;
hashtables json io.streams.string ;
IN: json.reader.tests
{ f } [ "false" json> ] unit-test
@ -59,5 +59,8 @@ IN: json.reader.tests
{ 0 } [ "0 " json> ] unit-test
{ 0 } [ " 0 " json> ] unit-test
{ V{ H{ { "a" "b" } } H{ { "c" "d" } } } }
[ """{"a": "b"} {"c": "d"}""" [ read-jsons ] with-string-reader ] unit-test
! empty objects are allowed as values in objects
{ H{ { "foo" H{ } } } } [ "{ \"foo\" : {}}" json> ] unit-test

View File

@ -78,7 +78,7 @@ DEFER: j-string
{ CHAR: { [ 2 [ V{ } clone over push ] times ] }
{ CHAR: : [ v-pick-push ] }
{ CHAR: } [ (close-hash) ] }
{ CHAR: \u000020 [ ] }
{ CHAR: \s [ ] }
{ CHAR: \t [ ] }
{ CHAR: \r [ ] }
{ CHAR: \n [ ] }
@ -89,10 +89,10 @@ DEFER: j-string
} case
] when* ;
: (json-parser>) ( string -- object )
[ V{ } clone [ read1 dup ] [ scan ] while drop first ] with-string-reader ;
PRIVATE>
: read-jsons ( -- objects )
V{ } clone [ read1 dup ] [ scan ] while drop ;
: json> ( string -- object )
(json-parser>) ;
[ read-jsons first ] with-string-reader ;

View File

@ -248,7 +248,7 @@ CONSTANT: window-control>ex-style
{ minimize-button 0 }
{ maximize-button 0 }
{ resize-handles $ WS_EX_WINDOWEDGE }
{ small-title-bar $ WS_EX_TOOLWINDOW }
{ small-title-bar $[ WS_EX_TOOLWINDOW WS_EX_TOPMOST bitor ] }
{ normal-title-bar $ WS_EX_APPWINDOW }
}

View File

@ -65,9 +65,9 @@ ARTICLE: "apply-combinators" "Apply combinators"
"All of the apply combinators are equivalent to using the corresponding " { $link "spread-combinators" } " with the same quotation supplied for every value." ;
ARTICLE: "dip-keep-combinators" "Preserving combinators"
"Sometimes it is necessary to temporarily hide values on the datastack. The " { $snippet "dip" } " combinators invoke the quotation at the top of the stack, hiding some number of values underneath:"
"Sometimes it is necessary to temporarily hide values on the datastack. The " { $snippet "dip" } " combinators invoke the quotation at the top of the stack, hiding some number of values:"
{ $subsections dip 2dip 3dip 4dip }
"The " { $snippet "keep" } " combinators invoke a quotation and restore some number of values to the top of the stack when it completes:"
"The " { $snippet "keep" } " combinators invoke a quotation and restore some number of values to the top of the stack:"
{ $subsections keep 2keep 3keep } ;
ARTICLE: "curried-dataflow" "Curried dataflow combinators"