1 /* Validating XML processor for /home/mquinson/Code/simgrid/src/xbt/graphxml.dtd.
2 * Generated 2010/04/06 12:44:26.
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.62 2007/10/11 10:00:14 mquinson 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.40 2007/10/11 09:57:24 mquinson Exp $";
53 const char rcs_graphxml_flexml[] =
54 "$" "Id: flexml.pl,v 1.62 2007/10/11 10:00:14 mquinson Exp $";
57 #include <stdlib.h> /* for realloc() -- needed here when using flex 2.5.4 */
64 #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__TOS_WIN__)
65 # ifndef __STRICT_ANSI__
73 #ifndef FLEXML_INDEXSTACKSIZE
74 #define FLEXML_INDEXSTACKSIZE 1000
77 /* Generated definitions. */
78 #define FLEXML_yylineno
79 #ifndef FLEXML_BUFFERSTACKSIZE
80 #define FLEXML_BUFFERSTACKSIZE 1000000
82 #define FLEXML_NEED_BUFFERLIT
84 /* XML processor api. */
85 /* FleXML-provided data. */
86 int graphxml_pcdata_ix;
87 extern char *graphxml_bufferstack;
88 #define graphxml_pcdata (graphxml_bufferstack + graphxml_pcdata_ix)
89 AT_graphxml_node_name AX_graphxml_node_name;
90 #define A_graphxml_node_name (graphxml_bufferstack + AX_graphxml_node_name)
91 AT_graphxml_edge_source AX_graphxml_edge_source;
92 #define A_graphxml_edge_source (graphxml_bufferstack + AX_graphxml_edge_source)
93 AT_graphxml_node_position_y AX_graphxml_node_position_y;
94 #define A_graphxml_node_position_y (graphxml_bufferstack + AX_graphxml_node_position_y)
95 AT_graphxml_node_position_x AX_graphxml_node_position_x;
96 #define A_graphxml_node_position_x (graphxml_bufferstack + AX_graphxml_node_position_x)
97 AT_graphxml_edge_data AX_graphxml_edge_data;
98 #define A_graphxml_edge_data (graphxml_bufferstack + AX_graphxml_edge_data)
99 AT_graphxml_edge_target AX_graphxml_edge_target;
100 #define A_graphxml_edge_target (graphxml_bufferstack + AX_graphxml_edge_target)
101 AT_graphxml_graph_isDirected AX_graphxml_graph_isDirected;
102 #define A_graphxml_graph_isDirected AX_graphxml_graph_isDirected
103 AT_graphxml_node_label AX_graphxml_node_label;
104 #define A_graphxml_node_label (graphxml_bufferstack + AX_graphxml_node_label)
105 AT_graphxml_node_data AX_graphxml_node_data;
106 #define A_graphxml_node_data (graphxml_bufferstack + AX_graphxml_node_data)
107 AT_graphxml_edge_label AX_graphxml_edge_label;
108 #define A_graphxml_edge_label (graphxml_bufferstack + AX_graphxml_edge_label)
109 AT_graphxml_edge_length AX_graphxml_edge_length;
110 #define A_graphxml_edge_length (graphxml_bufferstack + AX_graphxml_edge_length)
111 AT_graphxml_edge_name AX_graphxml_edge_name;
112 #define A_graphxml_edge_name (graphxml_bufferstack + AX_graphxml_edge_name)
116 # define ENTER(state) debug_enter(state,#state)
117 # define LEAVE debug_leave()
118 # define SET(state) debug_set(state,#state)
119 static void debug_enter(int, const char*);
120 static void debug_leave(void);
121 static void debug_set(int, const char*);
123 # define ENTER(state) (yy_push_state(state))
124 # define LEAVE (yy_pop_state())
125 # define SET(state) BEGIN(state)
128 /* Generic actions. */
129 #define SKIP /*skip*/
130 #define SUCCEED CLEANUP; return 0
132 #define FAIL return fail
133 static int fail(const char*, ...);
135 enum {flexml_max_err_msg_size = 512};
136 static char flexml_err_msg[flexml_max_err_msg_size];
137 const char * graphxml_parse_err_msg()
139 return flexml_err_msg;
141 static void reset_graphxml_parse_err_msg()
143 flexml_err_msg[0] = '\0';
147 static void cleanup(void);
148 #define CLEANUP cleanup()
150 /* Text buffer stack handling. */
151 char *graphxml_bufferstack = NULL;
152 static int blimit = FLEXML_BUFFERSTACKSIZE;
153 static int bnext = 1;
155 static int *indexstack = NULL;
156 static int ilimit = FLEXML_INDEXSTACKSIZE;
157 static int inext = 1;
159 #define BUFFERSET(P) (P = bnext)
160 #define BUFFERPUTC(C) (ck_blimit(), graphxml_bufferstack[bnext++] = (C))
161 #define BUFFERDONE (BUFFERPUTC('\0'))
163 #define BUFFERLITERAL(C, P) graphxml_bufferliteral(C, &(P), yytext)
165 /* after this is called, there are at least 2 slots left in the stack */
166 static int ck_blimit()
168 if (bnext >= blimit) {
169 blimit += FLEXML_BUFFERSTACKSIZE + 2;
171 char *temp = (char *) realloc(graphxml_bufferstack, blimit);
173 graphxml_bufferstack = temp;
179 /* after this is called, there are at least 2 slots left in the stack */
180 static int ck_ilimit()
182 if (inext >= ilimit) {
183 ilimit += FLEXML_INDEXSTACKSIZE + 2;
185 int *temp = (int *) realloc(indexstack, ilimit);
193 #ifdef FLEXML_NEED_BUFFERLIT
194 static void graphxml_bufferliteral(char c, int* pp, const char* text)
196 const char *s = (c ? strchr(text,c) : text-1), *e = strrchr(text,c);
197 assert(s <= e); BUFFERSET(*pp);
199 if (isspace(*s) && c) { BUFFERPUTC(' '); while (isspace(*s)) ++s; }
206 static void pushbuffer(int p)
209 indexstack[inext++] = p;
210 indexstack[inext++] = bnext;
213 static int popbuffer(void)
216 bnext = indexstack[--inext];
217 return indexstack[--inext];
220 /* General internal entities are `unput' back onto the input stream... */
221 #define ENTITYTEXT(T) \
222 { char *s = (T), *e = s+strlen(s);\
223 while (--e >= s) { unput(*e); }}
228 /* Flex standard options. */
230 %option noyy_top_state
236 /* Flex user-requested options. */
240 /* XML character classes (currently restricted to ASCII). */
242 /* "Common syntactic structures." */
246 /* "Names and Tokens." */
247 NameChar [A-Za-z0-9.:_-]
248 Name [A-Za-z_:]{NameChar}*
249 Names {Name}({S}{Name})*
250 Nmtoken ({NameChar})+
251 Nmtokens {Nmtoken}({S}{Nmtoken})*
254 VersionNum [a-zA-Z0-9_.:-]+
256 Literal \'[^'']*\'|\"[^""]*\"
258 /* Parser states (flex `exclusive start conditions'):
260 * PROLOG the XML prolog of the document before <?xml...>
261 * DOCTYPE the XML prolog of the document after <?xml...>
262 * EPILOG after the root element
263 * INCOMMENT inside an XML comment <!--....-->
264 * INPI inside an XML PI <?...?>
265 * VALUE1 inside a '...'-delimited literal
266 * VALUE2 inside a "..."-delimited literal
267 * CDATA inside a <![CDATA[...] ]> section.
268 * ROOT_<tag> expect root element <tag>
269 * AL_<tag> inside the attribute list for <tag>
270 * IN_<tag> inside a <tag> with element contents (ready for end tag)
271 * IMPOSSIBLE dummy to permit disabling rules; must be last
273 %x PROLOG DOCTYPE EPILOG INCOMMENT INPI VALUE1 VALUE2 CDATA
274 %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
275 %x ROOT_graphxml_node AL_graphxml_node E_graphxml_node
276 %x ROOT_graphxml_edge AL_graphxml_edge E_graphxml_edge
281 const char* *graphxml_statenames=NULL;
286 /* Bypass Flex's default INITIAL state and begin by parsing the XML prolog. */
288 reset_graphxml_parse_err_msg();
289 graphxml_bufferstack = (char *) malloc(FLEXML_BUFFERSTACKSIZE);
290 assert(graphxml_bufferstack);
294 for (i = 0; i < blimit; i++) {
295 graphxml_bufferstack[i] = '\377';
299 graphxml_bufferstack[0] = '\0';
300 indexstack = (int *) malloc(FLEXML_INDEXSTACKSIZE * sizeof(int));
306 graphxml_bufferliteral('\0', &bnext, "-1.0");
307 graphxml_bufferliteral('\0', &bnext, "-1.0");
308 graphxml_bufferliteral('\0', &bnext, "-1.0");
309 if(!graphxml_statenames) {graphxml_statenames= (const char **)calloc(IMPOSSIBLE,sizeof(char*));
310 graphxml_statenames[PROLOG] = NULL;
311 graphxml_statenames[DOCTYPE] = NULL;
312 graphxml_statenames[EPILOG] = NULL;
313 graphxml_statenames[INCOMMENT] = NULL;
314 graphxml_statenames[INPI] = NULL;
315 graphxml_statenames[VALUE1] = NULL;
316 graphxml_statenames[VALUE2] = NULL;
317 graphxml_statenames[CDATA] = NULL;
318 graphxml_statenames[ROOT_graphxml_graph] = NULL;
319 graphxml_statenames[AL_graphxml_graph] = NULL;
320 graphxml_statenames[S_graphxml_graph] = "graph";
321 graphxml_statenames[S_graphxml_graph_1] = "graph";
322 graphxml_statenames[S_graphxml_graph_2] = "graph";
323 graphxml_statenames[S_graphxml_graph_3] = "graph";
324 graphxml_statenames[S_graphxml_graph_4] = "graph";
325 graphxml_statenames[S_graphxml_graph_5] = "graph";
326 graphxml_statenames[E_graphxml_graph] = "graph";
327 graphxml_statenames[ROOT_graphxml_node] = NULL;
328 graphxml_statenames[AL_graphxml_node] = NULL;
329 graphxml_statenames[E_graphxml_node] = "node";
330 graphxml_statenames[ROOT_graphxml_edge] = NULL;
331 graphxml_statenames[AL_graphxml_edge] = NULL;
332 graphxml_statenames[E_graphxml_edge] = "edge";
335 /* COMMENTS and PIs: handled uniformly for efficiency. */
337 <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>{
338 "<!--" ENTER(INCOMMENT);
346 <<EOF>> FAIL("EOF in comment.");
352 <<EOF>> FAIL("EOF in PI (processing instruction).");
355 /* SPACES: skipped uniformly */
357 <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;
359 /* PROLOG: determine root element and process it. */
362 "<?xml"({S}version{Eq}(\'{VersionNum}\'|\"{VersionNum}\"))?({S}encoding{Eq}(\'[^']*\'|\"[^"]*\"))?"?>" SET(DOCTYPE);
363 "<?xml"[^>]*">" FAIL("Bad declaration %s.",yytext);
367 "<!DOCTYPE"{S}"edge"{S}SYSTEM{S}("'graphxml.dtd'"|"\"graphxml.dtd\""){s}">" SET(ROOT_graphxml_edge);
368 "<!DOCTYPE"{S}"node"{S}SYSTEM{S}("'graphxml.dtd'"|"\"graphxml.dtd\""){s}">" SET(ROOT_graphxml_node);
369 "<!DOCTYPE"{S}"graph"{S}SYSTEM{S}("'graphxml.dtd'"|"\"graphxml.dtd\""){s}">" SET(ROOT_graphxml_graph);
370 "<!"[^>-][^>]*">" FAIL("Bad declaration %s.",yytext);
371 . FAIL("Unexpected character `%c' in prolog.", yytext[0]);
372 <<EOF>> FAIL("EOF in prolog.");
375 /* RULES DERIVED FROM DTD. */
377 /* <!-- Small DTD for xbt graphs. --> */
379 /* isDirected (true|false) "true"
382 <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.");
384 <ROOT_graphxml_graph>"<graph"{s} {
385 AX_graphxml_graph_isDirected = A_graphxml_graph_isDirected_true;
386 ENTER(AL_graphxml_graph); pushbuffer(0);
390 "isDirected"{Eq}"'true'" |
391 "isDirected"{Eq}"\"true\"" A_graphxml_graph_isDirected = A_graphxml_graph_isDirected_true;
392 "isDirected"{Eq}"'false'" |
393 "isDirected"{Eq}"\"false\"" A_graphxml_graph_isDirected = A_graphxml_graph_isDirected_false;
396 LEAVE; STag_graphxml_graph();graphxml_pcdata_ix = 0; ENTER(S_graphxml_graph);
399 LEAVE; STag_graphxml_graph(); graphxml_pcdata_ix = 0; ETag_graphxml_graph(); popbuffer(); /* attribute */
401 case ROOT_graphxml_graph: SET(EPILOG); break;
404 . FAIL("Unexpected character `%c' in attribute list of graph element.", yytext[0]);
405 {Name} FAIL("Bad attribute `%s' in `graph' element start tag.",yytext);
406 <<EOF>> FAIL("EOF in attribute list of `graph' element.");
409 <S_graphxml_graph_1,E_graphxml_graph,S_graphxml_graph_3,S_graphxml_graph_5,S_graphxml_graph>{
412 ETag_graphxml_graph();
413 popbuffer(); /* attribute */
415 case ROOT_graphxml_graph: SET(EPILOG); break;
418 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</graph>' expected.",yytext);
419 . FAIL("Unexpected character `%c': `</graph>' expected.",yytext[0]);
420 <<EOF>> FAIL("Premature EOF: `</graph>' expected.");
424 * name CDATA #REQUIRED
426 * position_x CDATA "-1.0"
427 * position_y CDATA "-1.0"
430 <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.");
432 <ROOT_graphxml_node,S_graphxml_graph_2,S_graphxml_graph_3,S_graphxml_graph>"<node"{s} {
433 AX_graphxml_node_label = 0;
434 AX_graphxml_node_name = 0;
435 AX_graphxml_node_data = 0;
436 AX_graphxml_node_position_x = 1;
437 AX_graphxml_node_position_y = 6;
438 ENTER(AL_graphxml_node); pushbuffer(0);
442 "label"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_graphxml_node_label);
443 "label"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_graphxml_node_label);
445 "name"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_graphxml_node_name);
446 "name"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_graphxml_node_name);
448 "data"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_graphxml_node_data);
449 "data"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_graphxml_node_data);
451 "position_x"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_graphxml_node_position_x);
452 "position_x"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_graphxml_node_position_x);
454 "position_y"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_graphxml_node_position_y);
455 "position_y"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_graphxml_node_position_y);
458 if (!AX_graphxml_node_name) FAIL("Required attribute `name' not set for `node' element.");
459 LEAVE; STag_graphxml_node();graphxml_pcdata_ix = 0; ENTER(E_graphxml_node);
462 if (!AX_graphxml_node_name) FAIL("Required attribute `name' not set for `node' element.");
463 LEAVE; STag_graphxml_node(); graphxml_pcdata_ix = 0; ETag_graphxml_node(); popbuffer(); /* attribute */
465 case S_graphxml_graph_2: case S_graphxml_graph_3: case S_graphxml_graph: SET(S_graphxml_graph_3); break;
466 case ROOT_graphxml_node: SET(EPILOG); break;
469 . FAIL("Unexpected character `%c' in attribute list of node element.", yytext[0]);
470 {Name} FAIL("Bad attribute `%s' in `node' element start tag.",yytext);
471 <<EOF>> FAIL("EOF in attribute list of `node' element.");
477 ETag_graphxml_node();
478 popbuffer(); /* attribute */
480 case S_graphxml_graph_2: case S_graphxml_graph_3: case S_graphxml_graph: SET(S_graphxml_graph_3); break;
481 case ROOT_graphxml_node: SET(EPILOG); break;
484 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</node>' expected.",yytext);
485 . FAIL("Unexpected character `%c': `</node>' expected.",yytext[0]);
486 <<EOF>> FAIL("Premature EOF: `</node>' expected.");
490 * name CDATA #IMPLIED
491 * source CDATA #REQUIRED
492 * target CDATA #REQUIRED
493 * length CDATA "-1.0"
497 <E_graphxml_graph,S_graphxml_graph_2>"<edge"{s} FAIL("Starting tag <edge> is not allowed here.");
499 <ROOT_graphxml_edge,S_graphxml_graph_1,S_graphxml_graph_3,S_graphxml_graph_5,S_graphxml_graph_4,S_graphxml_graph>"<edge"{s} {
500 AX_graphxml_edge_label = 0;
501 AX_graphxml_edge_name = 0;
502 AX_graphxml_edge_source = 0;
503 AX_graphxml_edge_target = 0;
504 AX_graphxml_edge_length = 11;
505 AX_graphxml_edge_data = 0;
506 ENTER(AL_graphxml_edge); pushbuffer(0);
510 "label"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_graphxml_edge_label);
511 "label"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_graphxml_edge_label);
513 "name"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_graphxml_edge_name);
514 "name"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_graphxml_edge_name);
516 "source"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_graphxml_edge_source);
517 "source"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_graphxml_edge_source);
519 "target"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_graphxml_edge_target);
520 "target"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_graphxml_edge_target);
522 "length"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_graphxml_edge_length);
523 "length"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_graphxml_edge_length);
525 "data"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_graphxml_edge_data);
526 "data"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_graphxml_edge_data);
529 if (!AX_graphxml_edge_source) FAIL("Required attribute `source' not set for `edge' element.");
530 if (!AX_graphxml_edge_target) FAIL("Required attribute `target' not set for `edge' element.");
531 LEAVE; STag_graphxml_edge();graphxml_pcdata_ix = 0; ENTER(E_graphxml_edge);
534 if (!AX_graphxml_edge_source) FAIL("Required attribute `source' not set for `edge' element.");
535 if (!AX_graphxml_edge_target) FAIL("Required attribute `target' not set for `edge' element.");
536 LEAVE; STag_graphxml_edge(); graphxml_pcdata_ix = 0; ETag_graphxml_edge(); 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 . FAIL("Unexpected character `%c' in attribute list of edge element.", yytext[0]);
543 {Name} FAIL("Bad attribute `%s' in `edge' element start tag.",yytext);
544 <<EOF>> FAIL("EOF in attribute list of `edge' element.");
550 ETag_graphxml_edge();
551 popbuffer(); /* attribute */
553 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;
554 case ROOT_graphxml_edge: SET(EPILOG); break;
557 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</edge>' expected.",yytext);
558 . FAIL("Unexpected character `%c': `</edge>' expected.",yytext[0]);
559 <<EOF>> FAIL("Premature EOF: `</edge>' expected.");
562 /* EPILOG: after the root element. */
565 . {SET(PROLOG); yyless(0); CLEANUP; return -1;}
569 /* CHARACTER DATA. */
571 <IMPOSSIBLE,VALUE1,VALUE2>{
572 /* Non-defined standard entities... */
573 "&" BUFFERPUTC('&');
574 "<" BUFFERPUTC('<');
575 ">" BUFFERPUTC('>');
576 "'" BUFFERPUTC('\'');
577 """ BUFFERPUTC('"');
579 /* Character entities. */
580 "&#"[[:digit:]]+";" BUFFERPUTC((unsigned char)atoi(yytext+2));
581 "&#x"[[:xdigit:]]+";" BUFFERPUTC((unsigned char)strtol(yytext+3,NULL,16));
584 <IMPOSSIBLE,VALUE1,VALUE2,CDATA>{
588 "\n\r" BUFFERPUTC('\n');
592 "<![CDATA[" ENTER(CDATA);
593 "]""]>" FAIL("Unexpected `]""]>' in character data.");
597 \' BUFFERDONE; LEAVE;
598 <<EOF>> FAIL("EOF in literal (\"'\" expected).");
602 \" BUFFERDONE; LEAVE;
603 <<EOF>> FAIL("EOF in literal (`\"' expected).");
606 <IMPOSSIBLE,VALUE1,VALUE2>{
607 [^<&] BUFFERPUTC(yytext[0]);
608 [<&] FAIL("Spurious `%c' in character data.",yytext[0]);
613 /* "]""]" BUFFERPUTC(yytext[0]); BUFFERPUTC(yytext[1]); */
614 . BUFFERPUTC(yytext[0]);
615 <<EOF>> FAIL("EOF in CDATA section.");
618 /* Impossible rules to avoid warnings from flex(1). */
619 /* Ideally, this should be replaced by code in flexml.pl that
620 generates just the states not covered by other rules. */
622 .|[\n] FAIL("Syntax error on character `%c'.", yytext[0]);
627 /* Element context stack lookup. */
628 int graphxml_element_context(int i)
630 return (0<i && i<yy_start_stack_depth
631 ? yy_start_stack[yy_start_stack_ptr - i]
636 void print_yy_stack(char* fmt, ...)
638 int i = 0; va_list ap; va_start(ap, fmt);
639 vfprintf(stderr, fmt, ap);
640 if (graphxml_statenames) {
641 for (i=1; i<yy_start_stack_ptr; i++) {
642 fprintf(stderr, "%s/", graphxml_statenames[yy_start_stack[i] ]);
644 fprintf(stderr,"%s\n", graphxml_statenames[YY_START]);
649 void print_graphxml_bufferstack()
652 fputs("Buffer: ", stderr);
653 for (i = 0; i < blimit; i++) {
654 if ( graphxml_bufferstack[i] == '\377' ) break;
655 putc(graphxml_bufferstack[i], stderr);
660 static void debug_enter(int state, const char* statename) {
661 yy_push_state(state);
663 print_yy_stack("--ENTER(%s) : ",statename);
664 print_graphxml_bufferstack();
668 static void debug_leave(void) {
670 print_yy_stack("--LEAVE : ");
671 print_graphxml_bufferstack();
676 static void debug_set(int state, const char* statename) {
678 if (yy_flex_debug) print_yy_stack("--SET(%s) : ",statename);
683 static void cleanup(void)
685 if (graphxml_statenames) {
686 free(graphxml_statenames);
687 graphxml_statenames = NULL;
689 free(graphxml_bufferstack);
690 graphxml_bufferstack = NULL;
697 static int fail(const char* fmt, ...)
699 int chars_left, used;
700 va_list ap; va_start(ap, fmt);
701 #ifdef FLEXML_yylineno
702 used = sprintf(flexml_err_msg,
703 "Invalid XML (XML input line %d, state %d): ",
706 used = sprintf(flexml_err_msg,
707 "Invalid XML (state %d): ",
710 chars_left = flexml_max_err_msg_size - used - 1;
711 vsnprintf(flexml_err_msg + used, chars_left, fmt, ap);
714 #ifndef FLEXML_quiet_parser
715 /* print directly to sdterr */
716 fprintf(stderr, "%s\n", flexml_err_msg);
717 flexml_err_msg[0] = '\0';