[ [ accept-connection ] with-semaphore ]
[ accept-connection ]
if*
- ] [ accept-loop ] bi ; inline
+ ] [ accept-loop ] bi ; inline recursive
: started-accept-loop ( server -- )
threaded-server get
! Word-based XML literal syntax
: parsed-name ( accum -- accum )
- scan ":" split1 [ f <name> ] [ <name-tag> ] if* parsed ;
+ scan ":" split1 [ f <name> ] [ <simple-name> ] if* parsed ;
: run-combinator ( accum quot1 quot2 -- accum )
>r [ ] like parsed r> [ parsed ] each ;
: call-under ( quot object -- quot )
swap dup slip ; inline
-: sax-loop ( quot -- ) ! quot: xml-elem --
+: sax-loop ( quot: ( xml-elem -- ) -- )
parse-text call-under
get-char [ make-tag call-under sax-loop ]
- [ drop ] if ; inline
+ [ drop ] if ; inline recursive
-: sax ( stream quot -- ) ! quot: xml-elem --
+: sax ( stream quot: ( xml-elem -- ) -- )
swap [
reset-prolog init-ns-stack
prolog-data get call-under
sax-loop
- ] state-parse ; inline
+ ] state-parse ; inline recursive
: (read-xml) ( -- )
[ process ] sax-loop ; inline
>r over r> nth dup zero? [
3drop 0
] [
- >r nth dup zero? [
- r> 2drop 0
+ >r nth dup zero? r> swap [
+ 2drop 0
] [
- r> swap / neg
+ swap / neg
] if
] if ;
[ "link" tag-named "href" swap at >url >>url ]
[
{ "content" "summary" } any-tag-named
- dup tag-children [ string? not ] contains?
- [ tag-children [ write-chunk ] with-string-writer ]
+ dup children>> [ string? not ] contains?
+ [ children>> [ write-chunk ] with-string-writer ]
[ children>string ] if >>description
]
[
tri ;
: xml>feed ( xml -- feed )
- dup name-tag {
+ dup main>> {
{ "RDF" [ rss1.0 ] }
{ "rss" [ rss2.0 ] }
{ "feed" [ atom1.0 ] }