1 USING: accessors sequences assocs kernel quotations namespaces
2 xml.data xml.traversal combinators macros parser lexer words fry ;
5 : implies ( x y -- z ) [ not ] dip or ; inline
7 : child-tags ( tag -- seq ) children>> [ tag? ] filter ;
9 : map-find ( seq quot -- result elt )
12 [ [ drop f ] unless ] dip ; inline
14 : tag-init-form ( spec -- quot )
16 { [ dup quotation? ] [ [ object get tag get ] prepose ] }
17 { [ dup length 2 = ] [
19 tag get children>string
20 _ [ execute ] when* object get _ execute
23 { [ dup length 3 = ] [
26 _ [ execute ] when* object get _ execute
31 : with-tag-initializer ( tag obj quot -- )
32 [ object set tag set ] prepose with-scope ; inline
34 MACRO: (init-from-tag) ( specs -- )
35 [ tag-init-form ] map concat [ ] like
36 [ with-tag-initializer ] curry ;
38 : init-from-tag ( tag tuple specs -- tuple )
39 over [ (init-from-tag) ] dip ; inline
42 SYMBOL: tag-handler-word
45 CREATE tag-handler-word set
46 H{ } clone tag-handlers set ; parsing
48 : (TAG:) ( name quot -- ) swap tag-handlers get set-at ;
56 tag-handlers get >alist [ [ dup main>> ] dip case ] curry