1 /* Validating XML processor for surfxml.dtd.
2 * Generated 2005/01/04 14:37:23.
4 * This program was generated with the FleXML XML processor generator,
5 * (Id: flexml.pl,v 1.29 2005/01/04 09:30:15 alegrand Exp).
6 * Copyright © 1999 Kristoffer Rose. All rights reserved.
8 * You can redistribute and/or modify this program provided the following
11 * 1. The program is distributed WITHOUT ANY WARRANTY from the author of
12 * FleXML; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE.
15 * 2. The program distribution conditions do not in any way affect the
16 * distribution conditions of the FleXML system used to generate this
17 * file or any version of FleXML derived from that system.
19 * Notice that these are explicit rights granted to you for files
20 * generated by the FleXML system. For your rights in connection with
21 * the FleXML system itself please consult the GNU General Public License.
26 /* Version strings. */
27 const char rcs_flexml_skeleton[] =
28 "$" "Id: skel,v 1.16 1999/12/09 04:01:51 krisrose Exp $";
29 const char rcs_flexml[] =
30 "$" "Id: flexml.pl,v 1.29 2005/01/04 09:30:15 alegrand Exp $";
40 /* Generated definitions. */
41 #define FLEXML_BUFFERSTACKSIZE 10000000
43 /* XML processor api. */
44 #include "surf/surfxml.h"
46 /* FleXML-provided data. */
48 AT_network_link_bandwidth A_network_link_bandwidth;
49 AT_cpu_name A_cpu_name;
50 AT_network_link_state A_network_link_state;
51 AT_argument_value A_argument_value;
52 AT_cpu_availability_file A_cpu_availability_file;
53 AT_process_host A_process_host;
54 AT_route_src A_route_src;
55 AT_network_link_latency_file A_network_link_latency_file;
56 AT_cpu_availability A_cpu_availability;
57 AT_network_link_name A_network_link_name;
58 AT_route_element_name A_route_element_name;
59 AT_cpu_power A_cpu_power;
60 AT_process_function A_process_function;
61 AT_cpu_state A_cpu_state;
62 AT_route_dst A_route_dst;
63 AT_network_link_latency A_network_link_latency;
64 AT_cpu_state_file A_cpu_state_file;
65 AT_network_link_state_file A_network_link_state_file;
66 AT_network_link_bandwidth_file A_network_link_bandwidth_file;
70 # define ENTER(state) debug_enter(state,#state)
71 # define LEAVE debug_leave()
72 # define SET(state) debug_set(state,#state)
73 static void debug_enter(int, const char*);
74 static void debug_leave(void);
75 static void debug_set(int, const char*);
77 # define ENTER(state) (yy_push_state(state))
78 # define LEAVE (yy_pop_state())
79 # define SET(state) BEGIN(state)
82 /* Generic actions. */
84 #define SUCCEED return 0
86 #define FAIL return fail
87 static int fail(const char*, ...);
89 /* Text buffer stack handling. */
90 char bufferstack[FLEXML_BUFFERSTACKSIZE];
91 char* limit = bufferstack + FLEXML_BUFFERSTACKSIZE;
92 typedef struct BufferLast_s {
93 struct BufferLast_s *old; char* saved; char new[1];
95 BufferLast* last = (BufferLast*)0;
96 char* next = bufferstack;
98 #define BUFFERSET(P) (P = next)
99 #define BUFFERPUTC(C) (assert(next<limit), *(next++) = (C))
100 #define BUFFERDONE (BUFFERPUTC('\0'))
102 #define BUFFERLITERAL(C,P) bufferliteral(C,&(P),yytext)
103 static void bufferliteral(char c, char** pp, char* text)
105 char *s = strchr(text,c), *e = strrchr(text,c);
106 assert(s <= e); BUFFERSET(*pp);
108 if (isspace(*s)) { BUFFERPUTC(' '); while (isspace(*s)) ++s; }
114 #ifdef FLEXML_HasMixed
115 static void pushbuffer(char* p)
117 BufferLast* l = (BufferLast*)next;
118 assert(next < limit);
125 static char* popbuffer(void)
127 BufferLast* l = last;
128 assert(last != (BufferLast*)0);
135 /* General internal entities are `unput' back onto the input stream... */
136 #define ENTITYTEXT(T) \
137 { char *s = (T), *e = s+strlen(s);\
138 while (--e >= s) { unput(*e); }}
141 /* Flex standard options. */
143 %option noyy_top_state
149 /* Flex user-requested options. */
152 /* XML character classes (currently restricted to ASCII). */
154 /* "Common syntactic structures." */
158 /* "Names and Tokens." */
159 NameChar [A-Za-z0-9.:_-]
160 Name [A-Za-z_:]{NameChar}*
161 Names {Name}({S}{Name})*
162 Nmtoken ({NameChar})+
163 Nmtokens {Nmtoken}({S}{Nmtoken})*
166 VersionNum [a-zA-Z0-9_.:-]+
168 Literal \'[^'']*\'|\"[^""]*\"
170 /* Parser states (flex `exclusive start conditions'):
172 * PROLOG the XML prolog of the document before <?xml...>
173 * DOCTYPE the XML prolog of the document after <?xml...>
174 * EPILOG after the root element
175 * INCOMMENT inside an XML comment <!--....-->
176 * INPI inside an XML PI <?...?>
177 * VALUE1 inside a '...'-delimited literal
178 * VALUE2 inside a "..."-delimited literal
179 * CDATA inside a <![CDATA[...]]> section.
180 * ROOT_<tag> expect root element <tag>
181 * AL_<tag> inside the attribute list for <tag>
182 * IN_<tag> inside a <tag> with element contents (ready for end tag)
183 * IMPOSSIBLE dummy to permit disabling rules; must be last
185 %x PROLOG DOCTYPE EPILOG INCOMMENT INPI VALUE1 VALUE2 CDATA
186 %x ROOT_platform_description AL_platform_description S_platform_description S_platform_description_1 S_platform_description_2 E_platform_description
187 %x ROOT_cpu AL_cpu E_cpu
188 %x ROOT_network_link AL_network_link E_network_link
189 %x ROOT_route AL_route S_route S_route_1 S_route_2 E_route
190 %x ROOT_route_element AL_route_element E_route_element
191 %x ROOT_process AL_process S_process S_process_1 S_process_2 E_process
192 %x ROOT_argument AL_argument E_argument
197 const char* *statenames=NULL;
202 /* Bypass Flex's default INITIAL state and begin by parsing the XML prolog. */
205 if(!statenames) statenames=calloc(IMPOSSIBLE,sizeof(char*));
206 statenames[PROLOG] = NULL;
207 statenames[DOCTYPE] = NULL;
208 statenames[EPILOG] = NULL;
209 statenames[INCOMMENT] = NULL;
210 statenames[INPI] = NULL;
211 statenames[VALUE1] = NULL;
212 statenames[VALUE2] = NULL;
213 statenames[CDATA] = NULL;
214 statenames[ROOT_platform_description] = NULL;
215 statenames[AL_platform_description] = NULL;
216 statenames[S_platform_description] = "platform_description";
217 statenames[S_platform_description_1] = "platform_description";
218 statenames[S_platform_description_2] = "platform_description";
219 statenames[E_platform_description] = "platform_description";
220 statenames[ROOT_cpu] = NULL;
221 statenames[AL_cpu] = NULL;
222 statenames[E_cpu] = "cpu";
223 statenames[ROOT_network_link] = NULL;
224 statenames[AL_network_link] = NULL;
225 statenames[E_network_link] = "network_link";
226 statenames[ROOT_route] = NULL;
227 statenames[AL_route] = NULL;
228 statenames[S_route] = "route";
229 statenames[S_route_1] = "route";
230 statenames[S_route_2] = "route";
231 statenames[E_route] = "route";
232 statenames[ROOT_route_element] = NULL;
233 statenames[AL_route_element] = NULL;
234 statenames[E_route_element] = "route_element";
235 statenames[ROOT_process] = NULL;
236 statenames[AL_process] = NULL;
237 statenames[S_process] = "process";
238 statenames[S_process_1] = "process";
239 statenames[S_process_2] = "process";
240 statenames[E_process] = "process";
241 statenames[ROOT_argument] = NULL;
242 statenames[AL_argument] = NULL;
243 statenames[E_argument] = "argument";
245 /* COMMENTS and PIs: handled uniformly for efficiency. */
247 <ROOT_platform_description,AL_platform_description,S_platform_description,S_platform_description_1,S_platform_description_2,E_platform_description,ROOT_cpu,AL_cpu,E_cpu,ROOT_network_link,AL_network_link,E_network_link,ROOT_route,AL_route,S_route,S_route_1,S_route_2,E_route,ROOT_route_element,AL_route_element,E_route_element,ROOT_process,AL_process,S_process,S_process_1,S_process_2,E_process,ROOT_argument,AL_argument,E_argument,PROLOG,DOCTYPE,EPILOG>{
248 "<!--" ENTER(INCOMMENT);
256 <<EOF>> fail("EOF in comment.");
262 <<EOF>> fail("EOF in PI (processing instruction).");
265 /* SPACES: skipped uniformly */
267 <ROOT_platform_description,AL_platform_description,S_platform_description,S_platform_description_1,S_platform_description_2,E_platform_description,ROOT_cpu,AL_cpu,E_cpu,ROOT_network_link,AL_network_link,E_network_link,ROOT_route,AL_route,S_route,S_route_1,S_route_2,E_route,ROOT_route_element,AL_route_element,E_route_element,ROOT_process,AL_process,S_process,S_process_1,S_process_2,E_process,ROOT_argument,AL_argument,E_argument,PROLOG,DOCTYPE,EPILOG>{S} SKIP;
269 /* PROLOG: determine root element and process it. */
272 "<?xml"({S}version{Eq}(\'{VersionNum}\'|\"{VersionNum}\"))?"?>" SET(DOCTYPE);
273 "<?xml"[^>]*">" fail("Bad declaration %s.",yytext);
277 "<!DOCTYPE"{S}"argument"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_argument);
278 "<!DOCTYPE"{S}"route_element"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_route_element);
279 "<!DOCTYPE"{S}"cpu"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_cpu);
280 "<!DOCTYPE"{S}"route"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_route);
281 "<!DOCTYPE"{S}"platform_description"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_platform_description);
282 "<!DOCTYPE"{S}"network_link"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_network_link);
283 "<!DOCTYPE"{S}"process"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_process);
284 "<!"[^>-][^>]*">" fail("Bad declaration %s.",yytext);
285 . fail("Unexpected character `%c' in prolog.", yytext[0]);
286 <<EOF>> fail("EOF in prolog.");
289 /* RULES DERIVED FROM DTD. */
291 /* <!-- Small DTD for SURF based tools. --> */
293 <ROOT_platform_description>"<platform_description"{s} {
294 ENTER(AL_platform_description);
297 <AL_platform_description>{
299 LEAVE; STag_platform_description();pcdata = NULL; ENTER(S_platform_description);
302 LEAVE; STag_platform_description(); pcdata = NULL; ETag_platform_description();
304 case ROOT_platform_description: SET(EPILOG); break;
307 . fail("Unexpected character `%c' in attribute list of platform_description element.", yytext[0]);
308 {Name} fail("Bad attribute `%s' in `platform_description' element start tag.",yytext);
309 <<EOF>> fail("EOF in attribute list of `platform_description' element.");
312 <E_platform_description,S_platform_description_2,S_platform_description>{
313 "</platform_description"{s}">" {
315 ETag_platform_description();
317 case ROOT_platform_description: SET(EPILOG); break;
320 "</"{Name}{s}">" fail("Unexpected end-tag `%s': `</platform_description>' expected.",yytext);
321 . fail("Unexpected character `%c': `</platform_description>' expected.",yytext[0]);
322 <<EOF>> fail("Premature EOF: `</platform_description>' expected.");
325 <ROOT_cpu,S_platform_description_2,S_platform_description_1,S_platform_description>"<cpu"{s} {
328 A_cpu_availability = "1.0";
329 A_cpu_availability_file = NULL;
330 A_cpu_state = A_cpu_state_ON;
331 A_cpu_state_file = NULL;
336 "name"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_name);
337 "name"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_name);
339 "power"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_power);
340 "power"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_power);
342 "availability"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_availability);
343 "availability"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_availability);
345 "availability_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_availability_file);
346 "availability_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_availability_file);
349 "state"{Eq}"\"ON\"" A_cpu_state = A_cpu_state_ON;
351 "state"{Eq}"\"OFF\"" A_cpu_state = A_cpu_state_OFF;
353 "state_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_state_file);
354 "state_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_state_file);
357 if (!A_cpu_name) fail("Required attribute `name' not set for `cpu' element.");
358 if (!A_cpu_power) fail("Required attribute `power' not set for `cpu' element.");
359 LEAVE; STag_cpu();pcdata = NULL; ENTER(E_cpu);
362 if (!A_cpu_name) fail("Required attribute `name' not set for `cpu' element.");
363 if (!A_cpu_power) fail("Required attribute `power' not set for `cpu' element.");
364 LEAVE; STag_cpu(); pcdata = NULL; ETag_cpu();
366 case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
367 case ROOT_cpu: SET(EPILOG); break;
370 . fail("Unexpected character `%c' in attribute list of cpu element.", yytext[0]);
371 {Name} fail("Bad attribute `%s' in `cpu' element start tag.",yytext);
372 <<EOF>> fail("EOF in attribute list of `cpu' element.");
380 case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
381 case ROOT_cpu: SET(EPILOG); break;
384 "</"{Name}{s}">" fail("Unexpected end-tag `%s': `</cpu>' expected.",yytext);
385 . fail("Unexpected character `%c': `</cpu>' expected.",yytext[0]);
386 <<EOF>> fail("Premature EOF: `</cpu>' expected.");
389 <ROOT_network_link,S_platform_description_2,S_platform_description_1,S_platform_description>"<network_link"{s} {
390 A_network_link_name = NULL;
391 A_network_link_bandwidth = NULL;
392 A_network_link_bandwidth_file = NULL;
393 A_network_link_latency = "0.001";
394 A_network_link_latency_file = NULL;
395 A_network_link_state = A_network_link_state_ON;
396 A_network_link_state_file = NULL;
397 ENTER(AL_network_link);
401 "name"{Eq}\' ENTER(VALUE1); BUFFERSET(A_network_link_name);
402 "name"{Eq}\" ENTER(VALUE2); BUFFERSET(A_network_link_name);
404 "bandwidth"{Eq}\' ENTER(VALUE1); BUFFERSET(A_network_link_bandwidth);
405 "bandwidth"{Eq}\" ENTER(VALUE2); BUFFERSET(A_network_link_bandwidth);
407 "bandwidth_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_network_link_bandwidth_file);
408 "bandwidth_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_network_link_bandwidth_file);
410 "latency"{Eq}\' ENTER(VALUE1); BUFFERSET(A_network_link_latency);
411 "latency"{Eq}\" ENTER(VALUE2); BUFFERSET(A_network_link_latency);
413 "latency_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_network_link_latency_file);
414 "latency_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_network_link_latency_file);
417 "state"{Eq}"\"ON\"" A_network_link_state = A_network_link_state_ON;
419 "state"{Eq}"\"OFF\"" A_network_link_state = A_network_link_state_OFF;
421 "state_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_network_link_state_file);
422 "state_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_network_link_state_file);
425 if (!A_network_link_name) fail("Required attribute `name' not set for `network_link' element.");
426 if (!A_network_link_bandwidth) fail("Required attribute `bandwidth' not set for `network_link' element.");
427 LEAVE; STag_network_link();pcdata = NULL; ENTER(E_network_link);
430 if (!A_network_link_name) fail("Required attribute `name' not set for `network_link' element.");
431 if (!A_network_link_bandwidth) fail("Required attribute `bandwidth' not set for `network_link' element.");
432 LEAVE; STag_network_link(); pcdata = NULL; ETag_network_link();
434 case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
435 case ROOT_network_link: SET(EPILOG); break;
438 . fail("Unexpected character `%c' in attribute list of network_link element.", yytext[0]);
439 {Name} fail("Bad attribute `%s' in `network_link' element start tag.",yytext);
440 <<EOF>> fail("EOF in attribute list of `network_link' element.");
444 "</network_link"{s}">" {
448 case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
449 case ROOT_network_link: SET(EPILOG); break;
452 "</"{Name}{s}">" fail("Unexpected end-tag `%s': `</network_link>' expected.",yytext);
453 . fail("Unexpected character `%c': `</network_link>' expected.",yytext[0]);
454 <<EOF>> fail("Premature EOF: `</network_link>' expected.");
457 <ROOT_route,S_platform_description_2,S_platform_description_1,S_platform_description>"<route"{s} {
464 "src"{Eq}\' ENTER(VALUE1); BUFFERSET(A_route_src);
465 "src"{Eq}\" ENTER(VALUE2); BUFFERSET(A_route_src);
467 "dst"{Eq}\' ENTER(VALUE1); BUFFERSET(A_route_dst);
468 "dst"{Eq}\" ENTER(VALUE2); BUFFERSET(A_route_dst);
471 if (!A_route_src) fail("Required attribute `src' not set for `route' element.");
472 if (!A_route_dst) fail("Required attribute `dst' not set for `route' element.");
473 LEAVE; STag_route();pcdata = NULL; ENTER(S_route);
476 if (!A_route_src) fail("Required attribute `src' not set for `route' element.");
477 if (!A_route_dst) fail("Required attribute `dst' not set for `route' element.");
478 LEAVE; STag_route(); pcdata = NULL; ETag_route();
480 case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
481 case ROOT_route: SET(EPILOG); break;
484 . fail("Unexpected character `%c' in attribute list of route element.", yytext[0]);
485 {Name} fail("Bad attribute `%s' in `route' element start tag.",yytext);
486 <<EOF>> fail("EOF in attribute list of `route' element.");
489 <S_route,S_route_2,E_route>{
494 case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
495 case ROOT_route: SET(EPILOG); break;
498 "</"{Name}{s}">" fail("Unexpected end-tag `%s': `</route>' expected.",yytext);
499 . fail("Unexpected character `%c': `</route>' expected.",yytext[0]);
500 <<EOF>> fail("Premature EOF: `</route>' expected.");
503 <ROOT_route_element,S_route_1,S_route,S_route_2>"<route_element"{s} {
504 A_route_element_name = NULL;
505 ENTER(AL_route_element);
509 "name"{Eq}\' ENTER(VALUE1); BUFFERSET(A_route_element_name);
510 "name"{Eq}\" ENTER(VALUE2); BUFFERSET(A_route_element_name);
513 if (!A_route_element_name) fail("Required attribute `name' not set for `route_element' element.");
514 LEAVE; STag_route_element();pcdata = NULL; ENTER(E_route_element);
517 if (!A_route_element_name) fail("Required attribute `name' not set for `route_element' element.");
518 LEAVE; STag_route_element(); pcdata = NULL; ETag_route_element();
520 case S_route_1: case S_route: case S_route_2: SET(S_route_2); break;
521 case ROOT_route_element: SET(EPILOG); break;
524 . fail("Unexpected character `%c' in attribute list of route_element element.", yytext[0]);
525 {Name} fail("Bad attribute `%s' in `route_element' element start tag.",yytext);
526 <<EOF>> fail("EOF in attribute list of `route_element' element.");
530 "</route_element"{s}">" {
532 ETag_route_element();
534 case S_route_1: case S_route: case S_route_2: SET(S_route_2); break;
535 case ROOT_route_element: SET(EPILOG); break;
538 "</"{Name}{s}">" fail("Unexpected end-tag `%s': `</route_element>' expected.",yytext);
539 . fail("Unexpected character `%c': `</route_element>' expected.",yytext[0]);
540 <<EOF>> fail("Premature EOF: `</route_element>' expected.");
543 <ROOT_process,S_platform_description_2,S_platform_description_1,S_platform_description>"<process"{s} {
544 A_process_host = NULL;
545 A_process_function = NULL;
550 "host"{Eq}\' ENTER(VALUE1); BUFFERSET(A_process_host);
551 "host"{Eq}\" ENTER(VALUE2); BUFFERSET(A_process_host);
553 "function"{Eq}\' ENTER(VALUE1); BUFFERSET(A_process_function);
554 "function"{Eq}\" ENTER(VALUE2); BUFFERSET(A_process_function);
557 if (!A_process_host) fail("Required attribute `host' not set for `process' element.");
558 if (!A_process_function) fail("Required attribute `function' not set for `process' element.");
559 LEAVE; STag_process();pcdata = NULL; ENTER(S_process);
562 if (!A_process_host) fail("Required attribute `host' not set for `process' element.");
563 if (!A_process_function) fail("Required attribute `function' not set for `process' element.");
564 LEAVE; STag_process(); pcdata = NULL; ETag_process();
566 case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
567 case ROOT_process: SET(EPILOG); break;
570 . fail("Unexpected character `%c' in attribute list of process element.", yytext[0]);
571 {Name} fail("Bad attribute `%s' in `process' element start tag.",yytext);
572 <<EOF>> fail("EOF in attribute list of `process' element.");
575 <S_process,E_process,S_process_2>{
580 case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
581 case ROOT_process: SET(EPILOG); break;
584 "</"{Name}{s}">" fail("Unexpected end-tag `%s': `</process>' expected.",yytext);
585 . fail("Unexpected character `%c': `</process>' expected.",yytext[0]);
586 <<EOF>> fail("Premature EOF: `</process>' expected.");
589 <ROOT_argument,S_process_1,S_process,S_process_2>"<argument"{s} {
590 A_argument_value = NULL;
595 "value"{Eq}\' ENTER(VALUE1); BUFFERSET(A_argument_value);
596 "value"{Eq}\" ENTER(VALUE2); BUFFERSET(A_argument_value);
599 if (!A_argument_value) fail("Required attribute `value' not set for `argument' element.");
600 LEAVE; STag_argument();pcdata = NULL; ENTER(E_argument);
603 if (!A_argument_value) fail("Required attribute `value' not set for `argument' element.");
604 LEAVE; STag_argument(); pcdata = NULL; ETag_argument();
606 case ROOT_argument: SET(EPILOG); break;
607 case S_process_1: case S_process: case S_process_2: SET(S_process_2); break;
610 . fail("Unexpected character `%c' in attribute list of argument element.", yytext[0]);
611 {Name} fail("Bad attribute `%s' in `argument' element start tag.",yytext);
612 <<EOF>> fail("EOF in attribute list of `argument' element.");
620 case ROOT_argument: SET(EPILOG); break;
621 case S_process_1: case S_process: case S_process_2: SET(S_process_2); break;
624 "</"{Name}{s}">" fail("Unexpected end-tag `%s': `</argument>' expected.",yytext);
625 . fail("Unexpected character `%c': `</argument>' expected.",yytext[0]);
626 <<EOF>> fail("Premature EOF: `</argument>' expected.");
629 /* EPILOG: after the root element. */
632 . fail("Unexpected character `%c' after document.", yytext[0]);
636 /* CHARACTER DATA. */
638 <IMPOSSIBLE,VALUE1,VALUE2>{
639 /* Non-defined standard entities... */
640 "&" BUFFERPUTC('&');
641 "<" BUFFERPUTC('<');
642 ">" BUFFERPUTC('>');
643 "'" BUFFERPUTC('\'');
644 """ BUFFERPUTC('"');
646 /* Character entities. */
647 "&#"[[:digit:]]+";" BUFFERPUTC((unsigned char)atoi(yytext+2));
648 "&#x"[[:xdigit:]]+";" BUFFERPUTC((unsigned char)strtol(yytext+3,NULL,16));
651 <IMPOSSIBLE,VALUE1,VALUE2,CDATA>{
655 "\n\r" BUFFERPUTC('\n');
659 "<![CDATA[" ENTER(CDATA);
660 "]""]>" fail("Unexpected `]""]>' in character data.");
664 \' BUFFERDONE; LEAVE;
665 <<EOF>> fail("EOF in literal (\"'\" expected).");
669 \" BUFFERDONE; LEAVE;
670 <<EOF>> fail("EOF in literal (`\"' expected).");
673 <IMPOSSIBLE,VALUE1,VALUE2>{
674 [^<&] BUFFERPUTC(yytext[0]);
675 [<&] fail("Spurious `%c' in character data.",yytext[0]);
680 "]""]" BUFFERPUTC(yytext[0]); BUFFERPUTC(yytext[1]);
681 . BUFFERPUTC(yytext[0]);
682 <<EOF>> fail("EOF in CDATA section.");
685 /* Impossible rules to avoid warnings from flex(1). */
687 <INITIAL,IMPOSSIBLE>{
688 .|[\n] fail("The Impossible Happened: INITIAL or IMPOSSIBLE state entered?");
693 /* Element context stack lookup. */
694 int element_context(int i)
696 return (0<i && i<yy_start_stack_depth
697 ? yy_start_stack[yy_start_stack_ptr - i]
702 void print_yy_stack(char* fmt, ...)
704 int i = 0; va_list ap; va_start(ap, fmt);
705 vfprintf(stderr, fmt, ap);
706 for (i=1; i<yy_start_stack_ptr; i++)
707 fprintf(stderr, "%s/", statenames[yy_start_stack[i] ]);
708 fprintf(stderr,"%s\n", statenames[YY_START]);
712 static void debug_enter(int state, const char* statename) {
713 yy_push_state(state);
714 if (yy_flex_debug) print_yy_stack("--ENTER(%s) : ",statename);
717 static void debug_leave(void) {
718 if (yy_flex_debug) print_yy_stack("--LEAVE : ");
722 static void debug_set(int state, const char* statename) {
724 if (yy_flex_debug) print_yy_stack("--SET(%s) : ",statename);
729 static int fail(const char* fmt, ...)
731 va_list ap; va_start(ap, fmt);
732 #ifdef FLEXML_yylineno
733 fprintf(stderr, "Invalid XML (XML input line %d, state %d): ", yylineno, YY_START);
735 fprintf(stderr, "Invalid XML (state %d): ",YY_START);
737 vfprintf(stderr, fmt, ap);
738 fprintf(stderr, "\n");