2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: parser.h /main/3 1995/11/08 09:41:12 rswiston $ */
25 Copyright 1986 Tandem Computers Incorporated.
26 This product and information is proprietary of Tandem Computers Incorporated.
27 Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
30 /* Parser.h allocates global variables for PARSER */
34 #define M_PARINIT(a) = a
36 #define M_PAREXTERN extern
42 /* Stack of open entities and line number in each external file */
43 #define M_ENTLVL 16 /* Maximum number of open entities */
44 M_PAREXTERN M_ENTITY *m_opene[M_ENTLVL] ;
45 M_PAREXTERN int m_eopencnt M_PARINIT(0) ;
46 M_PAREXTERN void *m_sysent[M_ENTLVL + 1] ;
48 M_PAREXTERN int m_line[M_ENTLVL + 1] M_PARINIT({M_FIRSTLINE}) ;
49 M_PAREXTERN int m_sysecnt M_PARINIT(0) ;
51 /* Possible states of a line -- no SGML characters yet processed, SGML
52 characters processed but no data character or contextual end tag,
53 data character or contextual end tag (i.e., end tag of a proper
54 subelement) has occurred. Note that linestat is stacked with each
55 element. If an element contains a line that
56 * is neither its first nor last line
57 * contains data characters within an included element
58 the status of the line should be M_SOMETHING not M_DCORCET because the data
59 characters belong to the inner element rather than the outer one.
61 Also note that "M_DCORCET" originally stood for "data character or contextual
62 end tag" when the Standard used the term "contextual element" to mean
63 an element allowed by a model rather than an inclusion and when
64 the rules for ignoring RE's referred to the occurrence of end tags of
65 such elements rather than the entire elements. Now the acronym can be
66 interpreted as "data character or contextual element".
72 /* Definitions for parse stack. The primary data structure of PARSER
73 is a stack containing one entry for each open element. Each entry
74 on the stack is described in an m_parse structure. Entries for
75 element's whose content is defined by a content model have a
76 pointer to a stack of open FSAs. These FSA stacks do not describe
77 the actual automata (which are coded in the data structures
78 generated by BUILD, but rather the current state in the active
79 automata. An element's FSA stack will have one entry for the
80 content model and an additional entry for each active and-group.
83 typedef struct m_parse M_PARSE ;
84 typedef struct m_openfsa M_OPENFSA ;
85 typedef struct m_andlist M_ANDLIST ;
88 /* Pointer to preceding entry on stack */
91 /* Identifier of element this entry represents */
94 /* Pointer to table of parameter pointers for this instance of this
98 /* Pointer to stack of open FSAs for this element */
101 /* For RCDATA elements to indicate the nesting level
102 of entities when the element opened, since net and etago
103 delimiters are not recognized except in the same entity
104 as the element began. */
107 /* TRUE iff the element's start-tag ended with a NET so that a NET
108 is expected to end the element */
111 /* Has a Record End occurred in the element's content? */
114 /* Flag that indicates whether the element is contextual, i.e.,
115 whether it occurred because it was allowed in context by a
116 content model, or it was allowed by an inclusion exception or
117 occurred by error. (The term "contextual subelement" was used
118 in the Draft International Standard in the same sense as
119 "proper subelement" in the International Standard.) */
122 /* Whether character data is currently being processed. */
125 /* Line status. Indicates whether anything has occurred after
126 the start-tag or most recent Record Start in this element */
129 /* Flag indicating whether or not a Record End (carriage return)
130 has been scanned and is being held to see if there is more
131 content in the element. If there is, the RE will be processed
132 as a data character, otherwise it will be discarded. */
135 /* Pointer to the element's short reference map. The value is NULL
136 if there is no map. */
139 /* Index in actions for processing text characters encountered
140 in this element, and pointer to stack location where parameters
141 should be retrieved. */
145 /* Index in actions for processing processing instructions
146 encountered in this element, and pointer to stack location where
147 parameters should be retrieved. */
151 /* Index in actions for processing start- and end-strings
152 encountered in this element, and pointer to stack location where
153 parameters should be retrieved. */
157 /* Pointer to name of input file in which the current element
158 began (NULL if primary input file). */
161 /* Line number where the current element began. */
164 /* Interface-defined pointer stored on the stack */
169 /* Pointer to preceding entry on FSA stack */
172 /* Current state in this FSA */
175 /* Identifier of set of and-groups being processed and pointer to list of
176 and-groups that have occurred within this set. */
177 M_ANDGROUP andgroup ;
186 extern M_OPENFSA m_botfsa ;
188 /* Bottom marker of parse stack */
189 M_PAREXTERN M_PARSE m_stackbot
190 #if defined(M_PARDEF)
192 /* M_PARSE *oldtop ;*/ NULL,
193 /* M_ELEMENT element ;*/ M_NULLVAL,
194 /* M_WCHAR **param ;*/ NULL,
195 /* M_OPENFSA *fsastack ;*/ &m_botfsa,
196 /* int thisent ;*/ 0,
197 /* LOGICAL neednet ;*/ FALSE,
198 /* LOGICAL firstre ; */ FALSE,
199 /* LOGICAL contextual ;*/ TRUE,
200 /* LOGICAL intext ;*/ FALSE,
201 /* int linestat ;*/ M_NOTHING,
202 /* LOGICAL holdre ;*/ FALSE,
203 /* int *map ;*/ NULL,
205 /* M_PARSE *cdparam ;*/ &m_stackbot,
207 /* M_PARSE *piparam ;*/ &m_stackbot,
208 /* int stccase ;*/ 1,
209 /* M_PARSE *stparam ;*/ &m_stackbot,
210 /* M_WCHAR *file ;*/ NULL,
211 /* int line ;*/ M_FIRSTLINE,
212 /* void *ifdata ;*/ NULL,
217 M_PAREXTERN M_OPENFSA m_botfsa
218 #if defined(M_PARDEF)
220 /* M_OPENFSA *oldtop ;*/ NULL,
221 /* M_STATE current ;*/ 1,
222 /* M_ANDGROUP andgroup ;*/ M_NULLVAL,
223 /* M_ANDGROUP *usedand ;*/ NULL,
228 /* Index of current top of parse stack */
229 M_PAREXTERN M_PARSE *m_stacktop M_PARINIT(&m_stackbot) ;
231 /* Pointer to stack location where parameters for current code
232 segment are defined. Used for inherited code segments (text-code,
233 pi-code, string-code) */
234 M_PAREXTERN M_PARSE *m_stackpar ;
236 /* Type of characters */
237 typedef char M_HOLDTYPE ;
239 #if defined(M_PARDEF)
240 #include "chartype.h"
242 extern M_CHARTYPE m_ctarray[M_CHARSETLEN] ;
245 /* Indicates a start tag is allowed by an inclusion exception */
246 #define M_NONCONTEXTUAL 2
248 /* Character used to delimit parameter names in start and end strings
249 entered as data to ELTDEF */
250 #define M_ESCAPECHAR '@'
252 /* Pointer to name of element */
253 #define m_nameofelt(x) &m_ename[m_element[x - 1].enptr]
255 /* Status of characters as read from input stream */
259 #define M_ENTNORMAL 3
261 /* State transition network generated by CONTEXT */
264 /* Maximum length of a sequence of blanks in a short reference delimiter */
265 #define M_BSEQLEN 100
267 /* #defines used in recognition of short reference delimiters */
268 #if defined(M_PARDEF)
269 #define M_HOLDSIZ M_MAXSR + M_BSEQLEN * M_MAXSEQ + 1
279 /* Number of allowable tokens to display after a syntax error */
282 /* Status of T option output */
283 #define M_TOPTSTARTTAG 0
284 #define M_WHITESPACE 1
287 /* Maximum length of processing instruction (not in a PI entity) */
290 /* Storage for a name token just read by the scanner; and for a name read
291 while parsing parameters */
292 M_PAREXTERN M_WCHAR m_name[M_NAMELEN + 1] ;
293 M_PAREXTERN M_WCHAR m_saveatt[M_NAMELEN + 1] ;
295 /* M_curcon is current state of FSA that controls parser; m_prevcon is the
296 value of m_curcon before last character was scanned; m_token is the token
297 type returned by last call to scanner; and
298 m_scanval is index of element name just read within tag delimiters */
299 M_PAREXTERN int m_curcon M_PARINIT(PROLOG) ;
300 M_PAREXTERN int m_prevcon ;
301 M_PAREXTERN int m_token ;
302 M_PAREXTERN int m_scanval ;
304 char *user_defined_entities M_PARINIT("USER-DEFINED-ENTITIES");
306 /* Declarations for tentative list of omitted tags when checking for tag
308 typedef struct m_min M_MIN ;
313 M_PAREXTERN M_MIN *m_minstart ;
314 M_PAREXTERN M_MIN *m_minend ;
315 M_PAREXTERN M_MIN **m_nextms ;
316 M_PAREXTERN M_MIN **m_nextme ;
318 /* Count of the number of open elements expecting to be terminated with
320 M_PAREXTERN int m_netlevel M_PARINIT(0) ;
322 /* Count of errors that have occurred */
323 M_PAREXTERN int m_errcnt M_PARINIT(0) ;
325 M_PAREXTERN int m_errlim M_PARINIT(M_ERRLIM) ;
326 M_PAREXTERN int m_expcount ;
327 M_PAREXTERN LOGICAL m_errexit M_PARINIT(FALSE) ;
329 /* Flag to indicate whether processing of the text has begun */
330 M_PAREXTERN LOGICAL m_start M_PARINIT(FALSE) ;
332 /* Flag indicates whether current start tag is terminated by End-tag
333 indicator or by tag-close delimiter (or start of another tag) */
334 M_PAREXTERN LOGICAL m_scannet ;
336 /* Storage for literals */
337 M_PAREXTERN M_WCHAR m_literal[M_LITLEN + 1] ;
339 /* Buffer for sequence of white space that has been read before it is
340 determined whether or not the white space is significant */
341 #define M_WSPACELEN 100
342 M_PAREXTERN int m_wspace[M_WSPACELEN] ;
343 M_PAREXTERN int m_wscount M_PARINIT(0) ;
344 M_PAREXTERN int m_maxws M_PARINIT(0) ;
345 M_PAREXTERN int m_wsused ;
347 /* Temporary pointers to parameter values. Used while scanning start tag
348 before element is placed on parse stack.*/
353 #if defined(M_PARDEF)
354 M_MAXPAR ? M_MAXPAR : 1
358 /* Index of a particular parameter within the parameter list for a given
360 M_PAREXTERN int m_psave ;
361 /* Index of a particular parameter within the list of all parameters for all
363 M_PAREXTERN int m_ppsave ;
365 /* Index of element of tag just scanned; may be result of short tag
367 M_PAREXTERN M_ELEMENT m_scanel ;
369 /* Read-ahead buffer and number of characters currently in that buffer */
370 #define M_SAVECHAR 500
371 M_PAREXTERN int m_savechar[M_SAVECHAR] ;
372 M_PAREXTERN M_WCHAR m_savedchar[M_SAVECHAR] ;
373 M_PAREXTERN M_WCHAR m_oldlinestat[M_SAVECHAR] ;
374 M_PAREXTERN M_WCHAR m_oldatrs[M_SAVECHAR] ;
375 M_PAREXTERN int m_sourcefile[M_SAVECHAR] ;
376 M_PAREXTERN M_WCHAR m_atrs M_PARINIT(TRUE) ;
377 M_PAREXTERN int m_oldlsindex M_PARINIT(M_SAVECHAR - 1) ;
378 M_PAREXTERN int m_toundo M_PARINIT(0) ;
379 M_PAREXTERN int m_maxundo M_PARINIT(0) ;
380 #define M_LINELENGTH 80
381 M_PAREXTERN int m_saveline[M_LINELENGTH][M_ENTLVL + 1] ;
382 M_PAREXTERN int m_svlncnt[M_ENTLVL + 1] M_PARINIT({0}) ;
383 M_PAREXTERN LOGICAL m_svlnwrap[M_ENTLVL + 1] M_PARINIT({FALSE}) ;
385 /* Arrays used for short references */
386 M_PAREXTERN int m_hold[M_HOLDSIZ] ;
387 M_PAREXTERN M_HOLDTYPE m_dhold[M_HOLDSIZ] ;
388 M_PAREXTERN int m_delim[M_HOLDSIZ] ;
389 M_PAREXTERN char m_srefchartype[M_HOLDSIZ] ;
390 M_PAREXTERN int m_current[M_HOLDSIZ] ;
393 A -- Trace of calls to m_malloc() and m_free()
395 C -- Trace of calls to m_getachar(), putachar()
396 D -- Trace of encountered data characters
397 E -- Don't report duplicate entity declarations
400 H -- M_malloc and m_free check for valid heap
404 L -- Don't limit number of possible tokens displayed by expecting()
405 M -- Determine start-tag minimization strictly according to the Standard
415 W -- Missing tagc not considered an error
421 M_PAREXTERN LOGICAL m_malftrace M_PARINIT(FALSE) ;
422 M_PAREXTERN LOGICAL m_chtrace M_PARINIT(FALSE) ;
423 M_PAREXTERN LOGICAL m_cdtrace M_PARINIT(FALSE) ;
424 M_PAREXTERN LOGICAL m_entdupchk M_PARINIT(TRUE) ;
425 M_PAREXTERN LOGICAL m_heapchk M_PARINIT(FALSE) ;
426 M_PAREXTERN LOGICAL m_explimit M_PARINIT(TRUE) ;
427 M_PAREXTERN LOGICAL m_conform M_PARINIT(FALSE) ;
428 M_PAREXTERN LOGICAL m_scantrace M_PARINIT(FALSE) ;
429 M_PAREXTERN LOGICAL m_tagtrace M_PARINIT(FALSE) ;
430 M_PAREXTERN LOGICAL m_wholetag M_PARINIT(FALSE) ;
431 M_PAREXTERN int m_toptstat ;
433 /* Flag that indicates when unexpected content detected after document
434 appears to be complete */
435 M_PAREXTERN LOGICAL m_aftereod M_PARINIT(FALSE) ;
437 /* Save standard C main program arguments */
438 M_PAREXTERN int m_argc ;
439 M_PAREXTERN char **m_argv ;
441 /* PARSER output file */
442 M_PAREXTERN FILE *m_outfile M_PARINIT(stdout) ;
443 M_PAREXTERN FILE *m_errfile M_PARINIT(stdout) ;
445 /* Save processing instruction */
446 M_PAREXTERN M_WCHAR m_pi[M_PILEN + 1] ;
447 M_PAREXTERN int m_pilen M_PARINIT(0) ;
449 /* Entity being defined */
450 M_PAREXTERN M_ENTITY *m_entity ;
451 M_PAREXTERN int m_entclen ;
452 M_PAREXTERN M_WCHAR m_entcontent[M_LITLEN + 1] ;
454 /* Largest positive integer */
455 #define M_BIGINT 0x7FFF
457 /* Include function prototypes */