2009-01-27 14:34:14 -05:00
|
|
|
! 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 ;
|
2009-01-27 14:34:14 -05:00
|
|
|
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-01-27 14:34:14 -05:00
|
|
|
|
2009-02-04 14:25:51 -05:00
|
|
|
<PRIVATE
|
|
|
|
|
2009-02-04 02:25:48 -05:00
|
|
|
: compile-tags ( word xtable -- quot )
|
2009-02-04 13:32:47 -05:00
|
|
|
>alist swap '[ _ no-tag boa throw ] suffix
|
2009-02-04 02:25:48 -05:00
|
|
|
'[ dup main>> _ case ] ;
|
2009-01-27 14:34:14 -05:00
|
|
|
|
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:
|
2009-01-27 14:34:14 -05:00
|
|
|
CREATE
|
2009-02-04 02:25:48 -05:00
|
|
|
[ H{ } clone "xtable" set-word-prop ]
|
|
|
|
[ define-tags ] bi ; parsing
|
2009-01-27 14:34:14 -05:00
|
|
|
|
|
|
|
: TAG:
|
2009-02-04 02:25:48 -05:00
|
|
|
scan scan-word parse-definition define-tag ; parsing
|