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 : tag-init-form ( spec -- quot )
11 { [ dup quotation? ] [ [ object get tag get ] prepose ] }
12 { [ dup length 2 = ] [
14 tag get children>string
15 _ [ execute ] when* object get _ execute
18 { [ dup length 3 = ] [
21 _ [ execute ] when* object get _ execute
26 : with-tag-initializer ( tag obj quot -- )
27 [ object set tag set ] prepose with-scope ; inline
29 MACRO: (init-from-tag) ( specs -- )
30 [ tag-init-form ] map concat [ ] like
31 [ with-tag-initializer ] curry ;
33 : init-from-tag ( tag tuple specs -- tuple )
34 over [ (init-from-tag) ] dip ; inline
37 SYMBOL: tag-handler-word
40 CREATE tag-handler-word set
41 H{ } clone tag-handlers set ; parsing
43 : (TAG:) ( name quot -- ) swap tag-handlers get set-at ;
51 tag-handlers get >alist [ [ dup main>> ] dip case ] curry