1 ! Copyright (C) 2005, 2009 Daniel Ehrenberg, Slava Pestov
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: combinators hashtables kernel namespaces xml.data
4 xml.errors xml.name xml.state xml.tokenize ;
7 : take-decl-contents ( -- first second )
8 pass-blank take-word pass-blank ">" take-string ;
10 : take-element-decl ( -- element-decl )
11 take-decl-contents <element-decl> ;
13 : take-attlist-decl ( -- attlist-decl )
14 take-decl-contents <attlist-decl> ;
16 : take-notation-decl ( -- notation-decl )
17 take-decl-contents <notation-decl> ;
20 directive comment instruction ;
22 : take-entity-def ( var -- entity-name entity-def )
24 take-word pass-blank get-char {
25 { CHAR: ' [ parse-quote ] }
26 { CHAR: \" [ parse-quote ] }
27 [ drop take-external-id close ]
29 ] dip '[ swap _ [ ?set-at ] change ] 2keep ;
31 : take-entity-decl ( -- entity-decl )
33 { CHAR: % [ next pass-blank pe-table take-entity-def t ] }
34 [ drop extra-entities take-entity-def f ]
35 } case close <entity-decl> ;
37 : take-inner-directive ( string -- directive )
39 { "ELEMENT" [ take-element-decl ] }
40 { "ATTLIST" [ take-attlist-decl ] }
41 { "ENTITY" [ take-entity-decl ] }
42 { "NOTATION" [ take-notation-decl ] }