1 /* SGML Parser definitions SGML.h
2 ** =======================
4 ** The SGML parser is a state machine. It is called for every character
5 ** of the input stream. The DTD data structure contains pointers
6 ** to functions which are called to implement the actual effect of the
7 ** text read. When these functions are called, the attribute structures
8 ** pointed to by the DTD are valid, and the function is passed
9 ** a pointer to the curent tag structure, and an
10 ** "element stack" which represents the state of nesting within SGML
13 /* (c) Copyright CERN 1991 - See Copyright.html
20 char * name; /* The (constant) name of the attribute */
21 BOOL present; /* Was attribute specified for this tag? */
22 char * value; /* Malloced. Valid only if present is YES. */
26 /* A tag structure describes an SGML element.
27 ** -----------------------------------------
29 ** If the tag has an end tag, then treat and end must be non-zero.
30 ** If the tag does not, they must be zero.
32 ** name is the string which comes after the tag opener "<".
34 ** attributes points to a zero-terminated array
35 ** of attribute structures filled in by the parser.
37 ** style is a pointer left for use by oter modules (typically
38 ** for storing the style used with this element)
40 ** litteral determines how the SGML engine parses the charaters
41 ** within the element. If set, tag openers are ignored
42 ** except for that which opens a matching closing tag.
44 ** begin is called when the tag has been parsed, and the
45 ** attribute values set. The element pointer points
46 ** to the top of the new element stack.
48 ** treat is a pointer to a function which is called for
49 ** each text character within the element.
51 ** end is called when the end tag has been parsed.
52 ** The element pointer points to the top of the
55 typedef struct _tag HTTag;
56 typedef struct _HTElement HTElement;
58 char * name; /* The name of the tag */
59 attr * attributes; /* The list of acceptable attributes */
60 void * style; /* Not used by the SGML engine */
61 BOOL litteral; /* End only on end tag @@ */
62 void (*begin) PARAMS((HTTag * t, HTElement * e)); /* Action on begin tag */
63 void (*treat) PARAMS((char c)); /* Action when character is parsed */
64 void (*end) PARAMS((HTTag * t, HTElement * e)); /* Action on </tag> or 0 if empty */
67 /* Stack of previous tags:
69 ** This allows us to return down the stack reselcting styles.
70 ** As we return, attribute values will be garbage in general.
73 HTElement * next; /* Previously nested element or 0 */
74 HTTag * tag; /* The tag at this level */
75 void * info; /* Free to be used by caller only */
79 typedef struct _entity {
81 char * representation;
91 /* Initialise the SGML parser
94 ** dtd must point to a DTD structure as defined above
96 ** The default tag starter has been processed.
99 extern void SGML_begin PARAMS((SGML_dtd * dtd));
102 /* Crank the SGML parser
105 ** dtd must point to a DTD structure as defined above.
106 ** SGML_begin must have been called on it.
108 ** c is the next character of the input stream
111 extern void SGML_character PARAMS((SGML_dtd * dtd, char c));
114 /* Finish the SGML parser
117 ** dtd must point to a DTD structure as defined above
118 ** SGML_begin must have been called on it.
120 ** The document will be completed.
121 ** SGML_begin must be called again before any
122 ** more parsing is done.
125 extern void SGML_end PARAMS((SGML_dtd * dtd));