factor/basis/xml/dispatch/dispatch.factor

33 lines
826 B
Factor
Raw Normal View History

! Copyright (C) 2005, 2009 Daniel Ehrenberg
! See http://factorcode.org/license.txt for BSD license.
USING: words assocs kernel accessors parser sequences summary
2009-02-04 13:34:18 -05:00
lexer splitting fry combinators locals ;
IN: xml.dispatch
2009-02-04 02:25:48 -05:00
TUPLE: no-tag name word ;
M: no-tag summary
drop "The tag-dispatching word has no method for the given tag name" ;
2009-02-04 14:25:51 -05:00
<PRIVATE
2009-02-04 02:25:48 -05:00
: compile-tags ( word xtable -- quot )
>alist swap '[ _ no-tag boa throw ] suffix
2009-02-04 02:25:48 -05:00
'[ dup main>> _ case ] ;
2009-02-04 14:25:51 -05:00
PRIVATE>
2009-02-04 02:25:48 -05:00
: define-tags ( word -- )
dup dup "xtable" word-prop compile-tags define ;
:: define-tag ( string word quot -- )
quot string word "xtable" word-prop set-at
word define-tags ;
: TAGS:
CREATE
2009-02-04 02:25:48 -05:00
[ H{ } clone "xtable" set-word-prop ]
[ define-tags ] bi ; parsing
: TAG:
2009-02-04 02:25:48 -05:00
scan scan-word parse-definition define-tag ; parsing