1 /* Validating XML processor for surfxml.dtd.
2 * Generated 2005/01/05 14:22:05.
4 * This program was generated with the FleXML XML processor generator,
5 * (Id: flexml.pl,v 1.35 2005/01/05 06:29:58 legranda 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.19 2005/01/05 18:49:27 legranda Exp $";
29 const char rcs_flexml[] =
30 "$" "Id: flexml.pl,v 1.35 2005/01/05 06:29:58 legranda Exp $";
40 /* Generated definitions. */
41 #define FLEXML_yylineno
42 #define FLEXML_BUFFERSTACKSIZE 10000000
44 /* XML processor api. */
47 /* FleXML-provided data. */
49 AT_network_link_bandwidth A_network_link_bandwidth;
50 AT_cpu_name A_cpu_name;
51 AT_network_link_state A_network_link_state;
52 AT_argument_value A_argument_value;
53 AT_cpu_availability_file A_cpu_availability_file;
54 AT_process_host A_process_host;
55 AT_route_src A_route_src;
56 AT_network_link_latency_file A_network_link_latency_file;
57 AT_cpu_availability A_cpu_availability;
58 AT_network_link_name A_network_link_name;
59 AT_route_element_name A_route_element_name;
60 AT_cpu_power A_cpu_power;
61 AT_process_function A_process_function;
62 AT_cpu_state A_cpu_state;
63 AT_route_dst A_route_dst;
64 AT_network_link_latency A_network_link_latency;
65 AT_cpu_state_file A_cpu_state_file;
66 AT_network_link_state_file A_network_link_state_file;
67 AT_network_link_bandwidth_file A_network_link_bandwidth_file;
71 # define ENTER(state) debug_enter(state,#state)
72 # define LEAVE debug_leave()
73 # define SET(state) debug_set(state,#state)
74 static void debug_enter(int, const char*);
75 static void debug_leave(void);
76 static void debug_set(int, const char*);
78 # define ENTER(state) (yy_push_state(state))
79 # define LEAVE (yy_pop_state())
80 # define SET(state) BEGIN(state)
83 /* Generic actions. */
85 #define SUCCEED return 0
87 #define FAIL return fail
88 static int fail(const char*, ...);
90 /* Text buffer stack handling. */
91 char bufferstack[FLEXML_BUFFERSTACKSIZE];
92 char* limit = bufferstack + FLEXML_BUFFERSTACKSIZE;
93 typedef struct BufferLast_s {
94 struct BufferLast_s *old; char* saved; char new[1];
96 BufferLast* last = (BufferLast*)0;
97 char* next = bufferstack;
99 #define BUFFERSET(P) (P = next)
100 #define BUFFERPUTC(C) (assert(next<limit), *(next++) = (C))
101 #define BUFFERDONE (BUFFERPUTC('\0'))
103 #define BUFFERLITERAL(C,P) bufferliteral(C,&(P),yytext)
104 static void bufferliteral(char c, const char** pp, char* text)
106 char *s = strchr(text,c), *e = strrchr(text,c);
107 assert(s <= e); BUFFERSET(*pp);
109 if (isspace(*s)) { BUFFERPUTC(' '); while (isspace(*s)) ++s; }
115 #ifdef FLEXML_HasMixed
116 static void pushbuffer(char* p)
118 BufferLast* l = (BufferLast*)next;
119 assert(next < limit);
126 static char* popbuffer(void)
128 BufferLast* l = last;
129 assert(last != (BufferLast*)0);
136 /* General internal entities are `unput' back onto the input stream... */
137 #define ENTITYTEXT(T) \
138 { char *s = (T), *e = s+strlen(s);\
139 while (--e >= s) { unput(*e); }}
142 /* Flex standard options. */
144 %option noyy_top_state
150 /* Flex user-requested options. */
154 /* XML character classes (currently restricted to ASCII). */
156 /* "Common syntactic structures." */
160 /* "Names and Tokens." */
161 NameChar [A-Za-z0-9.:_-]
162 Name [A-Za-z_:]{NameChar}*
163 Names {Name}({S}{Name})*
164 Nmtoken ({NameChar})+
165 Nmtokens {Nmtoken}({S}{Nmtoken})*
168 VersionNum [a-zA-Z0-9_.:-]+
170 Literal \'[^'']*\'|\"[^""]*\"
172 /* Parser states (flex `exclusive start conditions'):
174 * PROLOG the XML prolog of the document before <?xml...>
175 * DOCTYPE the XML prolog of the document after <?xml...>
176 * EPILOG after the root element
177 * INCOMMENT inside an XML comment <!--....-->
178 * INPI inside an XML PI <?...?>
179 * VALUE1 inside a '...'-delimited literal
180 * VALUE2 inside a "..."-delimited literal
181 * CDATA inside a <![CDATA[...]]> section.
182 * ROOT_<tag> expect root element <tag>
183 * AL_<tag> inside the attribute list for <tag>
184 * IN_<tag> inside a <tag> with element contents (ready for end tag)
185 * IMPOSSIBLE dummy to permit disabling rules; must be last
187 %x PROLOG DOCTYPE EPILOG INCOMMENT INPI VALUE1 VALUE2 CDATA
188 %x ROOT_platform_description AL_platform_description S_platform_description S_platform_description_1 S_platform_description_2 E_platform_description
189 %x ROOT_cpu AL_cpu E_cpu
190 %x ROOT_network_link AL_network_link E_network_link
191 %x ROOT_route AL_route S_route S_route_1 S_route_2 E_route
192 %x ROOT_route_element AL_route_element E_route_element
193 %x ROOT_process AL_process S_process S_process_1 S_process_2 E_process
194 %x ROOT_argument AL_argument E_argument
199 const char* *statenames=NULL;
204 /* Bypass Flex's default INITIAL state and begin by parsing the XML prolog. */
207 if(!statenames) statenames=calloc(IMPOSSIBLE,sizeof(char*));
208 statenames[PROLOG] = NULL;
209 statenames[DOCTYPE] = NULL;
210 statenames[EPILOG] = NULL;
211 statenames[INCOMMENT] = NULL;
212 statenames[INPI] = NULL;
213 statenames[VALUE1] = NULL;
214 statenames[VALUE2] = NULL;
215 statenames[CDATA] = NULL;
216 statenames[ROOT_platform_description] = NULL;
217 statenames[AL_platform_description] = NULL;
218 statenames[S_platform_description] = "platform_description";
219 statenames[S_platform_description_1] = "platform_description";
220 statenames[S_platform_description_2] = "platform_description";
221 statenames[E_platform_description] = "platform_description";
222 statenames[ROOT_cpu] = NULL;
223 statenames[AL_cpu] = NULL;
224 statenames[E_cpu] = "cpu";
225 statenames[ROOT_network_link] = NULL;
226 statenames[AL_network_link] = NULL;
227 statenames[E_network_link] = "network_link";
228 statenames[ROOT_route] = NULL;
229 statenames[AL_route] = NULL;
230 statenames[S_route] = "route";
231 statenames[S_route_1] = "route";
232 statenames[S_route_2] = "route";
233 statenames[E_route] = "route";
234 statenames[ROOT_route_element] = NULL;
235 statenames[AL_route_element] = NULL;
236 statenames[E_route_element] = "route_element";
237 statenames[ROOT_process] = NULL;
238 statenames[AL_process] = NULL;
239 statenames[S_process] = "process";
240 statenames[S_process_1] = "process";
241 statenames[S_process_2] = "process";
242 statenames[E_process] = "process";
243 statenames[ROOT_argument] = NULL;
244 statenames[AL_argument] = NULL;
245 statenames[E_argument] = "argument";
247 /* COMMENTS and PIs: handled uniformly for efficiency. */
249 <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>{
250 "<!--" ENTER(INCOMMENT);
258 <<EOF>> FAIL("EOF in comment.");
264 <<EOF>> FAIL("EOF in PI (processing instruction).");
267 /* SPACES: skipped uniformly */
269 <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;
271 /* PROLOG: determine root element and process it. */
274 "<?xml"({S}version{Eq}(\'{VersionNum}\'|\"{VersionNum}\"))?"?>" SET(DOCTYPE);
275 "<?xml"[^>]*">" FAIL("Bad declaration %s.",yytext);
279 "<!DOCTYPE"{S}"argument"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_argument);
280 "<!DOCTYPE"{S}"route_element"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_route_element);
281 "<!DOCTYPE"{S}"cpu"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_cpu);
282 "<!DOCTYPE"{S}"route"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_route);
283 "<!DOCTYPE"{S}"platform_description"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_platform_description);
284 "<!DOCTYPE"{S}"network_link"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_network_link);
285 "<!DOCTYPE"{S}"process"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_process);
286 "<!"[^>-][^>]*">" FAIL("Bad declaration %s.",yytext);
287 . FAIL("Unexpected character `%c' in prolog.", yytext[0]);
288 <<EOF>> FAIL("EOF in prolog.");
291 /* RULES DERIVED FROM DTD. */
293 /* <!-- Small DTD for SURF based tools. --> */
295 <ROOT_platform_description>"<platform_description"{s} {
296 ENTER(AL_platform_description);
299 <AL_platform_description>{
301 LEAVE; STag_platform_description();pcdata = NULL; ENTER(S_platform_description);
304 LEAVE; STag_platform_description(); pcdata = NULL; ETag_platform_description();
306 case ROOT_platform_description: SET(EPILOG); break;
309 . FAIL("Unexpected character `%c' in attribute list of platform_description element.", yytext[0]);
310 {Name} FAIL("Bad attribute `%s' in `platform_description' element start tag.",yytext);
311 <<EOF>> FAIL("EOF in attribute list of `platform_description' element.");
314 <E_platform_description,S_platform_description_2,S_platform_description>{
315 "</platform_description"{s}">" {
317 ETag_platform_description();
319 case ROOT_platform_description: SET(EPILOG); break;
322 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</platform_description>' expected.",yytext);
323 . FAIL("Unexpected character `%c': `</platform_description>' expected.",yytext[0]);
324 <<EOF>> FAIL("Premature EOF: `</platform_description>' expected.");
327 <ROOT_cpu,S_platform_description_2,S_platform_description_1,S_platform_description>"<cpu"{s} {
330 A_cpu_availability = "1.0";
331 A_cpu_availability_file = NULL;
332 A_cpu_state = A_cpu_state_ON;
333 A_cpu_state_file = NULL;
338 "name"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_name);
339 "name"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_name);
341 "power"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_power);
342 "power"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_power);
344 "availability"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_availability);
345 "availability"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_availability);
347 "availability_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_availability_file);
348 "availability_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_availability_file);
351 "state"{Eq}"\"ON\"" A_cpu_state = A_cpu_state_ON;
353 "state"{Eq}"\"OFF\"" A_cpu_state = A_cpu_state_OFF;
355 "state_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_state_file);
356 "state_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_state_file);
359 if (!A_cpu_name) FAIL("Required attribute `name' not set for `cpu' element.");
360 if (!A_cpu_power) FAIL("Required attribute `power' not set for `cpu' element.");
361 LEAVE; STag_cpu();pcdata = NULL; ENTER(E_cpu);
364 if (!A_cpu_name) FAIL("Required attribute `name' not set for `cpu' element.");
365 if (!A_cpu_power) FAIL("Required attribute `power' not set for `cpu' element.");
366 LEAVE; STag_cpu(); pcdata = NULL; ETag_cpu();
368 case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
369 case ROOT_cpu: SET(EPILOG); break;
372 . FAIL("Unexpected character `%c' in attribute list of cpu element.", yytext[0]);
373 {Name} FAIL("Bad attribute `%s' in `cpu' element start tag.",yytext);
374 <<EOF>> FAIL("EOF in attribute list of `cpu' element.");
382 case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
383 case ROOT_cpu: SET(EPILOG); break;
386 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</cpu>' expected.",yytext);
387 . FAIL("Unexpected character `%c': `</cpu>' expected.",yytext[0]);
388 <<EOF>> FAIL("Premature EOF: `</cpu>' expected.");
391 <ROOT_network_link,S_platform_description_2,S_platform_description_1,S_platform_description>"<network_link"{s} {
392 A_network_link_name = NULL;
393 A_network_link_bandwidth = NULL;
394 A_network_link_bandwidth_file = NULL;
395 A_network_link_latency = "0.001";
396 A_network_link_latency_file = NULL;
397 A_network_link_state = A_network_link_state_ON;
398 A_network_link_state_file = NULL;
399 ENTER(AL_network_link);
403 "name"{Eq}\' ENTER(VALUE1); BUFFERSET(A_network_link_name);
404 "name"{Eq}\" ENTER(VALUE2); BUFFERSET(A_network_link_name);
406 "bandwidth"{Eq}\' ENTER(VALUE1); BUFFERSET(A_network_link_bandwidth);
407 "bandwidth"{Eq}\" ENTER(VALUE2); BUFFERSET(A_network_link_bandwidth);
409 "bandwidth_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_network_link_bandwidth_file);
410 "bandwidth_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_network_link_bandwidth_file);
412 "latency"{Eq}\' ENTER(VALUE1); BUFFERSET(A_network_link_latency);
413 "latency"{Eq}\" ENTER(VALUE2); BUFFERSET(A_network_link_latency);
415 "latency_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_network_link_latency_file);
416 "latency_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_network_link_latency_file);
419 "state"{Eq}"\"ON\"" A_network_link_state = A_network_link_state_ON;
421 "state"{Eq}"\"OFF\"" A_network_link_state = A_network_link_state_OFF;
423 "state_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_network_link_state_file);
424 "state_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_network_link_state_file);
427 if (!A_network_link_name) FAIL("Required attribute `name' not set for `network_link' element.");
428 if (!A_network_link_bandwidth) FAIL("Required attribute `bandwidth' not set for `network_link' element.");
429 LEAVE; STag_network_link();pcdata = NULL; ENTER(E_network_link);
432 if (!A_network_link_name) FAIL("Required attribute `name' not set for `network_link' element.");
433 if (!A_network_link_bandwidth) FAIL("Required attribute `bandwidth' not set for `network_link' element.");
434 LEAVE; STag_network_link(); pcdata = NULL; ETag_network_link();
436 case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
437 case ROOT_network_link: SET(EPILOG); break;
440 . FAIL("Unexpected character `%c' in attribute list of network_link element.", yytext[0]);
441 {Name} FAIL("Bad attribute `%s' in `network_link' element start tag.",yytext);
442 <<EOF>> FAIL("EOF in attribute list of `network_link' element.");
446 "</network_link"{s}">" {
450 case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
451 case ROOT_network_link: SET(EPILOG); break;
454 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</network_link>' expected.",yytext);
455 . FAIL("Unexpected character `%c': `</network_link>' expected.",yytext[0]);
456 <<EOF>> FAIL("Premature EOF: `</network_link>' expected.");
459 <ROOT_route,S_platform_description_2,S_platform_description_1,S_platform_description>"<route"{s} {
466 "src"{Eq}\' ENTER(VALUE1); BUFFERSET(A_route_src);
467 "src"{Eq}\" ENTER(VALUE2); BUFFERSET(A_route_src);
469 "dst"{Eq}\' ENTER(VALUE1); BUFFERSET(A_route_dst);
470 "dst"{Eq}\" ENTER(VALUE2); BUFFERSET(A_route_dst);
473 if (!A_route_src) FAIL("Required attribute `src' not set for `route' element.");
474 if (!A_route_dst) FAIL("Required attribute `dst' not set for `route' element.");
475 LEAVE; STag_route();pcdata = NULL; ENTER(S_route);
478 if (!A_route_src) FAIL("Required attribute `src' not set for `route' element.");
479 if (!A_route_dst) FAIL("Required attribute `dst' not set for `route' element.");
480 LEAVE; STag_route(); pcdata = NULL; ETag_route();
482 case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
483 case ROOT_route: SET(EPILOG); break;
486 . FAIL("Unexpected character `%c' in attribute list of route element.", yytext[0]);
487 {Name} FAIL("Bad attribute `%s' in `route' element start tag.",yytext);
488 <<EOF>> FAIL("EOF in attribute list of `route' element.");
491 <S_route,S_route_2,E_route>{
496 case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
497 case ROOT_route: SET(EPILOG); break;
500 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</route>' expected.",yytext);
501 . FAIL("Unexpected character `%c': `</route>' expected.",yytext[0]);
502 <<EOF>> FAIL("Premature EOF: `</route>' expected.");
505 <ROOT_route_element,S_route_1,S_route,S_route_2>"<route_element"{s} {
506 A_route_element_name = NULL;
507 ENTER(AL_route_element);
511 "name"{Eq}\' ENTER(VALUE1); BUFFERSET(A_route_element_name);
512 "name"{Eq}\" ENTER(VALUE2); BUFFERSET(A_route_element_name);
515 if (!A_route_element_name) FAIL("Required attribute `name' not set for `route_element' element.");
516 LEAVE; STag_route_element();pcdata = NULL; ENTER(E_route_element);
519 if (!A_route_element_name) FAIL("Required attribute `name' not set for `route_element' element.");
520 LEAVE; STag_route_element(); pcdata = NULL; ETag_route_element();
522 case S_route_1: case S_route: case S_route_2: SET(S_route_2); break;
523 case ROOT_route_element: SET(EPILOG); break;
526 . FAIL("Unexpected character `%c' in attribute list of route_element element.", yytext[0]);
527 {Name} FAIL("Bad attribute `%s' in `route_element' element start tag.",yytext);
528 <<EOF>> FAIL("EOF in attribute list of `route_element' element.");
532 "</route_element"{s}">" {
534 ETag_route_element();
536 case S_route_1: case S_route: case S_route_2: SET(S_route_2); break;
537 case ROOT_route_element: SET(EPILOG); break;
540 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</route_element>' expected.",yytext);
541 . FAIL("Unexpected character `%c': `</route_element>' expected.",yytext[0]);
542 <<EOF>> FAIL("Premature EOF: `</route_element>' expected.");
545 <ROOT_process,S_platform_description_2,S_platform_description_1,S_platform_description>"<process"{s} {
546 A_process_host = NULL;
547 A_process_function = NULL;
552 "host"{Eq}\' ENTER(VALUE1); BUFFERSET(A_process_host);
553 "host"{Eq}\" ENTER(VALUE2); BUFFERSET(A_process_host);
555 "function"{Eq}\' ENTER(VALUE1); BUFFERSET(A_process_function);
556 "function"{Eq}\" ENTER(VALUE2); BUFFERSET(A_process_function);
559 if (!A_process_host) FAIL("Required attribute `host' not set for `process' element.");
560 if (!A_process_function) FAIL("Required attribute `function' not set for `process' element.");
561 LEAVE; STag_process();pcdata = NULL; ENTER(S_process);
564 if (!A_process_host) FAIL("Required attribute `host' not set for `process' element.");
565 if (!A_process_function) FAIL("Required attribute `function' not set for `process' element.");
566 LEAVE; STag_process(); pcdata = NULL; ETag_process();
568 case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
569 case ROOT_process: SET(EPILOG); break;
572 . FAIL("Unexpected character `%c' in attribute list of process element.", yytext[0]);
573 {Name} FAIL("Bad attribute `%s' in `process' element start tag.",yytext);
574 <<EOF>> FAIL("EOF in attribute list of `process' element.");
577 <S_process,E_process,S_process_2>{
582 case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
583 case ROOT_process: SET(EPILOG); break;
586 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</process>' expected.",yytext);
587 . FAIL("Unexpected character `%c': `</process>' expected.",yytext[0]);
588 <<EOF>> FAIL("Premature EOF: `</process>' expected.");
591 <ROOT_argument,S_process_1,S_process,S_process_2>"<argument"{s} {
592 A_argument_value = NULL;
597 "value"{Eq}\' ENTER(VALUE1); BUFFERSET(A_argument_value);
598 "value"{Eq}\" ENTER(VALUE2); BUFFERSET(A_argument_value);
601 if (!A_argument_value) FAIL("Required attribute `value' not set for `argument' element.");
602 LEAVE; STag_argument();pcdata = NULL; ENTER(E_argument);
605 if (!A_argument_value) FAIL("Required attribute `value' not set for `argument' element.");
606 LEAVE; STag_argument(); pcdata = NULL; ETag_argument();
608 case ROOT_argument: SET(EPILOG); break;
609 case S_process_1: case S_process: case S_process_2: SET(S_process_2); break;
612 . FAIL("Unexpected character `%c' in attribute list of argument element.", yytext[0]);
613 {Name} FAIL("Bad attribute `%s' in `argument' element start tag.",yytext);
614 <<EOF>> FAIL("EOF in attribute list of `argument' element.");
622 case ROOT_argument: SET(EPILOG); break;
623 case S_process_1: case S_process: case S_process_2: SET(S_process_2); break;
626 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</argument>' expected.",yytext);
627 . FAIL("Unexpected character `%c': `</argument>' expected.",yytext[0]);
628 <<EOF>> FAIL("Premature EOF: `</argument>' expected.");
631 /* EPILOG: after the root element. */
634 . FAIL("Unexpected character `%c' after document.", yytext[0]);
638 /* CHARACTER DATA. */
640 <IMPOSSIBLE,VALUE1,VALUE2>{
641 /* Non-defined standard entities... */
642 "&" BUFFERPUTC('&');
643 "<" BUFFERPUTC('<');
644 ">" BUFFERPUTC('>');
645 "'" BUFFERPUTC('\'');
646 """ BUFFERPUTC('"');
648 /* Character entities. */
649 "&#"[[:digit:]]+";" BUFFERPUTC((unsigned char)atoi(yytext+2));
650 "&#x"[[:xdigit:]]+";" BUFFERPUTC((unsigned char)strtol(yytext+3,NULL,16));
653 <IMPOSSIBLE,VALUE1,VALUE2,CDATA>{
657 "\n\r" BUFFERPUTC('\n');
661 "<![CDATA[" ENTER(CDATA);
662 "]""]>" FAIL("Unexpected `]""]>' in character data.");
666 \' BUFFERDONE; LEAVE;
667 <<EOF>> FAIL("EOF in literal (\"'\" expected).");
671 \" BUFFERDONE; LEAVE;
672 <<EOF>> FAIL("EOF in literal (`\"' expected).");
675 <IMPOSSIBLE,VALUE1,VALUE2>{
676 [^<&] BUFFERPUTC(yytext[0]);
677 [<&] FAIL("Spurious `%c' in character data.",yytext[0]);
682 "]""]" BUFFERPUTC(yytext[0]); BUFFERPUTC(yytext[1]);
683 . BUFFERPUTC(yytext[0]);
684 <<EOF>> FAIL("EOF in CDATA section.");
687 /* Impossible rules to avoid warnings from flex(1). */
689 <INITIAL,IMPOSSIBLE>{
690 .|[\n] FAIL("The Impossible Happened: INITIAL or IMPOSSIBLE state entered?");
695 /* Element context stack lookup. */
696 int element_context(int i)
698 return (0<i && i<yy_start_stack_depth
699 ? yy_start_stack[yy_start_stack_ptr - i]
704 void print_yy_stack(char* fmt, ...)
706 int i = 0; va_list ap; va_start(ap, fmt);
707 vfprintf(stderr, fmt, ap);
708 for (i=1; i<yy_start_stack_ptr; i++)
709 fprintf(stderr, "%s/", statenames[yy_start_stack[i] ]);
710 fprintf(stderr,"%s\n", statenames[YY_START]);
714 static void debug_enter(int state, const char* statename) {
715 yy_push_state(state);
716 if (yy_flex_debug) print_yy_stack("--ENTER(%s) : ",statename);
719 static void debug_leave(void) {
720 if (yy_flex_debug) print_yy_stack("--LEAVE : ");
724 static void debug_set(int state, const char* statename) {
726 if (yy_flex_debug) print_yy_stack("--SET(%s) : ",statename);
731 static int fail(const char* fmt, ...)
733 va_list ap; va_start(ap, fmt);
734 #ifdef FLEXML_yylineno
735 fprintf(stderr, "Invalid XML (XML input line %d, state %d): ", yylineno, YY_START);
737 fprintf(stderr, "Invalid XML (state %d): ",YY_START);
739 vfprintf(stderr, fmt, ap);
740 fprintf(stderr, "\n");