1 ! Copyright (C) 2005, 2006 Daniel Ehrenberg
2 ! See https://factorcode.org/license.txt for BSD license.
3 USING: accessors classes classes.tuple classes.tuple.parser
4 classes.tuple.private combinators generalizations kernel math
5 namespaces parser sequences vocabs.loader words xml.state ;
10 PREDICATE: generated-xml-error < tuple class-of "xml-error-class" word-prop ;
12 : define-xml-error-class ( class superclass slots -- )
13 { "line" "column" } prepend error-slots {
14 [ define-tuple-class ]
15 [ 2drop reset-generic ]
16 [ 2drop t "error-class" set-word-prop ]
17 [ 2drop t "xml-error-class" set-word-prop ]
21 [ [ get-line get-column ] swap ndip boa throw ]
24 [ 2drop all-slots 2 head* thrower-effect ] 3bi define-declared
29 parse-tuple-definition pick save-location
30 define-xml-error-class ;
34 XML-ERROR: expected should-be was ;
36 XML-ERROR: unexpected-end ;
38 XML-ERROR: missing-close ;
40 XML-ERROR: disallowed-char char ;
44 ERROR: pre/post-content string pre? ;
46 XML-ERROR: no-entity thing ;
48 XML-ERROR: mismatched open close ;
50 TUPLE: unclosed line column tags ;
52 : throw-unclosed ( -- * )
54 xml-stack get rest-slice [ first name>> ] map
57 XML-ERROR: bad-uri string ;
59 XML-ERROR: nonexist-ns name ;
61 ! this should give which tag was unopened
64 XML-ERROR: not-yes/no text ;
66 ! this should actually print the names
67 XML-ERROR: extra-attrs attrs ;
69 XML-ERROR: bad-version num ;
73 XML-ERROR: bad-prolog prolog ;
75 XML-ERROR: capitalized-prolog name ;
77 XML-ERROR: versionless-prolog ;
79 XML-ERROR: bad-directive dir ;
83 XML-ERROR: bad-external-id ;
85 XML-ERROR: misplaced-directive dir ;
87 XML-ERROR: bad-name name ;
89 XML-ERROR: unclosed-quote ;
91 XML-ERROR: quoteless-attr ;
95 XML-ERROR: text-w/]]> ;
97 XML-ERROR: duplicate-attr key values ;
99 XML-ERROR: bad-cdata ;
101 XML-ERROR: not-enough-characters ;
103 XML-ERROR: bad-doctype read-contents ;
105 XML-ERROR: bad-encoding encoding ;
108 unclosed multitags notags pre/post-content generated-xml-error ;
110 { "xml.errors" "debugger" } "xml.errors.debugger" require-when