1 /* Validating XML processor for src/xbt/graphxml.dtd.
3 * This program was generated with the FleXML XML processor generator.
4 * FleXML is Copyright (C) 1999-2005 Kristoffer Rose. All rights reserved.
5 * FleXML is Copyright (C) 2003-2006 Martin Quinson. All rights reserved.
6 * (Id: flexml.pl,v 1.62 2007/10/11 10:00:14 mquinson Exp).
8 * There are two, intertwined parts to this program, part A and part B.
13 * Some parts, here collectively called "Part A", are found in the
14 * FleXML package. They are Copyright (C) 1999-2005 Kristoffer Rose
15 * and Copyright (C) 2003-2006 Martin Quinson. All rights reserved.
17 * You can redistribute, use, perform, display and/or modify "Part A"
18 * provided the following two conditions hold:
20 * 1. The program is distributed WITHOUT ANY WARRANTY from the author of
21 * FleXML; without even the implied warranty of MERCHANTABILITY or
22 * FITNESS FOR A PARTICULAR PURPOSE.
24 * 2. The program distribution conditions do not in any way affect the
25 * distribution conditions of the FleXML system used to generate this
26 * file or any version of FleXML derived from that system.
28 * Notice that these are explicit rights granted to you for files
29 * generated by the FleXML system. For your rights in connection with
30 * the FleXML system itself please consult the GNU General Public License.
35 * The other parts, here collectively called "Part B", and which came
36 * from the DTD used by FleXML to generate this program, can be
37 * distributed (or not, as the case may be) under the terms of whoever
38 * wrote them, provided these terms respect and obey the two conditions
39 * above under the heading "Part A".
41 * The author of and contributors to FleXML specifically disclaim
42 * any copyright interest in "Part B", unless "Part B" was written
43 * by the author of or contributors to FleXML.
49 /* Version strings. */
50 const char rcs_graphxml_flexml_skeleton[] =
51 "$" "Id: skel,v 1.40 2007/10/11 09:57:24 mquinson Exp $";
52 const char rcs_graphxml_flexml[] =
53 "$" "Id: flexml.pl,v 1.62 2007/10/11 10:00:14 mquinson Exp $";
56 #include <stdlib.h> /* for realloc() -- needed here when using flex 2.5.4 */
63 #if defined(_XBT_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__TOS_WIN__)
64 # ifndef __STRICT_ANSI__
72 #ifndef FLEXML_INDEXSTACKSIZE
73 #define FLEXML_INDEXSTACKSIZE 1000
76 /* Generated definitions. */
77 #define FLEXML_yylineno
78 #ifndef FLEXML_BUFFERSTACKSIZE
79 #define FLEXML_BUFFERSTACKSIZE 1000000
81 #define FLEXML_NEED_BUFFERLIT
83 /* XML processor api. */
84 /* FleXML-provided data. */
85 int graphxml_pcdata_ix;
86 extern char *graphxml_bufferstack;
87 #define graphxml_pcdata (graphxml_bufferstack + graphxml_pcdata_ix)
88 AT_graphxml_node_name AX_graphxml_node_name;
89 #define A_graphxml_node_name (graphxml_bufferstack + AX_graphxml_node_name)
90 AT_graphxml_edge_source AX_graphxml_edge_source;
91 #define A_graphxml_edge_source (graphxml_bufferstack + AX_graphxml_edge_source)
92 AT_graphxml_node_position_y AX_graphxml_node_position_y;
93 #define A_graphxml_node_position_y (graphxml_bufferstack + AX_graphxml_node_position_y)
94 AT_graphxml_node_position_x AX_graphxml_node_position_x;
95 #define A_graphxml_node_position_x (graphxml_bufferstack + AX_graphxml_node_position_x)
96 AT_graphxml_edge_data AX_graphxml_edge_data;
97 #define A_graphxml_edge_data (graphxml_bufferstack + AX_graphxml_edge_data)
98 AT_graphxml_edge_target AX_graphxml_edge_target;
99 #define A_graphxml_edge_target (graphxml_bufferstack + AX_graphxml_edge_target)
100 AT_graphxml_graph_isDirected AX_graphxml_graph_isDirected;
101 #define A_graphxml_graph_isDirected AX_graphxml_graph_isDirected
102 AT_graphxml_node_label AX_graphxml_node_label;
103 #define A_graphxml_node_label (graphxml_bufferstack + AX_graphxml_node_label)
104 AT_graphxml_node_data AX_graphxml_node_data;
105 #define A_graphxml_node_data (graphxml_bufferstack + AX_graphxml_node_data)
106 AT_graphxml_edge_label AX_graphxml_edge_label;
107 #define A_graphxml_edge_label (graphxml_bufferstack + AX_graphxml_edge_label)
108 AT_graphxml_edge_length AX_graphxml_edge_length;
109 #define A_graphxml_edge_length (graphxml_bufferstack + AX_graphxml_edge_length)
110 AT_graphxml_edge_name AX_graphxml_edge_name;
111 #define A_graphxml_edge_name (graphxml_bufferstack + AX_graphxml_edge_name)
115 # define ENTER(state) debug_enter(state,#state)
116 # define LEAVE debug_leave()
117 # define SET(state) debug_set(state,#state)
118 static void debug_enter(int, const char*);
119 static void debug_leave(void);
120 static void debug_set(int, const char*);
122 # define ENTER(state) (yy_push_state(state))
123 # define LEAVE (yy_pop_state())
124 # define SET(state) BEGIN(state)
127 /* Generic actions. */
128 #define SKIP /*skip*/
129 #define SUCCEED CLEANUP; return 0
131 #define FAIL return fail
132 static int fail(const char*, ...);
134 enum {flexml_max_err_msg_size = 512};
135 static char flexml_err_msg[flexml_max_err_msg_size];
136 const char * graphxml_parse_err_msg()
138 return flexml_err_msg;
140 static void reset_graphxml_parse_err_msg()
142 flexml_err_msg[0] = '\0';
146 static void cleanup(void);
147 #define CLEANUP cleanup()
149 /* Text buffer stack handling. */
150 char *graphxml_bufferstack = NULL;
151 static int blimit = FLEXML_BUFFERSTACKSIZE;
152 static int bnext = 1;
154 static int *indexstack = NULL;
155 static int ilimit = FLEXML_INDEXSTACKSIZE;
156 static int inext = 1;
158 #define BUFFERSET(P) (P = bnext)
159 #define BUFFERPUTC(C) (ck_blimit(), graphxml_bufferstack[bnext++] = (C))
160 #define BUFFERDONE (BUFFERPUTC('\0'))
162 #define BUFFERLITERAL(C, P) graphxml_bufferliteral(C, &(P), yytext)
164 /* after this is called, there are at least 2 slots left in the stack */
165 static int ck_blimit()
167 if (bnext >= blimit) {
168 blimit += FLEXML_BUFFERSTACKSIZE + 2;
170 char *temp = (char *) realloc(graphxml_bufferstack, blimit);
172 graphxml_bufferstack = temp;
178 /* after this is called, there are at least 2 slots left in the stack */
179 static int ck_ilimit()
181 if (inext >= ilimit) {
182 ilimit += FLEXML_INDEXSTACKSIZE + 2;
184 int *temp = (int *) realloc(indexstack, ilimit);
192 #ifdef FLEXML_NEED_BUFFERLIT
193 static void graphxml_bufferliteral(char c, int* pp, const char* text)
195 const char *s = (c ? strchr(text,c) : text-1), *e = strrchr(text,c);
196 assert(s <= e); BUFFERSET(*pp);
198 if (isspace(*s) && c) { BUFFERPUTC(' '); while (isspace(*s)) ++s; }
205 static void pushbuffer(int p)
208 indexstack[inext++] = p;
209 indexstack[inext++] = bnext;
212 static int popbuffer(void)
215 bnext = indexstack[--inext];
216 return indexstack[--inext];
219 /* General internal entities are `unput' back onto the input stream... */
220 #define ENTITYTEXT(T) \
221 { char *s = (T), *e = s+strlen(s);\
222 while (--e >= s) { unput(*e); }}
227 /* Flex standard options. */
229 %option noyy_top_state
235 /* Flex user-requested options. */
239 /* XML character classes (currently restricted to ASCII). */
241 /* "Common syntactic structures." */
245 /* "Names and Tokens." */
246 NameChar [A-Za-z0-9.:_-]
247 Name [A-Za-z_:]{NameChar}*
248 Names {Name}({S}{Name})*
249 Nmtoken ({NameChar})+
250 Nmtokens {Nmtoken}({S}{Nmtoken})*
253 VersionNum [a-zA-Z0-9_.:-]+
255 Literal \'[^'']*\'|\"[^""]*\"
257 /* Parser states (flex `exclusive start conditions'):
259 * PROLOG the XML prolog of the document before <?xml...>
260 * DOCTYPE the XML prolog of the document after <?xml...>
261 * EPILOG after the root element
262 * INCOMMENT inside an XML comment <!--....-->
263 * INPI inside an XML PI <?...?>
264 * VALUE1 inside a '...'-delimited literal
265 * VALUE2 inside a "..."-delimited literal
266 * CDATA inside a <![CDATA[...] ]> section.
267 * ROOT_<tag> expect root element <tag>
268 * AL_<tag> inside the attribute list for <tag>
269 * IN_<tag> inside a <tag> with element contents (ready for end tag)
270 * IMPOSSIBLE dummy to permit disabling rules; must be last
272 %x PROLOG DOCTYPE EPILOG INCOMMENT INPI VALUE1 VALUE2 CDATA
273 %x ROOT_graphxml_graph AL_graphxml_graph S_graphxml_graph S_graphxml_graph_1 S_graphxml_graph_2 S_graphxml_graph_3 S_graphxml_graph_4 S_graphxml_graph_5 E_graphxml_graph
274 %x ROOT_graphxml_node AL_graphxml_node E_graphxml_node
275 %x ROOT_graphxml_edge AL_graphxml_edge E_graphxml_edge
280 const char* *graphxml_statenames=NULL;
285 /* Bypass Flex's default INITIAL state and begin by parsing the XML prolog. */
287 reset_graphxml_parse_err_msg();
288 graphxml_bufferstack = (char *) malloc(FLEXML_BUFFERSTACKSIZE);
289 assert(graphxml_bufferstack);
293 for (i = 0; i < blimit; i++) {
294 graphxml_bufferstack[i] = '\377';
298 graphxml_bufferstack[0] = '\0';
299 indexstack = (int *) malloc(FLEXML_INDEXSTACKSIZE * sizeof(int));
305 graphxml_bufferliteral('\0', &bnext, "-1.0");
306 graphxml_bufferliteral('\0', &bnext, "-1.0");
307 graphxml_bufferliteral('\0', &bnext, "-1.0");
308 if(!graphxml_statenames) {graphxml_statenames= (const char **)calloc(IMPOSSIBLE,sizeof(char*));
309 graphxml_statenames[PROLOG] = NULL;
310 graphxml_statenames[DOCTYPE] = NULL;
311 graphxml_statenames[EPILOG] = NULL;
312 graphxml_statenames[INCOMMENT] = NULL;
313 graphxml_statenames[INPI] = NULL;
314 graphxml_statenames[VALUE1] = NULL;
315 graphxml_statenames[VALUE2] = NULL;
316 graphxml_statenames[CDATA] = NULL;
317 graphxml_statenames[ROOT_graphxml_graph] = NULL;
318 graphxml_statenames[AL_graphxml_graph] = NULL;
319 graphxml_statenames[S_graphxml_graph] = "graph";
320 graphxml_statenames[S_graphxml_graph_1] = "graph";
321 graphxml_statenames[S_graphxml_graph_2] = "graph";
322 graphxml_statenames[S_graphxml_graph_3] = "graph";
323 graphxml_statenames[S_graphxml_graph_4] = "graph";
324 graphxml_statenames[S_graphxml_graph_5] = "graph";
325 graphxml_statenames[E_graphxml_graph] = "graph";
326 graphxml_statenames[ROOT_graphxml_node] = NULL;
327 graphxml_statenames[AL_graphxml_node] = NULL;
328 graphxml_statenames[E_graphxml_node] = "node";
329 graphxml_statenames[ROOT_graphxml_edge] = NULL;
330 graphxml_statenames[AL_graphxml_edge] = NULL;
331 graphxml_statenames[E_graphxml_edge] = "edge";
334 /* COMMENTS and PIs: handled uniformly for efficiency. */
336 <ROOT_graphxml_graph,AL_graphxml_graph,S_graphxml_graph,S_graphxml_graph_1,S_graphxml_graph_2,S_graphxml_graph_3,S_graphxml_graph_4,S_graphxml_graph_5,E_graphxml_graph,ROOT_graphxml_node,AL_graphxml_node,E_graphxml_node,ROOT_graphxml_edge,AL_graphxml_edge,E_graphxml_edge,PROLOG,DOCTYPE,EPILOG>{
337 "<!--" ENTER(INCOMMENT);
345 <<EOF>> FAIL("EOF in comment.");
351 <<EOF>> FAIL("EOF in PI (processing instruction).");
354 /* SPACES: skipped uniformly */
356 <ROOT_graphxml_graph,AL_graphxml_graph,S_graphxml_graph,S_graphxml_graph_1,S_graphxml_graph_2,S_graphxml_graph_3,S_graphxml_graph_4,S_graphxml_graph_5,E_graphxml_graph,ROOT_graphxml_node,AL_graphxml_node,E_graphxml_node,ROOT_graphxml_edge,AL_graphxml_edge,E_graphxml_edge,PROLOG,DOCTYPE,EPILOG>{S} SKIP;
358 /* PROLOG: determine root element and process it. */
361 "<?xml"({S}version{Eq}(\'{VersionNum}\'|\"{VersionNum}\"))?({S}encoding{Eq}(\'[^']*\'|\"[^"]*\"))?"?>" SET(DOCTYPE);
362 "<?xml"[^>]*">" FAIL("Bad declaration %s.",yytext);
366 "<!DOCTYPE"{S}"edge"{S}SYSTEM{S}("'graphxml.dtd'"|"\"graphxml.dtd\""){s}">" SET(ROOT_graphxml_edge);
367 "<!DOCTYPE"{S}"node"{S}SYSTEM{S}("'graphxml.dtd'"|"\"graphxml.dtd\""){s}">" SET(ROOT_graphxml_node);
368 "<!DOCTYPE"{S}"graph"{S}SYSTEM{S}("'graphxml.dtd'"|"\"graphxml.dtd\""){s}">" SET(ROOT_graphxml_graph);
369 "<!"[^>-][^>]*">" FAIL("Bad declaration %s.",yytext);
370 . FAIL("Unexpected character `%c' in prolog.", yytext[0]);
371 <<EOF>> FAIL("EOF in prolog.");
374 /* RULES DERIVED FROM DTD. */
376 /* <!-- Small DTD for xbt graphs. --> */
378 /* isDirected (true|false) "true"
381 <S_graphxml_graph,S_graphxml_graph_3,S_graphxml_graph_1,S_graphxml_graph_5,S_graphxml_graph_2,S_graphxml_graph_4,E_graphxml_graph>"<graph"{s} FAIL("Starting tag <graph> is not allowed here.");
383 <ROOT_graphxml_graph>"<graph"{s} {
384 AX_graphxml_graph_isDirected = A_graphxml_graph_isDirected_true;
385 ENTER(AL_graphxml_graph); pushbuffer(0);
389 "isDirected"{Eq}"'true'" |
390 "isDirected"{Eq}"\"true\"" A_graphxml_graph_isDirected = A_graphxml_graph_isDirected_true;
391 "isDirected"{Eq}"'false'" |
392 "isDirected"{Eq}"\"false\"" A_graphxml_graph_isDirected = A_graphxml_graph_isDirected_false;
395 LEAVE; STag_graphxml_graph();graphxml_pcdata_ix = 0; ENTER(S_graphxml_graph);
398 LEAVE; STag_graphxml_graph(); graphxml_pcdata_ix = 0; ETag_graphxml_graph(); popbuffer(); /* attribute */
400 case ROOT_graphxml_graph: SET(EPILOG); break;
403 . FAIL("Unexpected character `%c' in attribute list of graph element.", yytext[0]);
404 {Name} FAIL("Bad attribute `%s' in `graph' element start tag.",yytext);
405 <<EOF>> FAIL("EOF in attribute list of `graph' element.");
408 <S_graphxml_graph_1,E_graphxml_graph,S_graphxml_graph_3,S_graphxml_graph_5,S_graphxml_graph>{
411 ETag_graphxml_graph();
412 popbuffer(); /* attribute */
414 case ROOT_graphxml_graph: SET(EPILOG); break;
417 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</graph>' expected.",yytext);
418 . FAIL("Unexpected character `%c': `</graph>' expected.",yytext[0]);
419 <<EOF>> FAIL("Premature EOF: `</graph>' expected.");
423 * name CDATA #REQUIRED
425 * position_x CDATA "-1.0"
426 * position_y CDATA "-1.0"
429 <S_graphxml_graph_1,S_graphxml_graph_5,S_graphxml_graph_4,E_graphxml_graph>"<node"{s} FAIL("Starting tag <node> is not allowed here.");
431 <ROOT_graphxml_node,S_graphxml_graph_2,S_graphxml_graph_3,S_graphxml_graph>"<node"{s} {
432 AX_graphxml_node_label = 0;
433 AX_graphxml_node_name = 0;
434 AX_graphxml_node_data = 0;
435 AX_graphxml_node_position_x = 1;
436 AX_graphxml_node_position_y = 6;
437 ENTER(AL_graphxml_node); pushbuffer(0);
441 "label"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_graphxml_node_label);
442 "label"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_graphxml_node_label);
444 "name"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_graphxml_node_name);
445 "name"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_graphxml_node_name);
447 "data"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_graphxml_node_data);
448 "data"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_graphxml_node_data);
450 "position_x"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_graphxml_node_position_x);
451 "position_x"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_graphxml_node_position_x);
453 "position_y"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_graphxml_node_position_y);
454 "position_y"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_graphxml_node_position_y);
457 if (!AX_graphxml_node_name) FAIL("Required attribute `name' not set for `node' element.");
458 LEAVE; STag_graphxml_node();graphxml_pcdata_ix = 0; ENTER(E_graphxml_node);
461 if (!AX_graphxml_node_name) FAIL("Required attribute `name' not set for `node' element.");
462 LEAVE; STag_graphxml_node(); graphxml_pcdata_ix = 0; ETag_graphxml_node(); popbuffer(); /* attribute */
464 case S_graphxml_graph_2: case S_graphxml_graph_3: case S_graphxml_graph: SET(S_graphxml_graph_3); break;
465 case ROOT_graphxml_node: SET(EPILOG); break;
468 . FAIL("Unexpected character `%c' in attribute list of node element.", yytext[0]);
469 {Name} FAIL("Bad attribute `%s' in `node' element start tag.",yytext);
470 <<EOF>> FAIL("EOF in attribute list of `node' element.");
476 ETag_graphxml_node();
477 popbuffer(); /* attribute */
479 case S_graphxml_graph_2: case S_graphxml_graph_3: case S_graphxml_graph: SET(S_graphxml_graph_3); break;
480 case ROOT_graphxml_node: SET(EPILOG); break;
483 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</node>' expected.",yytext);
484 . FAIL("Unexpected character `%c': `</node>' expected.",yytext[0]);
485 <<EOF>> FAIL("Premature EOF: `</node>' expected.");
489 * name CDATA #IMPLIED
490 * source CDATA #REQUIRED
491 * target CDATA #REQUIRED
492 * length CDATA "-1.0"
496 <E_graphxml_graph,S_graphxml_graph_2>"<edge"{s} FAIL("Starting tag <edge> is not allowed here.");
498 <ROOT_graphxml_edge,S_graphxml_graph_1,S_graphxml_graph_3,S_graphxml_graph_5,S_graphxml_graph_4,S_graphxml_graph>"<edge"{s} {
499 AX_graphxml_edge_label = 0;
500 AX_graphxml_edge_name = 0;
501 AX_graphxml_edge_source = 0;
502 AX_graphxml_edge_target = 0;
503 AX_graphxml_edge_length = 11;
504 AX_graphxml_edge_data = 0;
505 ENTER(AL_graphxml_edge); pushbuffer(0);
509 "label"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_graphxml_edge_label);
510 "label"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_graphxml_edge_label);
512 "name"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_graphxml_edge_name);
513 "name"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_graphxml_edge_name);
515 "source"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_graphxml_edge_source);
516 "source"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_graphxml_edge_source);
518 "target"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_graphxml_edge_target);
519 "target"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_graphxml_edge_target);
521 "length"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_graphxml_edge_length);
522 "length"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_graphxml_edge_length);
524 "data"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_graphxml_edge_data);
525 "data"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_graphxml_edge_data);
528 if (!AX_graphxml_edge_source) FAIL("Required attribute `source' not set for `edge' element.");
529 if (!AX_graphxml_edge_target) FAIL("Required attribute `target' not set for `edge' element.");
530 LEAVE; STag_graphxml_edge();graphxml_pcdata_ix = 0; ENTER(E_graphxml_edge);
533 if (!AX_graphxml_edge_source) FAIL("Required attribute `source' not set for `edge' element.");
534 if (!AX_graphxml_edge_target) FAIL("Required attribute `target' not set for `edge' element.");
535 LEAVE; STag_graphxml_edge(); graphxml_pcdata_ix = 0; ETag_graphxml_edge(); popbuffer(); /* attribute */
537 case S_graphxml_graph_1: case S_graphxml_graph_3: case S_graphxml_graph_5: case S_graphxml_graph_4: case S_graphxml_graph: SET(S_graphxml_graph_5); break;
538 case ROOT_graphxml_edge: SET(EPILOG); break;
541 . FAIL("Unexpected character `%c' in attribute list of edge element.", yytext[0]);
542 {Name} FAIL("Bad attribute `%s' in `edge' element start tag.",yytext);
543 <<EOF>> FAIL("EOF in attribute list of `edge' element.");
549 ETag_graphxml_edge();
550 popbuffer(); /* attribute */
552 case S_graphxml_graph_1: case S_graphxml_graph_3: case S_graphxml_graph_5: case S_graphxml_graph_4: case S_graphxml_graph: SET(S_graphxml_graph_5); break;
553 case ROOT_graphxml_edge: SET(EPILOG); break;
556 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</edge>' expected.",yytext);
557 . FAIL("Unexpected character `%c': `</edge>' expected.",yytext[0]);
558 <<EOF>> FAIL("Premature EOF: `</edge>' expected.");
561 /* EPILOG: after the root element. */
564 . {SET(PROLOG); yyless(0); CLEANUP; return -1;}
568 /* CHARACTER DATA. */
570 <IMPOSSIBLE,VALUE1,VALUE2>{
571 /* Non-defined standard entities... */
572 "&" BUFFERPUTC('&');
573 "<" BUFFERPUTC('<');
574 ">" BUFFERPUTC('>');
575 "'" BUFFERPUTC('\'');
576 """ BUFFERPUTC('"');
578 /* Character entities. */
579 "&#"[[:digit:]]+";" BUFFERPUTC((unsigned char)atoi(yytext+2));
580 "&#x"[[:xdigit:]]+";" BUFFERPUTC((unsigned char)strtol(yytext+3,NULL,16));
583 <IMPOSSIBLE,VALUE1,VALUE2,CDATA>{
587 "\n\r" BUFFERPUTC('\n');
591 "<![CDATA[" ENTER(CDATA);
592 "]""]>" FAIL("Unexpected `]""]>' in character data.");
596 \' BUFFERDONE; LEAVE;
597 <<EOF>> FAIL("EOF in literal (\"'\" expected).");
601 \" BUFFERDONE; LEAVE;
602 <<EOF>> FAIL("EOF in literal (`\"' expected).");
605 <IMPOSSIBLE,VALUE1,VALUE2>{
606 [^<&] BUFFERPUTC(yytext[0]);
607 [<&] FAIL("Spurious `%c' in character data.",yytext[0]);
612 /* "]""]" BUFFERPUTC(yytext[0]); BUFFERPUTC(yytext[1]); */
613 . BUFFERPUTC(yytext[0]);
614 <<EOF>> FAIL("EOF in CDATA section.");
617 /* Impossible rules to avoid warnings from flex(1). */
618 /* Ideally, this should be replaced by code in flexml.pl that
619 generates just the states not covered by other rules. */
621 .|[\n] FAIL("Syntax error on character `%c'.", yytext[0]);
626 /* Element context stack lookup. */
627 int graphxml_element_context(int i)
629 return (0<i && i<yy_start_stack_depth
630 ? yy_start_stack[yy_start_stack_ptr - i]
635 void print_yy_stack(char* fmt, ...)
637 int i = 0; va_list ap; va_start(ap, fmt);
638 vfprintf(stderr, fmt, ap);
639 if (graphxml_statenames) {
640 for (i=1; i<yy_start_stack_ptr; i++) {
641 fprintf(stderr, "%s/", graphxml_statenames[yy_start_stack[i] ]);
643 fprintf(stderr,"%s\n", graphxml_statenames[YY_START]);
648 void print_graphxml_bufferstack()
651 fputs("Buffer: ", stderr);
652 for (i = 0; i < blimit; i++) {
653 if ( graphxml_bufferstack[i] == '\377' ) break;
654 putc(graphxml_bufferstack[i], stderr);
659 static void debug_enter(int state, const char* statename) {
660 yy_push_state(state);
662 print_yy_stack("--ENTER(%s) : ",statename);
663 print_graphxml_bufferstack();
667 static void debug_leave(void) {
669 print_yy_stack("--LEAVE : ");
670 print_graphxml_bufferstack();
675 static void debug_set(int state, const char* statename) {
677 if (yy_flex_debug) print_yy_stack("--SET(%s) : ",statename);
682 static void cleanup(void)
684 if (graphxml_statenames) {
685 free(graphxml_statenames);
686 graphxml_statenames = NULL;
688 free(graphxml_bufferstack);
689 graphxml_bufferstack = NULL;
696 static int fail(const char* fmt, ...)
698 int chars_left, used;
699 va_list ap; va_start(ap, fmt);
700 #ifdef FLEXML_yylineno
701 used = sprintf(flexml_err_msg,
702 "Invalid XML (XML input line %d, state %d): ",
705 used = sprintf(flexml_err_msg,
706 "Invalid XML (state %d): ",
709 chars_left = flexml_max_err_msg_size - used - 1;
710 vsnprintf(flexml_err_msg + used, chars_left, fmt, ap);
713 #ifndef FLEXML_quiet_parser
714 /* print directly to sdterr */
715 fprintf(stderr, "%s\n", flexml_err_msg);
716 flexml_err_msg[0] = '\0';