config: Access OPT_MUST_SAVE in the real option, not alias.
[elinks/elinks-j605.git] / src / dom / sgml / parser.h
blob966bd40648696e0ead37ba7ec95f820110a61a8d
2 #ifndef EL_DOM_SGML_PARSER_H
3 #define EL_DOM_SGML_PARSER_H
5 #include "dom/node.h"
6 #include "dom/stack.h"
7 #include "dom/sgml/sgml.h"
8 #include "dom/scanner.h"
10 struct string;
11 struct uri;
13 enum sgml_parser_type {
14 /* The first one is a DOM tree builder. */
15 SGML_PARSER_TREE,
16 /* The second one will simply push nodes on the stack, not building a
17 * DOM tree. This interface is similar to that of SAX (Simple API for
18 * XML) where events are fired when nodes are entered and exited. It is
19 * useful when you are not actually interested in the DOM tree, but can
20 * do all processing in a stream-like manner, such as when highlighting
21 * HTML code. */
22 SGML_PARSER_STREAM,
25 struct sgml_parser_state {
26 /* Info about the properties of the node contained by state.
27 * This is only meaningful to element and attribute nodes. For
28 * unknown nodes it points to the common 'unknown node' info. */
29 struct sgml_node_info *info;
30 /* This is used by the DOM source renderer for highlighting the
31 * end-tag of an element. */
32 struct dom_scanner_token end_token;
35 struct sgml_parser {
36 enum sgml_parser_type type; /* Stream or tree */
38 struct sgml_info *info; /* Backend dependent info */
40 struct dom_string uri; /* The URI of the DOM document */
41 struct dom_node *root; /* The document root node */
43 struct dom_stack stack; /* A stack for tracking parsed nodes */
44 struct dom_stack parsing; /* Used for tracking parsing states */
47 struct sgml_parser *
48 init_sgml_parser(enum sgml_parser_type type, enum sgml_document_type doctype,
49 struct dom_string *uri);
51 void done_sgml_parser(struct sgml_parser *parser);
53 struct dom_node *parse_sgml(struct sgml_parser *parser, struct dom_string *buffer);
55 #endif