1 /* Validating XML processor for xbt/graphxml.dtd.
2 * Generated 2007/08/09 10:57:49.
4 * This program was generated with the FleXML XML processor generator.
5 * FleXML is Copyright (C) 1999-2005 Kristoffer Rose. All rights reserved.
6 * FleXML is Copyright (C) 2003-2006 Martin Quinson. All rights reserved.
7 * (Id: flexml.pl,v 1.61 2006/09/13 16:34:33 wdowling Exp).
9 * There are two, intertwined parts to this program, part A and part B.
14 * Some parts, here collectively called "Part A", are found in the
15 * FleXML package. They are Copyright (C) 1999-2005 Kristoffer Rose
16 * and Copyright (C) 2003-2006 Martin Quinson. All rights reserved.
18 * You can redistribute, use, perform, display and/or modify "Part A"
19 * provided the following two conditions hold:
21 * 1. The program is distributed WITHOUT ANY WARRANTY from the author of
22 * FleXML; without even the implied warranty of MERCHANTABILITY or
23 * FITNESS FOR A PARTICULAR PURPOSE.
25 * 2. The program distribution conditions do not in any way affect the
26 * distribution conditions of the FleXML system used to generate this
27 * file or any version of FleXML derived from that system.
29 * Notice that these are explicit rights granted to you for files
30 * generated by the FleXML system. For your rights in connection with
31 * the FleXML system itself please consult the GNU General Public License.
36 * The other parts, here collectively called "Part B", and which came
37 * from the DTD used by FleXML to generate this program, can be
38 * distributed (or not, as the case may be) under the terms of whoever
39 * wrote them, provided these terms respect and obey the two conditions
40 * above under the heading "Part A".
42 * The author of and contributors to FleXML specifically disclaim
43 * any copyright interest in "Part B", unless "Part B" was written
44 * by the author of or contributors to FleXML.
50 /* Version strings. */
51 const char rcs_graphxml_flexml_skeleton[] =
52 "$" "Id: skel,v 1.38 2006/09/12 18:05:45 wdowling Exp $";
53 const char rcs_graphxml_flexml[] =
54 "$" "Id: flexml.pl,v 1.61 2006/09/13 16:34:33 wdowling Exp $";
64 #ifndef FLEXML_INDEXSTACKSIZE
65 #define FLEXML_INDEXSTACKSIZE 1000
68 /* Generated definitions. */
69 #define FLEXML_yylineno
70 #ifndef FLEXML_BUFFERSTACKSIZE
71 #define FLEXML_BUFFERSTACKSIZE 1000000
73 #define FLEXML_NEED_BUFFERLIT
75 /* XML processor api. */
76 /* FleXML-provided data. */
77 int graphxml_pcdata_ix;
78 extern char *graphxml_bufferstack;
79 #define graphxml_pcdata (graphxml_bufferstack + graphxml_pcdata_ix)
80 AT_graphxml_node_name AX_graphxml_node_name;
81 #define A_graphxml_node_name (graphxml_bufferstack + AX_graphxml_node_name)
82 AT_graphxml_edge_source AX_graphxml_edge_source;
83 #define A_graphxml_edge_source (graphxml_bufferstack + AX_graphxml_edge_source)
84 AT_graphxml_node_position_y AX_graphxml_node_position_y;
85 #define A_graphxml_node_position_y (graphxml_bufferstack + AX_graphxml_node_position_y)
86 AT_graphxml_node_position_x AX_graphxml_node_position_x;
87 #define A_graphxml_node_position_x (graphxml_bufferstack + AX_graphxml_node_position_x)
88 AT_graphxml_edge_data AX_graphxml_edge_data;
89 #define A_graphxml_edge_data (graphxml_bufferstack + AX_graphxml_edge_data)
90 AT_graphxml_edge_target AX_graphxml_edge_target;
91 #define A_graphxml_edge_target (graphxml_bufferstack + AX_graphxml_edge_target)
92 AT_graphxml_graph_isDirected AX_graphxml_graph_isDirected;
93 #define A_graphxml_graph_isDirected AX_graphxml_graph_isDirected
94 AT_graphxml_node_label AX_graphxml_node_label;
95 #define A_graphxml_node_label (graphxml_bufferstack + AX_graphxml_node_label)
96 AT_graphxml_node_data AX_graphxml_node_data;
97 #define A_graphxml_node_data (graphxml_bufferstack + AX_graphxml_node_data)
98 AT_graphxml_edge_label AX_graphxml_edge_label;
99 #define A_graphxml_edge_label (graphxml_bufferstack + AX_graphxml_edge_label)
100 AT_graphxml_edge_length AX_graphxml_edge_length;
101 #define A_graphxml_edge_length (graphxml_bufferstack + AX_graphxml_edge_length)
102 AT_graphxml_edge_name AX_graphxml_edge_name;
103 #define A_graphxml_edge_name (graphxml_bufferstack + AX_graphxml_edge_name)
107 # define ENTER(state) debug_enter(state,#state)
108 # define LEAVE debug_leave()
109 # define SET(state) debug_set(state,#state)
110 static void debug_enter(int, const char*);
111 static void debug_leave(void);
112 static void debug_set(int, const char*);
114 # define ENTER(state) (yy_push_state(state))
115 # define LEAVE (yy_pop_state())
116 # define SET(state) BEGIN(state)
119 /* Generic actions. */
120 #define SKIP /*skip*/
121 #define SUCCEED CLEANUP; return 0
123 #define FAIL return fail
124 static int fail(const char*, ...);
126 enum {flexml_max_err_msg_size = 512};
127 static char flexml_err_msg[flexml_max_err_msg_size];
128 const char * graphxml_parse_err_msg()
130 return flexml_err_msg;
132 static void reset_graphxml_parse_err_msg()
134 flexml_err_msg[0] = '\0';
138 static void cleanup(void);
139 #define CLEANUP cleanup()
141 /* Text buffer stack handling. */
142 char *graphxml_bufferstack = NULL;
143 static int blimit = FLEXML_BUFFERSTACKSIZE;
144 static int bnext = 1;
146 static int *indexstack = NULL;
147 static int ilimit = FLEXML_INDEXSTACKSIZE;
148 static int inext = 1;
150 #define BUFFERSET(P) (P = bnext)
151 #define BUFFERPUTC(C) (ck_blimit(), graphxml_bufferstack[bnext++] = (C))
152 #define BUFFERDONE (BUFFERPUTC('\0'))
154 #define BUFFERLITERAL(C, P) graphxml_bufferliteral(C, &(P), yytext)
156 /* after this is called, there are at least 2 slots left in the stack */
157 static int ck_blimit()
159 if (bnext >= blimit) {
160 blimit += FLEXML_BUFFERSTACKSIZE + 2;
162 char *temp = (char *) realloc(graphxml_bufferstack, blimit);
164 graphxml_bufferstack = temp;
170 /* after this is called, there are at least 2 slots left in the stack */
171 static int ck_ilimit()
173 if (inext >= ilimit) {
174 ilimit += FLEXML_INDEXSTACKSIZE + 2;
176 int *temp = (int *) realloc(indexstack, ilimit);
184 #ifdef FLEXML_NEED_BUFFERLIT
185 static void graphxml_bufferliteral(char c, int* pp, const char* text)
187 const char *s = (c ? strchr(text,c) : text-1), *e = strrchr(text,c);
188 assert(s <= e); BUFFERSET(*pp);
190 if (isspace(*s) && c) { BUFFERPUTC(' '); while (isspace(*s)) ++s; }
197 static void pushbuffer(int p)
200 indexstack[inext++] = p;
201 indexstack[inext++] = bnext;
204 static int popbuffer(void)
207 bnext = indexstack[--inext];
208 return indexstack[--inext];
211 /* General internal entities are `unput' back onto the input stream... */
212 #define ENTITYTEXT(T) \
213 { char *s = (T), *e = s+strlen(s);\
214 while (--e >= s) { unput(*e); }}
219 /* Flex standard options. */
221 %option noyy_top_state
227 /* Flex user-requested options. */
231 /* XML character classes (currently restricted to ASCII). */
233 /* "Common syntactic structures." */
237 /* "Names and Tokens." */
238 NameChar [A-Za-z0-9.:_-]
239 Name [A-Za-z_:]{NameChar}*
240 Names {Name}({S}{Name})*
241 Nmtoken ({NameChar})+
242 Nmtokens {Nmtoken}({S}{Nmtoken})*
245 VersionNum [a-zA-Z0-9_.:-]+
247 Literal \'[^'']*\'|\"[^""]*\"
249 /* Parser states (flex `exclusive start conditions'):
251 * PROLOG the XML prolog of the document before <?xml...>
252 * DOCTYPE the XML prolog of the document after <?xml...>
253 * EPILOG after the root element
254 * INCOMMENT inside an XML comment <!--....-->
255 * INPI inside an XML PI <?...?>
256 * VALUE1 inside a '...'-delimited literal
257 * VALUE2 inside a "..."-delimited literal
258 * CDATA inside a <![CDATA[...] ]> section.
259 * ROOT_<tag> expect root element <tag>
260 * AL_<tag> inside the attribute list for <tag>
261 * IN_<tag> inside a <tag> with element contents (ready for end tag)
262 * IMPOSSIBLE dummy to permit disabling rules; must be last
264 %x PROLOG DOCTYPE EPILOG INCOMMENT INPI VALUE1 VALUE2 CDATA
265 %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
266 %x ROOT_graphxml_node AL_graphxml_node E_graphxml_node
267 %x ROOT_graphxml_edge AL_graphxml_edge E_graphxml_edge
272 const char* *graphxml_statenames=NULL;
277 /* Bypass Flex's default INITIAL state and begin by parsing the XML prolog. */
279 reset_graphxml_parse_err_msg();
280 graphxml_bufferstack = (char *) malloc(FLEXML_BUFFERSTACKSIZE);
281 assert(graphxml_bufferstack);
285 for (i = 0; i < blimit; i++) {
286 graphxml_bufferstack[i] = '\377';
290 graphxml_bufferstack[0] = '\0';
291 indexstack = (int *) malloc(FLEXML_INDEXSTACKSIZE * sizeof(int));
297 graphxml_bufferliteral('\0', &bnext, "-1.0");
298 graphxml_bufferliteral('\0', &bnext, "-1.0");
299 graphxml_bufferliteral('\0', &bnext, "-1.0");
300 if(!graphxml_statenames) {graphxml_statenames= (const char **)calloc(IMPOSSIBLE,sizeof(char*));
301 graphxml_statenames[PROLOG] = NULL;
302 graphxml_statenames[DOCTYPE] = NULL;
303 graphxml_statenames[EPILOG] = NULL;
304 graphxml_statenames[INCOMMENT] = NULL;
305 graphxml_statenames[INPI] = NULL;
306 graphxml_statenames[VALUE1] = NULL;
307 graphxml_statenames[VALUE2] = NULL;
308 graphxml_statenames[CDATA] = NULL;
309 graphxml_statenames[ROOT_graphxml_graph] = NULL;
310 graphxml_statenames[AL_graphxml_graph] = NULL;
311 graphxml_statenames[S_graphxml_graph] = "graph";
312 graphxml_statenames[S_graphxml_graph_1] = "graph";
313 graphxml_statenames[S_graphxml_graph_2] = "graph";
314 graphxml_statenames[S_graphxml_graph_3] = "graph";
315 graphxml_statenames[S_graphxml_graph_4] = "graph";
316 graphxml_statenames[S_graphxml_graph_5] = "graph";
317 graphxml_statenames[E_graphxml_graph] = "graph";
318 graphxml_statenames[ROOT_graphxml_node] = NULL;
319 graphxml_statenames[AL_graphxml_node] = NULL;
320 graphxml_statenames[E_graphxml_node] = "node";
321 graphxml_statenames[ROOT_graphxml_edge] = NULL;
322 graphxml_statenames[AL_graphxml_edge] = NULL;
323 graphxml_statenames[E_graphxml_edge] = "edge";
326 /* COMMENTS and PIs: handled uniformly for efficiency. */
328 <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>{
329 "<!--" ENTER(INCOMMENT);
337 <<EOF>> FAIL("EOF in comment.");
343 <<EOF>> FAIL("EOF in PI (processing instruction).");
346 /* SPACES: skipped uniformly */
348 <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;
350 /* PROLOG: determine root element and process it. */
353 "<?xml"({S}version{Eq}(\'{VersionNum}\'|\"{VersionNum}\"))?({S}encoding{Eq}(\'[^']*\'|\"[^"]*\"))?"?>" SET(DOCTYPE);
354 "<?xml"[^>]*">" FAIL("Bad declaration %s.",yytext);
358 "<!DOCTYPE"{S}"edge"{S}SYSTEM{S}("'graphxml.dtd'"|"\"graphxml.dtd\""){s}">" SET(ROOT_graphxml_edge);
359 "<!DOCTYPE"{S}"node"{S}SYSTEM{S}("'graphxml.dtd'"|"\"graphxml.dtd\""){s}">" SET(ROOT_graphxml_node);
360 "<!DOCTYPE"{S}"graph"{S}SYSTEM{S}("'graphxml.dtd'"|"\"graphxml.dtd\""){s}">" SET(ROOT_graphxml_graph);
361 "<!"[^>-][^>]*">" FAIL("Bad declaration %s.",yytext);
362 . FAIL("Unexpected character `%c' in prolog.", yytext[0]);
363 <<EOF>> FAIL("EOF in prolog.");
366 /* RULES DERIVED FROM DTD. */
368 /* <!-- Small DTD for xbt graphs. --> */
370 /* isDirected (true|false) "true"
373 <ROOT_graphxml_graph>"<graph"{s} {
374 AX_graphxml_graph_isDirected = A_graphxml_graph_isDirected_true;
375 ENTER(AL_graphxml_graph); pushbuffer(0);
379 "isDirected"{Eq}"'true'" |
380 "isDirected"{Eq}"\"true\"" A_graphxml_graph_isDirected = A_graphxml_graph_isDirected_true;
381 "isDirected"{Eq}"'false'" |
382 "isDirected"{Eq}"\"false\"" A_graphxml_graph_isDirected = A_graphxml_graph_isDirected_false;
385 LEAVE; STag_graphxml_graph();graphxml_pcdata_ix = 0; ENTER(S_graphxml_graph);
388 LEAVE; STag_graphxml_graph(); graphxml_pcdata_ix = 0; ETag_graphxml_graph(); popbuffer(); /* attribute */
390 case ROOT_graphxml_graph: SET(EPILOG); break;
393 . FAIL("Unexpected character `%c' in attribute list of graph element.", yytext[0]);
394 {Name} FAIL("Bad attribute `%s' in `graph' element start tag.",yytext);
395 <<EOF>> FAIL("EOF in attribute list of `graph' element.");
398 <S_graphxml_graph_1,E_graphxml_graph,S_graphxml_graph_3,S_graphxml_graph_5,S_graphxml_graph>{
401 ETag_graphxml_graph();
402 popbuffer(); /* attribute */
404 case ROOT_graphxml_graph: SET(EPILOG); break;
407 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</graph>' expected.",yytext);
408 . FAIL("Unexpected character `%c': `</graph>' expected.",yytext[0]);
409 <<EOF>> FAIL("Premature EOF: `</graph>' expected.");
413 * name CDATA #REQUIRED
415 * position_x CDATA "-1.0"
416 * position_y CDATA "-1.0"
419 <ROOT_graphxml_node,S_graphxml_graph_2,S_graphxml_graph_3,S_graphxml_graph>"<node"{s} {
420 AX_graphxml_node_label = 0;
421 AX_graphxml_node_name = 0;
422 AX_graphxml_node_data = 0;
423 AX_graphxml_node_position_x = 1;
424 AX_graphxml_node_position_y = 6;
425 ENTER(AL_graphxml_node); pushbuffer(0);
429 "label"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_graphxml_node_label);
430 "label"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_graphxml_node_label);
432 "name"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_graphxml_node_name);
433 "name"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_graphxml_node_name);
435 "data"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_graphxml_node_data);
436 "data"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_graphxml_node_data);
438 "position_x"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_graphxml_node_position_x);
439 "position_x"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_graphxml_node_position_x);
441 "position_y"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_graphxml_node_position_y);
442 "position_y"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_graphxml_node_position_y);
445 if (!AX_graphxml_node_name) FAIL("Required attribute `name' not set for `node' element.");
446 LEAVE; STag_graphxml_node();graphxml_pcdata_ix = 0; ENTER(E_graphxml_node);
449 if (!AX_graphxml_node_name) FAIL("Required attribute `name' not set for `node' element.");
450 LEAVE; STag_graphxml_node(); graphxml_pcdata_ix = 0; ETag_graphxml_node(); popbuffer(); /* attribute */
452 case S_graphxml_graph_2: case S_graphxml_graph_3: case S_graphxml_graph: SET(S_graphxml_graph_3); break;
453 case ROOT_graphxml_node: SET(EPILOG); break;
456 . FAIL("Unexpected character `%c' in attribute list of node element.", yytext[0]);
457 {Name} FAIL("Bad attribute `%s' in `node' element start tag.",yytext);
458 <<EOF>> FAIL("EOF in attribute list of `node' element.");
464 ETag_graphxml_node();
465 popbuffer(); /* attribute */
467 case S_graphxml_graph_2: case S_graphxml_graph_3: case S_graphxml_graph: SET(S_graphxml_graph_3); break;
468 case ROOT_graphxml_node: SET(EPILOG); break;
471 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</node>' expected.",yytext);
472 . FAIL("Unexpected character `%c': `</node>' expected.",yytext[0]);
473 <<EOF>> FAIL("Premature EOF: `</node>' expected.");
477 * name CDATA #IMPLIED
478 * source CDATA #REQUIRED
479 * target CDATA #REQUIRED
480 * length CDATA "-1.0"
484 <ROOT_graphxml_edge,S_graphxml_graph_1,S_graphxml_graph_3,S_graphxml_graph_5,S_graphxml_graph_4,S_graphxml_graph>"<edge"{s} {
485 AX_graphxml_edge_label = 0;
486 AX_graphxml_edge_name = 0;
487 AX_graphxml_edge_source = 0;
488 AX_graphxml_edge_target = 0;
489 AX_graphxml_edge_length = 11;
490 AX_graphxml_edge_data = 0;
491 ENTER(AL_graphxml_edge); pushbuffer(0);
495 "label"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_graphxml_edge_label);
496 "label"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_graphxml_edge_label);
498 "name"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_graphxml_edge_name);
499 "name"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_graphxml_edge_name);
501 "source"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_graphxml_edge_source);
502 "source"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_graphxml_edge_source);
504 "target"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_graphxml_edge_target);
505 "target"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_graphxml_edge_target);
507 "length"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_graphxml_edge_length);
508 "length"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_graphxml_edge_length);
510 "data"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_graphxml_edge_data);
511 "data"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_graphxml_edge_data);
514 if (!AX_graphxml_edge_source) FAIL("Required attribute `source' not set for `edge' element.");
515 if (!AX_graphxml_edge_target) FAIL("Required attribute `target' not set for `edge' element.");
516 LEAVE; STag_graphxml_edge();graphxml_pcdata_ix = 0; ENTER(E_graphxml_edge);
519 if (!AX_graphxml_edge_source) FAIL("Required attribute `source' not set for `edge' element.");
520 if (!AX_graphxml_edge_target) FAIL("Required attribute `target' not set for `edge' element.");
521 LEAVE; STag_graphxml_edge(); graphxml_pcdata_ix = 0; ETag_graphxml_edge(); popbuffer(); /* attribute */
523 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;
524 case ROOT_graphxml_edge: SET(EPILOG); break;
527 . FAIL("Unexpected character `%c' in attribute list of edge element.", yytext[0]);
528 {Name} FAIL("Bad attribute `%s' in `edge' element start tag.",yytext);
529 <<EOF>> FAIL("EOF in attribute list of `edge' element.");
535 ETag_graphxml_edge();
536 popbuffer(); /* attribute */
538 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;
539 case ROOT_graphxml_edge: SET(EPILOG); break;
542 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</edge>' expected.",yytext);
543 . FAIL("Unexpected character `%c': `</edge>' expected.",yytext[0]);
544 <<EOF>> FAIL("Premature EOF: `</edge>' expected.");
547 /* EPILOG: after the root element. */
550 . {SET(PROLOG); yyless(0); CLEANUP; return -1;}
554 /* CHARACTER DATA. */
556 <IMPOSSIBLE,VALUE1,VALUE2>{
557 /* Non-defined standard entities... */
558 "&" BUFFERPUTC('&');
559 "<" BUFFERPUTC('<');
560 ">" BUFFERPUTC('>');
561 "'" BUFFERPUTC('\'');
562 """ BUFFERPUTC('"');
564 /* Character entities. */
565 "&#"[[:digit:]]+";" BUFFERPUTC((unsigned char)atoi(yytext+2));
566 "&#x"[[:xdigit:]]+";" BUFFERPUTC((unsigned char)strtol(yytext+3,NULL,16));
569 <IMPOSSIBLE,VALUE1,VALUE2,CDATA>{
573 "\n\r" BUFFERPUTC('\n');
577 "<![CDATA[" ENTER(CDATA);
578 "]""]>" FAIL("Unexpected `]""]>' in character data.");
582 \' BUFFERDONE; LEAVE;
583 <<EOF>> FAIL("EOF in literal (\"'\" expected).");
587 \" BUFFERDONE; LEAVE;
588 <<EOF>> FAIL("EOF in literal (`\"' expected).");
591 <IMPOSSIBLE,VALUE1,VALUE2>{
592 [^<&] BUFFERPUTC(yytext[0]);
593 [<&] FAIL("Spurious `%c' in character data.",yytext[0]);
598 /* "]""]" BUFFERPUTC(yytext[0]); BUFFERPUTC(yytext[1]); */
599 . BUFFERPUTC(yytext[0]);
600 <<EOF>> FAIL("EOF in CDATA section.");
603 /* Impossible rules to avoid warnings from flex(1). */
604 /* Ideally, this should be replaced by code in flexml.pl that
605 generates just the states not covered by other rules. */
607 .|[\n] FAIL("Syntax error on character `%c'.", yytext[0]);
612 /* Element context stack lookup. */
613 int graphxml_element_context(int i)
615 return (0<i && i<yy_start_stack_depth
616 ? yy_start_stack[yy_start_stack_ptr - i]
621 void print_yy_stack(char* fmt, ...)
623 int i = 0; va_list ap; va_start(ap, fmt);
624 vfprintf(stderr, fmt, ap);
625 if (graphxml_statenames) {
626 for (i=1; i<yy_start_stack_ptr; i++) {
627 fprintf(stderr, "%s/", graphxml_statenames[yy_start_stack[i] ]);
629 fprintf(stderr,"%s\n", graphxml_statenames[YY_START]);
634 void print_graphxml_bufferstack()
637 fputs("Buffer: ", stderr);
638 for (i = 0; i < blimit; i++) {
639 if ( graphxml_bufferstack[i] == '\377' ) break;
640 putc(graphxml_bufferstack[i], stderr);
645 static void debug_enter(int state, const char* statename) {
646 yy_push_state(state);
648 print_yy_stack("--ENTER(%s) : ",statename);
649 print_graphxml_bufferstack();
653 static void debug_leave(void) {
655 print_yy_stack("--LEAVE : ");
656 print_graphxml_bufferstack();
661 static void debug_set(int state, const char* statename) {
663 if (yy_flex_debug) print_yy_stack("--SET(%s) : ",statename);
668 static void cleanup(void)
670 if (graphxml_statenames) {
671 free(graphxml_statenames);
672 graphxml_statenames = NULL;
674 free(graphxml_bufferstack);
675 graphxml_bufferstack = NULL;
682 static int fail(const char* fmt, ...)
684 int chars_left, used;
685 va_list ap; va_start(ap, fmt);
686 #ifdef FLEXML_yylineno
687 used = sprintf(flexml_err_msg,
688 "Invalid XML (XML input line %d, state %d): ",
691 used = sprintf(flexml_err_msg,
692 "Invalid XML (state %d): ",
695 chars_left = flexml_max_err_msg_size - used - 1;
696 vsnprintf(flexml_err_msg + used, chars_left, fmt, ap);
699 #ifndef FLEXML_quiet_parser
700 /* print directly to sdterr */
701 fprintf(stderr, "%s\n", flexml_err_msg);
702 flexml_err_msg[0] = '\0';