| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | ! Copyright (C) 2005, 2006 Daniel Ehrenberg | 
					
						
							|  |  |  | ! See http://factorcode.org/license.txt for BSD license. | 
					
						
							| 
									
										
										
										
											2011-01-29 00:09:09 -05:00
										 |  |  | USING: accessors kernel namespaces sequences vocabs.loader | 
					
						
							|  |  |  | xml.state ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | IN: xml.errors | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  | TUPLE: xml-error-at line column ;
 | 
					
						
							| 
									
										
										
										
											2009-01-21 00:54:33 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  | : xml-error-at ( class -- obj )
 | 
					
						
							| 
									
										
										
										
											2009-01-21 00:54:33 -05:00
										 |  |  |     new
 | 
					
						
							|  |  |  |         get-line >>line | 
					
						
							|  |  |  |         get-column >>column ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  | TUPLE: expected < xml-error-at should-be was ;
 | 
					
						
							| 
									
										
										
										
											2011-01-29 00:09:09 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-21 00:54:33 -05:00
										 |  |  | : expected ( should-be was -- * )
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  |     \ expected xml-error-at | 
					
						
							| 
									
										
										
										
											2009-01-21 00:54:33 -05:00
										 |  |  |         swap >>was | 
					
						
							|  |  |  |         swap >>should-be throw ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  | TUPLE: unexpected-end < xml-error-at ;
 | 
					
						
							| 
									
										
										
										
											2011-01-29 00:09:09 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  | : unexpected-end ( -- * ) \ unexpected-end xml-error-at throw ;
 | 
					
						
							| 
									
										
										
										
											2009-01-21 00:54:33 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  | TUPLE: missing-close < xml-error-at ;
 | 
					
						
							| 
									
										
										
										
											2011-01-29 00:09:09 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  | : missing-close ( -- * ) \ missing-close xml-error-at throw ;
 | 
					
						
							| 
									
										
										
										
											2009-01-21 00:54:33 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  | TUPLE: disallowed-char < xml-error-at char ;
 | 
					
						
							| 
									
										
										
										
											2009-01-21 00:54:33 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | : disallowed-char ( char -- * )
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  |     \ disallowed-char xml-error-at swap >>char throw ;
 | 
					
						
							| 
									
										
										
										
											2009-01-21 00:54:33 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-02 20:59:16 -05:00
										 |  |  | ERROR: multitags ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ERROR: pre/post-content string pre? ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  | TUPLE: no-entity < xml-error-at thing ;
 | 
					
						
							| 
									
										
										
										
											2008-12-02 20:59:16 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | : no-entity ( string -- * )
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  |     \ no-entity xml-error-at swap >>thing throw ;
 | 
					
						
							| 
									
										
										
										
											2008-12-02 20:59:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  | TUPLE: mismatched < xml-error-at open close ;
 | 
					
						
							| 
									
										
										
										
											2008-12-02 20:59:16 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | : mismatched ( open close -- * )
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  |     \ mismatched xml-error-at swap >>close swap >>open throw ;
 | 
					
						
							| 
									
										
										
										
											2008-12-02 20:59:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  | TUPLE: unclosed < xml-error-at tags ;
 | 
					
						
							| 
									
										
										
										
											2008-12-02 20:59:16 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | : unclosed ( -- * )
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  |     \ unclosed xml-error-at | 
					
						
							| 
									
										
										
										
											2008-12-02 20:59:16 -05:00
										 |  |  |         xml-stack get rest-slice [ first name>> ] map >>tags | 
					
						
							|  |  |  |     throw ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  | TUPLE: bad-uri < xml-error-at string ;
 | 
					
						
							| 
									
										
										
										
											2008-12-02 20:59:16 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | : bad-uri ( string -- * )
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  |     \ bad-uri xml-error-at swap >>string throw ;
 | 
					
						
							| 
									
										
										
										
											2008-12-02 20:59:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  | TUPLE: nonexist-ns < xml-error-at name ;
 | 
					
						
							| 
									
										
										
										
											2008-12-02 20:59:16 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | : nonexist-ns ( name-string -- * )
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  |     \ nonexist-ns xml-error-at swap >>name throw ;
 | 
					
						
							| 
									
										
										
										
											2008-12-02 20:59:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-01-29 00:09:09 -05:00
										 |  |  | ! this should give which tag was unopened | 
					
						
							|  |  |  | TUPLE: unopened < xml-error-at ;
 | 
					
						
							| 
									
										
										
										
											2008-12-02 20:59:16 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | : unopened ( -- * )
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  |     \ unopened xml-error-at throw ;
 | 
					
						
							| 
									
										
										
										
											2008-12-02 20:59:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  | TUPLE: not-yes/no < xml-error-at text ;
 | 
					
						
							| 
									
										
										
										
											2008-12-02 20:59:16 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | : not-yes/no ( text -- * )
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  |     \ not-yes/no xml-error-at swap >>text throw ;
 | 
					
						
							| 
									
										
										
										
											2008-12-02 20:59:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-05-02 18:12:09 -04:00
										 |  |  | ! this should actually print the names | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  | TUPLE: extra-attrs < xml-error-at attrs ;
 | 
					
						
							| 
									
										
										
										
											2008-12-02 20:59:16 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | : extra-attrs ( attrs -- * )
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  |     \ extra-attrs xml-error-at swap >>attrs throw ;
 | 
					
						
							| 
									
										
										
										
											2008-12-02 20:59:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  | TUPLE: bad-version < xml-error-at num ;
 | 
					
						
							| 
									
										
										
										
											2008-12-02 20:59:16 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | : bad-version ( num -- * )
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  |     \ bad-version xml-error-at swap >>num throw ;
 | 
					
						
							| 
									
										
										
										
											2008-12-02 20:59:16 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ERROR: notags ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  | TUPLE: bad-prolog < xml-error-at prolog ;
 | 
					
						
							| 
									
										
										
										
											2008-12-02 20:59:16 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | : bad-prolog ( prolog -- * )
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  |     \ bad-prolog xml-error-at swap >>prolog throw ;
 | 
					
						
							| 
									
										
										
										
											2008-12-02 20:59:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  | TUPLE: capitalized-prolog < xml-error-at name ;
 | 
					
						
							| 
									
										
										
										
											2008-12-02 20:59:16 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | : capitalized-prolog ( name -- capitalized-prolog )
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  |     \ capitalized-prolog xml-error-at swap >>name throw ;
 | 
					
						
							| 
									
										
										
										
											2008-12-02 20:59:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  | TUPLE: versionless-prolog < xml-error-at ;
 | 
					
						
							| 
									
										
										
										
											2008-12-02 20:59:16 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | : versionless-prolog ( -- * )
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  |     \ versionless-prolog xml-error-at throw ;
 | 
					
						
							| 
									
										
										
										
											2008-12-02 20:59:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  | TUPLE: bad-directive < xml-error-at dir ;
 | 
					
						
							| 
									
										
										
										
											2008-12-02 20:59:16 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | : bad-directive ( directive -- * )
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  |     \ bad-directive xml-error-at swap >>dir throw ;
 | 
					
						
							| 
									
										
										
										
											2008-12-02 20:59:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  | TUPLE: bad-decl < xml-error-at ;
 | 
					
						
							| 
									
										
										
										
											2008-12-02 20:59:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-19 23:25:15 -05:00
										 |  |  | : bad-decl ( -- * )
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  |     \ bad-decl xml-error-at throw ;
 | 
					
						
							| 
									
										
										
										
											2008-12-02 20:59:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  | TUPLE: bad-external-id < xml-error-at ;
 | 
					
						
							| 
									
										
										
										
											2008-12-02 20:59:16 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | : bad-external-id ( -- * )
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  |     \ bad-external-id xml-error-at throw ;
 | 
					
						
							| 
									
										
										
										
											2008-12-02 20:59:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  | TUPLE: misplaced-directive < xml-error-at dir ;
 | 
					
						
							| 
									
										
										
										
											2008-12-02 20:59:16 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | : misplaced-directive ( directive -- * )
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  |     \ misplaced-directive xml-error-at swap >>dir throw ;
 | 
					
						
							| 
									
										
										
										
											2008-12-02 20:59:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  | TUPLE: bad-name < xml-error-at name ;
 | 
					
						
							| 
									
										
										
										
											2009-01-15 17:35:55 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | : bad-name ( name -- * )
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  |     \ bad-name xml-error-at swap >>name throw ;
 | 
					
						
							| 
									
										
										
										
											2009-01-15 17:35:55 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  | TUPLE: unclosed-quote < xml-error-at ;
 | 
					
						
							| 
									
										
										
										
											2009-01-15 17:35:55 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | : unclosed-quote ( -- * )
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  |     \ unclosed-quote xml-error-at throw ;
 | 
					
						
							| 
									
										
										
										
											2009-01-15 17:35:55 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  | TUPLE: quoteless-attr < xml-error-at ;
 | 
					
						
							| 
									
										
										
										
											2009-01-15 17:35:55 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | : quoteless-attr ( -- * )
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  |     \ quoteless-attr xml-error-at throw ;
 | 
					
						
							| 
									
										
										
										
											2009-01-15 17:35:55 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  | TUPLE: attr-w/< < xml-error-at ;
 | 
					
						
							| 
									
										
										
										
											2009-01-19 23:25:15 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-23 22:40:17 -05:00
										 |  |  | : attr-w/< ( -- * )
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  |     \ attr-w/< xml-error-at throw ;
 | 
					
						
							| 
									
										
										
										
											2009-01-19 23:25:15 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  | TUPLE: text-w/]]> < xml-error-at ;
 | 
					
						
							| 
									
										
										
										
											2009-01-19 23:25:15 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-23 22:40:17 -05:00
										 |  |  | : text-w/]]> ( -- * )
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  |     \ text-w/]]> xml-error-at throw ;
 | 
					
						
							| 
									
										
										
										
											2009-01-19 23:25:15 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  | TUPLE: duplicate-attr < xml-error-at key values ;
 | 
					
						
							| 
									
										
										
										
											2009-01-19 23:25:15 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | : duplicate-attr ( key values -- * )
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  |     \ duplicate-attr xml-error-at | 
					
						
							| 
									
										
										
										
											2009-01-19 23:25:15 -05:00
										 |  |  |     swap >>values swap >>key throw ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  | TUPLE: bad-cdata < xml-error-at ;
 | 
					
						
							| 
									
										
										
										
											2009-01-20 16:37:21 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | : bad-cdata ( -- * )
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  |     \ bad-cdata xml-error-at throw ;
 | 
					
						
							| 
									
										
										
										
											2009-01-20 16:37:21 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  | TUPLE: not-enough-characters < xml-error-at ;
 | 
					
						
							| 
									
										
										
										
											2011-01-29 00:09:09 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-21 00:54:33 -05:00
										 |  |  | : not-enough-characters ( -- * )
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  |     \ not-enough-characters xml-error-at throw ;
 | 
					
						
							| 
									
										
										
										
											2009-01-21 00:54:33 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  | TUPLE: bad-doctype < xml-error-at contents ;
 | 
					
						
							| 
									
										
										
										
											2011-01-29 00:09:09 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-21 19:16:51 -05:00
										 |  |  | : bad-doctype ( contents -- * )
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  |     \ bad-doctype xml-error-at swap >>contents throw ;
 | 
					
						
							| 
									
										
										
										
											2009-01-21 19:16:51 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-18 19:32:34 -04:00
										 |  |  | TUPLE: bad-encoding < xml-error-at encoding ;
 | 
					
						
							| 
									
										
										
										
											2011-01-29 00:09:09 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-18 19:32:34 -04:00
										 |  |  | : bad-encoding ( encoding -- * )
 | 
					
						
							|  |  |  |     \ bad-encoding xml-error-at | 
					
						
							|  |  |  |         swap >>encoding | 
					
						
							|  |  |  |     throw ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-26 17:11:30 -05:00
										 |  |  | UNION: xml-error | 
					
						
							|  |  |  |     multitags notags pre/post-content xml-error-at ;
 | 
					
						
							| 
									
										
										
										
											2011-01-29 00:09:09 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | { "xml.errors" "debugger" } "xml.errors.debugger" require-when |