]> gitweb.factorcode.org Git - factor.git/blob - basis/xml/errors/errors.factor
Switch to https urls
[factor.git] / basis / xml / errors / errors.factor
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 ;
6 IN: xml.errors
7
8 <<
9
10 PREDICATE: generated-xml-error < tuple class-of "xml-error-class" word-prop ;
11
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 ]
18         [
19             [
20                 length 1 - nip dupd
21                 [ [ get-line get-column ] swap ndip boa throw ]
22                 2curry
23             ]
24             [ 2drop all-slots 2 head* thrower-effect ] 3bi define-declared
25         ]
26     } 3cleave ;
27
28 SYNTAX: XML-ERROR:
29     parse-tuple-definition pick save-location
30     define-xml-error-class ;
31
32 >>
33
34 XML-ERROR: expected should-be was ;
35
36 XML-ERROR: unexpected-end ;
37
38 XML-ERROR: missing-close ;
39
40 XML-ERROR: disallowed-char char ;
41
42 ERROR: multitags ;
43
44 ERROR: pre/post-content string pre? ;
45
46 XML-ERROR: no-entity thing ;
47
48 XML-ERROR: mismatched open close ;
49
50 TUPLE: unclosed line column tags ;
51
52 : throw-unclosed ( -- * )
53     get-line get-column
54     xml-stack get rest-slice [ first name>> ] map
55     unclosed boa throw ;
56
57 XML-ERROR: bad-uri string ;
58
59 XML-ERROR: nonexist-ns name ;
60
61 ! this should give which tag was unopened
62 XML-ERROR: unopened ;
63
64 XML-ERROR: not-yes/no text ;
65
66 ! this should actually print the names
67 XML-ERROR: extra-attrs attrs ;
68
69 XML-ERROR: bad-version num ;
70
71 ERROR: notags ;
72
73 XML-ERROR: bad-prolog prolog ;
74
75 XML-ERROR: capitalized-prolog name ;
76
77 XML-ERROR: versionless-prolog ;
78
79 XML-ERROR: bad-directive dir ;
80
81 XML-ERROR: bad-decl ;
82
83 XML-ERROR: bad-external-id ;
84
85 XML-ERROR: misplaced-directive dir ;
86
87 XML-ERROR: bad-name name ;
88
89 XML-ERROR: unclosed-quote ;
90
91 XML-ERROR: quoteless-attr ;
92
93 XML-ERROR: attr-w/< ;
94
95 XML-ERROR: text-w/]]> ;
96
97 XML-ERROR: duplicate-attr key values ;
98
99 XML-ERROR: bad-cdata ;
100
101 XML-ERROR: not-enough-characters ;
102
103 XML-ERROR: bad-doctype read-contents ;
104
105 XML-ERROR: bad-encoding encoding ;
106
107 UNION: xml-error
108     unclosed multitags notags pre/post-content generated-xml-error ;
109
110 { "xml.errors" "debugger" } "xml.errors.debugger" require-when