| 
									
										
										
										
											2009-01-21 19:16:51 -05:00
										 |  |  | ! Copyright (C) 2005, 2009 Daniel Ehrenberg, Slava Pestov | 
					
						
							|  |  |  | ! See http://factorcode.org/license.txt for BSD license. | 
					
						
							|  |  |  | USING: xml.tokenize xml.data xml.state kernel sequences ascii | 
					
						
							|  |  |  | fry xml.errors combinators hashtables namespaces xml.entities | 
					
						
							| 
									
										
										
										
											2009-01-23 16:29:28 -05:00
										 |  |  | strings xml.name ;
 | 
					
						
							| 
									
										
										
										
											2009-01-21 19:16:51 -05:00
										 |  |  | IN: xml.dtd | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : take-decl-contents ( -- first second )
 | 
					
						
							|  |  |  |     pass-blank take-word pass-blank ">" take-string ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : take-element-decl ( -- element-decl )
 | 
					
						
							|  |  |  |     take-decl-contents <element-decl> ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : take-attlist-decl ( -- attlist-decl )
 | 
					
						
							|  |  |  |     take-decl-contents <attlist-decl> ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : take-notation-decl ( -- notation-decl )
 | 
					
						
							| 
									
										
										
										
											2015-06-29 19:43:15 -04:00
										 |  |  |     take-decl-contents <notation-decl> ;
 | 
					
						
							| 
									
										
										
										
											2009-01-21 19:16:51 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | UNION: dtd-acceptable | 
					
						
							|  |  |  |     directive comment instruction ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : take-entity-def ( var -- entity-name entity-def )
 | 
					
						
							|  |  |  |     [ | 
					
						
							|  |  |  |         take-word pass-blank get-char { | 
					
						
							|  |  |  |             { CHAR: ' [ parse-quote ] } | 
					
						
							| 
									
										
										
										
											2016-09-04 00:40:43 -04:00
										 |  |  |             { CHAR: \" [ parse-quote ] } | 
					
						
							| 
									
										
										
										
											2009-01-23 16:29:28 -05:00
										 |  |  |             [ drop take-external-id close ] | 
					
						
							| 
									
										
										
										
											2009-01-21 19:16:51 -05:00
										 |  |  |         } case
 | 
					
						
							|  |  |  |    ] dip '[ swap _ [ ?set-at ] change ] 2keep ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : take-entity-decl ( -- entity-decl )
 | 
					
						
							|  |  |  |     pass-blank get-char { | 
					
						
							|  |  |  |         { CHAR: % [ next pass-blank pe-table take-entity-def t ] } | 
					
						
							|  |  |  |         [ drop extra-entities take-entity-def f ] | 
					
						
							| 
									
										
										
										
											2009-01-22 17:31:22 -05:00
										 |  |  |     } case close <entity-decl> ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : take-inner-directive ( string -- directive )
 | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         { "ELEMENT" [ take-element-decl ] } | 
					
						
							|  |  |  |         { "ATTLIST" [ take-attlist-decl ] } | 
					
						
							|  |  |  |         { "ENTITY" [ take-entity-decl ] } | 
					
						
							|  |  |  |         { "NOTATION" [ take-notation-decl ] } | 
					
						
							|  |  |  |         [ bad-directive ] | 
					
						
							|  |  |  |     } case ;
 |