1 /* Validating XML processor for surfxml.dtd.
2 * Generated 2005/02/13 20:04:21.
4 * This program was generated with the FleXML XML processor generator,
5 * (Id: flexml.pl,v 1.39 2005/02/13 18:12:19 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.24 2005/02/10 11:42:39 mquinson Exp $";
29 const char rcs_flexml[] =
30 "$" "Id: flexml.pl,v 1.39 2005/02/13 18:12:19 legranda Exp $";
40 /* Generated definitions. */
41 #define FLEXML_yylineno
42 #define FLEXML_BUFFERSTACKSIZE 10000000
44 /* XML processor api. */
45 #include "surf/surfxml.h"
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_impact_on_src A_route_impact_on_src;
56 AT_route_src A_route_src;
57 AT_network_link_latency_file A_network_link_latency_file;
58 AT_cpu_max_outgoing_rate A_cpu_max_outgoing_rate;
59 AT_route_impact_on_dst_with_other_send A_route_impact_on_dst_with_other_send;
60 AT_cpu_interference_send_recv A_cpu_interference_send_recv;
61 AT_cpu_availability A_cpu_availability;
62 AT_route_impact_on_dst A_route_impact_on_dst;
63 AT_cpu_interference_recv A_cpu_interference_recv;
64 AT_route_impact_on_src_with_other_recv A_route_impact_on_src_with_other_recv;
65 AT_network_link_name A_network_link_name;
66 AT_route_element_name A_route_element_name;
67 AT_cpu_power A_cpu_power;
68 AT_include_file A_include_file;
69 AT_process_function A_process_function;
70 AT_route_dst A_route_dst;
71 AT_cpu_state A_cpu_state;
72 AT_network_link_latency A_network_link_latency;
73 AT_network_link_state_file A_network_link_state_file;
74 AT_cpu_interference_send A_cpu_interference_send;
75 AT_cpu_state_file A_cpu_state_file;
76 AT_network_link_bandwidth_file A_network_link_bandwidth_file;
80 # define ENTER(state) debug_enter(state,#state)
81 # define LEAVE debug_leave()
82 # define SET(state) debug_set(state,#state)
83 static void debug_enter(int, const char*);
84 static void debug_leave(void);
85 static void debug_set(int, const char*);
87 # define ENTER(state) (yy_push_state(state))
88 # define LEAVE (yy_pop_state())
89 # define SET(state) BEGIN(state)
92 /* Generic actions. */
94 #define SUCCEED return 0
96 #define FAIL return fail
97 static int fail(const char*, ...);
98 const char * parse_err_msg(void);
100 /* Text buffer stack handling. */
101 char bufferstack[FLEXML_BUFFERSTACKSIZE];
102 char* limit = bufferstack + FLEXML_BUFFERSTACKSIZE;
103 typedef struct BufferLast_s {
104 struct BufferLast_s *old; char* saved; char new1[1];
106 BufferLast* last = (BufferLast*)0;
107 char* next = bufferstack;
109 #define BUFFERSET(P) (P = next)
110 #define BUFFERPUTC(C) (assert(next<limit), *(next++) = (C))
111 #define BUFFERDONE (BUFFERPUTC('\0'))
113 #define BUFFERLITERAL(C,P) bufferliteral(C,&(P),yytext)
114 static void bufferliteral(char c, const char** pp, char* text)
116 char *s = strchr(text,c), *e = strrchr(text,c);
117 assert(s <= e); BUFFERSET(*pp);
119 if (isspace(*s)) { BUFFERPUTC(' '); while (isspace(*s)) ++s; }
125 #ifdef FLEXML_HasMixed
126 static void pushbuffer(char* p)
128 BufferLast* l = (BufferLast*)next;
129 assert(next < limit);
136 static char* popbuffer(void)
138 BufferLast* l = last;
139 assert(last != (BufferLast*)0);
146 /* General internal entities are `unput' back onto the input stream... */
147 #define ENTITYTEXT(T) \
148 { char *s = (T), *e = s+strlen(s);\
149 while (--e >= s) { unput(*e); }}
152 /* Flex standard options. */
154 %option noyy_top_state
160 /* Flex user-requested options. */
164 /* XML character classes (currently restricted to ASCII). */
166 /* "Common syntactic structures." */
170 /* "Names and Tokens." */
171 NameChar [A-Za-z0-9.:_-]
172 Name [A-Za-z_:]{NameChar}*
173 Names {Name}({S}{Name})*
174 Nmtoken ({NameChar})+
175 Nmtokens {Nmtoken}({S}{Nmtoken})*
178 VersionNum [a-zA-Z0-9_.:-]+
180 Literal \'[^'']*\'|\"[^""]*\"
182 /* Parser states (flex `exclusive start conditions'):
184 * PROLOG the XML prolog of the document before <?xml...>
185 * DOCTYPE the XML prolog of the document after <?xml...>
186 * EPILOG after the root element
187 * INCOMMENT inside an XML comment <!--....-->
188 * INPI inside an XML PI <?...?>
189 * VALUE1 inside a '...'-delimited literal
190 * VALUE2 inside a "..."-delimited literal
191 * CDATA inside a <![CDATA[...]]> section.
192 * ROOT_<tag> expect root element <tag>
193 * AL_<tag> inside the attribute list for <tag>
194 * IN_<tag> inside a <tag> with element contents (ready for end tag)
195 * IMPOSSIBLE dummy to permit disabling rules; must be last
197 %x PROLOG DOCTYPE EPILOG INCOMMENT INPI VALUE1 VALUE2 CDATA
198 %x ROOT_platform_description AL_platform_description S_platform_description S_platform_description_1 S_platform_description_2 E_platform_description
199 %x ROOT_include AL_include S_include S_include_1 S_include_2 E_include
200 %x ROOT_cpu AL_cpu E_cpu
201 %x ROOT_network_link AL_network_link E_network_link
202 %x ROOT_route AL_route S_route S_route_1 S_route_2 E_route
203 %x ROOT_route_element AL_route_element E_route_element
204 %x ROOT_process AL_process S_process S_process_1 S_process_2 E_process
205 %x ROOT_argument AL_argument E_argument
210 const char* *statenames=NULL;
215 /* Bypass Flex's default INITIAL state and begin by parsing the XML prolog. */
218 if(!statenames) statenames= (const char **)calloc(IMPOSSIBLE,sizeof(char*));
219 statenames[PROLOG] = NULL;
220 statenames[DOCTYPE] = NULL;
221 statenames[EPILOG] = NULL;
222 statenames[INCOMMENT] = NULL;
223 statenames[INPI] = NULL;
224 statenames[VALUE1] = NULL;
225 statenames[VALUE2] = NULL;
226 statenames[CDATA] = NULL;
227 statenames[ROOT_platform_description] = NULL;
228 statenames[AL_platform_description] = NULL;
229 statenames[S_platform_description] = "platform_description";
230 statenames[S_platform_description_1] = "platform_description";
231 statenames[S_platform_description_2] = "platform_description";
232 statenames[E_platform_description] = "platform_description";
233 statenames[ROOT_include] = NULL;
234 statenames[AL_include] = NULL;
235 statenames[S_include] = "include";
236 statenames[S_include_1] = "include";
237 statenames[S_include_2] = "include";
238 statenames[E_include] = "include";
239 statenames[ROOT_cpu] = NULL;
240 statenames[AL_cpu] = NULL;
241 statenames[E_cpu] = "cpu";
242 statenames[ROOT_network_link] = NULL;
243 statenames[AL_network_link] = NULL;
244 statenames[E_network_link] = "network_link";
245 statenames[ROOT_route] = NULL;
246 statenames[AL_route] = NULL;
247 statenames[S_route] = "route";
248 statenames[S_route_1] = "route";
249 statenames[S_route_2] = "route";
250 statenames[E_route] = "route";
251 statenames[ROOT_route_element] = NULL;
252 statenames[AL_route_element] = NULL;
253 statenames[E_route_element] = "route_element";
254 statenames[ROOT_process] = NULL;
255 statenames[AL_process] = NULL;
256 statenames[S_process] = "process";
257 statenames[S_process_1] = "process";
258 statenames[S_process_2] = "process";
259 statenames[E_process] = "process";
260 statenames[ROOT_argument] = NULL;
261 statenames[AL_argument] = NULL;
262 statenames[E_argument] = "argument";
264 /* COMMENTS and PIs: handled uniformly for efficiency. */
266 <ROOT_platform_description,AL_platform_description,S_platform_description,S_platform_description_1,S_platform_description_2,E_platform_description,ROOT_include,AL_include,S_include,S_include_1,S_include_2,E_include,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>{
267 "<!--" ENTER(INCOMMENT);
275 <<EOF>> FAIL("EOF in comment.");
281 <<EOF>> FAIL("EOF in PI (processing instruction).");
284 /* SPACES: skipped uniformly */
286 <ROOT_platform_description,AL_platform_description,S_platform_description,S_platform_description_1,S_platform_description_2,E_platform_description,ROOT_include,AL_include,S_include,S_include_1,S_include_2,E_include,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;
288 /* PROLOG: determine root element and process it. */
291 "<?xml"({S}version{Eq}(\'{VersionNum}\'|\"{VersionNum}\"))?({S}encoding{Eq}(\'[^']*\'|\"[^"]*\"))?"?>" SET(DOCTYPE);
292 "<?xml"[^>]*">" FAIL("Bad declaration %s.",yytext);
296 "<!DOCTYPE"{S}"argument"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_argument);
297 "<!DOCTYPE"{S}"route_element"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_route_element);
298 "<!DOCTYPE"{S}"cpu"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_cpu);
299 "<!DOCTYPE"{S}"include"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_include);
300 "<!DOCTYPE"{S}"route"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_route);
301 "<!DOCTYPE"{S}"platform_description"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_platform_description);
302 "<!DOCTYPE"{S}"network_link"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_network_link);
303 "<!DOCTYPE"{S}"process"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_process);
304 "<!"[^>-][^>]*">" FAIL("Bad declaration %s.",yytext);
305 . FAIL("Unexpected character `%c' in prolog.", yytext[0]);
306 <<EOF>> FAIL("EOF in prolog.");
309 /* RULES DERIVED FROM DTD. */
311 /* <!-- Small DTD for SURF based tools. --> */
313 <ROOT_platform_description>"<platform_description"{s} {
314 ENTER(AL_platform_description);
317 <AL_platform_description>{
319 LEAVE; STag_platform_description();pcdata = NULL; ENTER(S_platform_description);
322 LEAVE; STag_platform_description(); pcdata = NULL; ETag_platform_description();
324 case ROOT_platform_description: SET(EPILOG); break;
327 . FAIL("Unexpected character `%c' in attribute list of platform_description element.", yytext[0]);
328 {Name} FAIL("Bad attribute `%s' in `platform_description' element start tag.",yytext);
329 <<EOF>> FAIL("EOF in attribute list of `platform_description' element.");
332 <E_platform_description,S_platform_description_2,S_platform_description>{
333 "</platform_description"{s}">" {
335 ETag_platform_description();
337 case ROOT_platform_description: SET(EPILOG); break;
340 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</platform_description>' expected.",yytext);
341 . FAIL("Unexpected character `%c': `</platform_description>' expected.",yytext[0]);
342 <<EOF>> FAIL("Premature EOF: `</platform_description>' expected.");
345 <ROOT_include,S_platform_description_2,S_include,S_include_2,S_platform_description_1,S_include_1,S_platform_description>"<include"{s} {
346 A_include_file = NULL;
351 "file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_include_file);
352 "file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_include_file);
355 if (!A_include_file) FAIL("Required attribute `file' not set for `include' element.");
356 LEAVE; STag_include();pcdata = NULL; ENTER(S_include);
359 if (!A_include_file) FAIL("Required attribute `file' not set for `include' element.");
360 LEAVE; STag_include(); pcdata = NULL; ETag_include();
362 case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
363 case S_include: case S_include_2: case S_include_1: SET(S_include_2); break;
364 case ROOT_include: SET(EPILOG); break;
367 . FAIL("Unexpected character `%c' in attribute list of include element.", yytext[0]);
368 {Name} FAIL("Bad attribute `%s' in `include' element start tag.",yytext);
369 <<EOF>> FAIL("EOF in attribute list of `include' element.");
372 <E_include,S_include,S_include_2>{
377 case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
378 case S_include: case S_include_2: case S_include_1: SET(S_include_2); break;
379 case ROOT_include: SET(EPILOG); break;
382 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</include>' expected.",yytext);
383 . FAIL("Unexpected character `%c': `</include>' expected.",yytext[0]);
384 <<EOF>> FAIL("Premature EOF: `</include>' expected.");
387 <ROOT_cpu,S_platform_description_2,S_include,S_include_2,S_platform_description_1,S_include_1,S_platform_description>"<cpu"{s} {
390 A_cpu_availability = "1.0";
391 A_cpu_availability_file = NULL;
392 A_cpu_state = A_cpu_state_ON;
393 A_cpu_state_file = NULL;
394 A_cpu_interference_send = "1.0";
395 A_cpu_interference_recv = "1.0";
396 A_cpu_interference_send_recv = "1.0";
397 A_cpu_max_outgoing_rate = "-1.0";
402 "name"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_name);
403 "name"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_name);
405 "power"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_power);
406 "power"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_power);
408 "availability"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_availability);
409 "availability"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_availability);
411 "availability_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_availability_file);
412 "availability_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_availability_file);
415 "state"{Eq}"\"ON\"" A_cpu_state = A_cpu_state_ON;
417 "state"{Eq}"\"OFF\"" A_cpu_state = A_cpu_state_OFF;
419 "state_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_state_file);
420 "state_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_state_file);
422 "interference_send"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_interference_send);
423 "interference_send"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_interference_send);
425 "interference_recv"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_interference_recv);
426 "interference_recv"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_interference_recv);
428 "interference_send_recv"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_interference_send_recv);
429 "interference_send_recv"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_interference_send_recv);
431 "max_outgoing_rate"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_max_outgoing_rate);
432 "max_outgoing_rate"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_max_outgoing_rate);
435 if (!A_cpu_name) FAIL("Required attribute `name' not set for `cpu' element.");
436 if (!A_cpu_power) FAIL("Required attribute `power' not set for `cpu' element.");
437 LEAVE; STag_cpu();pcdata = NULL; ENTER(E_cpu);
440 if (!A_cpu_name) FAIL("Required attribute `name' not set for `cpu' element.");
441 if (!A_cpu_power) FAIL("Required attribute `power' not set for `cpu' element.");
442 LEAVE; STag_cpu(); pcdata = NULL; ETag_cpu();
444 case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
445 case S_include: case S_include_2: case S_include_1: SET(S_include_2); break;
446 case ROOT_cpu: SET(EPILOG); break;
449 . FAIL("Unexpected character `%c' in attribute list of cpu element.", yytext[0]);
450 {Name} FAIL("Bad attribute `%s' in `cpu' element start tag.",yytext);
451 <<EOF>> FAIL("EOF in attribute list of `cpu' element.");
459 case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
460 case S_include: case S_include_2: case S_include_1: SET(S_include_2); break;
461 case ROOT_cpu: SET(EPILOG); break;
464 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</cpu>' expected.",yytext);
465 . FAIL("Unexpected character `%c': `</cpu>' expected.",yytext[0]);
466 <<EOF>> FAIL("Premature EOF: `</cpu>' expected.");
469 <ROOT_network_link,S_platform_description_2,S_include,S_include_2,S_platform_description_1,S_include_1,S_platform_description>"<network_link"{s} {
470 A_network_link_name = NULL;
471 A_network_link_bandwidth = NULL;
472 A_network_link_bandwidth_file = NULL;
473 A_network_link_latency = "0.0";
474 A_network_link_latency_file = NULL;
475 A_network_link_state = A_network_link_state_ON;
476 A_network_link_state_file = NULL;
477 ENTER(AL_network_link);
481 "name"{Eq}\' ENTER(VALUE1); BUFFERSET(A_network_link_name);
482 "name"{Eq}\" ENTER(VALUE2); BUFFERSET(A_network_link_name);
484 "bandwidth"{Eq}\' ENTER(VALUE1); BUFFERSET(A_network_link_bandwidth);
485 "bandwidth"{Eq}\" ENTER(VALUE2); BUFFERSET(A_network_link_bandwidth);
487 "bandwidth_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_network_link_bandwidth_file);
488 "bandwidth_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_network_link_bandwidth_file);
490 "latency"{Eq}\' ENTER(VALUE1); BUFFERSET(A_network_link_latency);
491 "latency"{Eq}\" ENTER(VALUE2); BUFFERSET(A_network_link_latency);
493 "latency_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_network_link_latency_file);
494 "latency_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_network_link_latency_file);
497 "state"{Eq}"\"ON\"" A_network_link_state = A_network_link_state_ON;
499 "state"{Eq}"\"OFF\"" A_network_link_state = A_network_link_state_OFF;
501 "state_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_network_link_state_file);
502 "state_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_network_link_state_file);
505 if (!A_network_link_name) FAIL("Required attribute `name' not set for `network_link' element.");
506 if (!A_network_link_bandwidth) FAIL("Required attribute `bandwidth' not set for `network_link' element.");
507 LEAVE; STag_network_link();pcdata = NULL; ENTER(E_network_link);
510 if (!A_network_link_name) FAIL("Required attribute `name' not set for `network_link' element.");
511 if (!A_network_link_bandwidth) FAIL("Required attribute `bandwidth' not set for `network_link' element.");
512 LEAVE; STag_network_link(); pcdata = NULL; ETag_network_link();
514 case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
515 case S_include: case S_include_2: case S_include_1: SET(S_include_2); break;
516 case ROOT_network_link: SET(EPILOG); break;
519 . FAIL("Unexpected character `%c' in attribute list of network_link element.", yytext[0]);
520 {Name} FAIL("Bad attribute `%s' in `network_link' element start tag.",yytext);
521 <<EOF>> FAIL("EOF in attribute list of `network_link' element.");
525 "</network_link"{s}">" {
529 case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
530 case S_include: case S_include_2: case S_include_1: SET(S_include_2); break;
531 case ROOT_network_link: SET(EPILOG); break;
534 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</network_link>' expected.",yytext);
535 . FAIL("Unexpected character `%c': `</network_link>' expected.",yytext[0]);
536 <<EOF>> FAIL("Premature EOF: `</network_link>' expected.");
539 <ROOT_route,S_platform_description_2,S_include,S_include_2,S_platform_description_1,S_include_1,S_platform_description>"<route"{s} {
542 A_route_impact_on_src = "0.0";
543 A_route_impact_on_dst = "0.0";
544 A_route_impact_on_src_with_other_recv = "0.0";
545 A_route_impact_on_dst_with_other_send = "0.0";
550 "src"{Eq}\' ENTER(VALUE1); BUFFERSET(A_route_src);
551 "src"{Eq}\" ENTER(VALUE2); BUFFERSET(A_route_src);
553 "dst"{Eq}\' ENTER(VALUE1); BUFFERSET(A_route_dst);
554 "dst"{Eq}\" ENTER(VALUE2); BUFFERSET(A_route_dst);
556 "impact_on_src"{Eq}\' ENTER(VALUE1); BUFFERSET(A_route_impact_on_src);
557 "impact_on_src"{Eq}\" ENTER(VALUE2); BUFFERSET(A_route_impact_on_src);
559 "impact_on_dst"{Eq}\' ENTER(VALUE1); BUFFERSET(A_route_impact_on_dst);
560 "impact_on_dst"{Eq}\" ENTER(VALUE2); BUFFERSET(A_route_impact_on_dst);
562 "impact_on_src_with_other_recv"{Eq}\' ENTER(VALUE1); BUFFERSET(A_route_impact_on_src_with_other_recv);
563 "impact_on_src_with_other_recv"{Eq}\" ENTER(VALUE2); BUFFERSET(A_route_impact_on_src_with_other_recv);
565 "impact_on_dst_with_other_send"{Eq}\' ENTER(VALUE1); BUFFERSET(A_route_impact_on_dst_with_other_send);
566 "impact_on_dst_with_other_send"{Eq}\" ENTER(VALUE2); BUFFERSET(A_route_impact_on_dst_with_other_send);
569 if (!A_route_src) FAIL("Required attribute `src' not set for `route' element.");
570 if (!A_route_dst) FAIL("Required attribute `dst' not set for `route' element.");
571 LEAVE; STag_route();pcdata = NULL; ENTER(S_route);
574 if (!A_route_src) FAIL("Required attribute `src' not set for `route' element.");
575 if (!A_route_dst) FAIL("Required attribute `dst' not set for `route' element.");
576 LEAVE; STag_route(); pcdata = NULL; ETag_route();
578 case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
579 case S_include: case S_include_2: case S_include_1: SET(S_include_2); break;
580 case ROOT_route: SET(EPILOG); break;
583 . FAIL("Unexpected character `%c' in attribute list of route element.", yytext[0]);
584 {Name} FAIL("Bad attribute `%s' in `route' element start tag.",yytext);
585 <<EOF>> FAIL("EOF in attribute list of `route' element.");
588 <S_route,S_route_2,E_route>{
593 case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
594 case S_include: case S_include_2: case S_include_1: SET(S_include_2); break;
595 case ROOT_route: SET(EPILOG); break;
598 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</route>' expected.",yytext);
599 . FAIL("Unexpected character `%c': `</route>' expected.",yytext[0]);
600 <<EOF>> FAIL("Premature EOF: `</route>' expected.");
603 <ROOT_route_element,S_route_1,S_route,S_route_2>"<route_element"{s} {
604 A_route_element_name = NULL;
605 ENTER(AL_route_element);
609 "name"{Eq}\' ENTER(VALUE1); BUFFERSET(A_route_element_name);
610 "name"{Eq}\" ENTER(VALUE2); BUFFERSET(A_route_element_name);
613 if (!A_route_element_name) FAIL("Required attribute `name' not set for `route_element' element.");
614 LEAVE; STag_route_element();pcdata = NULL; ENTER(E_route_element);
617 if (!A_route_element_name) FAIL("Required attribute `name' not set for `route_element' element.");
618 LEAVE; STag_route_element(); pcdata = NULL; ETag_route_element();
620 case S_route_1: case S_route: case S_route_2: SET(S_route_2); break;
621 case ROOT_route_element: SET(EPILOG); break;
624 . FAIL("Unexpected character `%c' in attribute list of route_element element.", yytext[0]);
625 {Name} FAIL("Bad attribute `%s' in `route_element' element start tag.",yytext);
626 <<EOF>> FAIL("EOF in attribute list of `route_element' element.");
630 "</route_element"{s}">" {
632 ETag_route_element();
634 case S_route_1: case S_route: case S_route_2: SET(S_route_2); break;
635 case ROOT_route_element: SET(EPILOG); break;
638 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</route_element>' expected.",yytext);
639 . FAIL("Unexpected character `%c': `</route_element>' expected.",yytext[0]);
640 <<EOF>> FAIL("Premature EOF: `</route_element>' expected.");
643 <ROOT_process,S_platform_description_2,S_include,S_include_2,S_platform_description_1,S_include_1,S_platform_description>"<process"{s} {
644 A_process_host = NULL;
645 A_process_function = NULL;
650 "host"{Eq}\' ENTER(VALUE1); BUFFERSET(A_process_host);
651 "host"{Eq}\" ENTER(VALUE2); BUFFERSET(A_process_host);
653 "function"{Eq}\' ENTER(VALUE1); BUFFERSET(A_process_function);
654 "function"{Eq}\" ENTER(VALUE2); BUFFERSET(A_process_function);
657 if (!A_process_host) FAIL("Required attribute `host' not set for `process' element.");
658 if (!A_process_function) FAIL("Required attribute `function' not set for `process' element.");
659 LEAVE; STag_process();pcdata = NULL; ENTER(S_process);
662 if (!A_process_host) FAIL("Required attribute `host' not set for `process' element.");
663 if (!A_process_function) FAIL("Required attribute `function' not set for `process' element.");
664 LEAVE; STag_process(); pcdata = NULL; ETag_process();
666 case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
667 case S_include: case S_include_2: case S_include_1: SET(S_include_2); break;
668 case ROOT_process: SET(EPILOG); break;
671 . FAIL("Unexpected character `%c' in attribute list of process element.", yytext[0]);
672 {Name} FAIL("Bad attribute `%s' in `process' element start tag.",yytext);
673 <<EOF>> FAIL("EOF in attribute list of `process' element.");
676 <S_process,E_process,S_process_2>{
681 case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
682 case S_include: case S_include_2: case S_include_1: SET(S_include_2); break;
683 case ROOT_process: SET(EPILOG); break;
686 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</process>' expected.",yytext);
687 . FAIL("Unexpected character `%c': `</process>' expected.",yytext[0]);
688 <<EOF>> FAIL("Premature EOF: `</process>' expected.");
691 <ROOT_argument,S_process_1,S_process,S_process_2>"<argument"{s} {
692 A_argument_value = NULL;
697 "value"{Eq}\' ENTER(VALUE1); BUFFERSET(A_argument_value);
698 "value"{Eq}\" ENTER(VALUE2); BUFFERSET(A_argument_value);
701 if (!A_argument_value) FAIL("Required attribute `value' not set for `argument' element.");
702 LEAVE; STag_argument();pcdata = NULL; ENTER(E_argument);
705 if (!A_argument_value) FAIL("Required attribute `value' not set for `argument' element.");
706 LEAVE; STag_argument(); pcdata = NULL; ETag_argument();
708 case ROOT_argument: SET(EPILOG); break;
709 case S_process_1: case S_process: case S_process_2: SET(S_process_2); break;
712 . FAIL("Unexpected character `%c' in attribute list of argument element.", yytext[0]);
713 {Name} FAIL("Bad attribute `%s' in `argument' element start tag.",yytext);
714 <<EOF>> FAIL("EOF in attribute list of `argument' element.");
722 case ROOT_argument: SET(EPILOG); break;
723 case S_process_1: case S_process: case S_process_2: SET(S_process_2); break;
726 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</argument>' expected.",yytext);
727 . FAIL("Unexpected character `%c': `</argument>' expected.",yytext[0]);
728 <<EOF>> FAIL("Premature EOF: `</argument>' expected.");
731 /* EPILOG: after the root element. */
734 . {SET(PROLOG); yyless(0); return -1;}
738 /* CHARACTER DATA. */
740 <IMPOSSIBLE,VALUE1,VALUE2>{
741 /* Non-defined standard entities... */
742 "&" BUFFERPUTC('&');
743 "<" BUFFERPUTC('<');
744 ">" BUFFERPUTC('>');
745 "'" BUFFERPUTC('\'');
746 """ BUFFERPUTC('"');
748 /* Character entities. */
749 "&#"[[:digit:]]+";" BUFFERPUTC((unsigned char)atoi(yytext+2));
750 "&#x"[[:xdigit:]]+";" BUFFERPUTC((unsigned char)strtol(yytext+3,NULL,16));
753 <IMPOSSIBLE,VALUE1,VALUE2,CDATA>{
757 "\n\r" BUFFERPUTC('\n');
761 "<![CDATA[" ENTER(CDATA);
762 "]""]>" FAIL("Unexpected `]""]>' in character data.");
766 \' BUFFERDONE; LEAVE;
767 <<EOF>> FAIL("EOF in literal (\"'\" expected).");
771 \" BUFFERDONE; LEAVE;
772 <<EOF>> FAIL("EOF in literal (`\"' expected).");
775 <IMPOSSIBLE,VALUE1,VALUE2>{
776 [^<&] BUFFERPUTC(yytext[0]);
777 [<&] FAIL("Spurious `%c' in character data.",yytext[0]);
782 /* "]""]" BUFFERPUTC(yytext[0]); BUFFERPUTC(yytext[1]); */
783 . BUFFERPUTC(yytext[0]);
784 <<EOF>> FAIL("EOF in CDATA section.");
787 /* Impossible rules to avoid warnings from flex(1). */
788 /* Ideally, this should be replaced by code in flexml.pl that
789 generates just the states not covered by other rules. */
791 .|[\n] FAIL("Syntax error on character `%c'.", yytext[0]);
796 /* Element context stack lookup. */
797 int element_context(int i)
799 return (0<i && i<yy_start_stack_depth
800 ? yy_start_stack[yy_start_stack_ptr - i]
805 void print_yy_stack(char* fmt, ...)
807 int i = 0; va_list ap; va_start(ap, fmt);
808 vfprintf(stderr, fmt, ap);
809 for (i=1; i<yy_start_stack_ptr; i++)
810 fprintf(stderr, "%s/", statenames[yy_start_stack[i] ]);
811 fprintf(stderr,"%s\n", statenames[YY_START]);
815 static void debug_enter(int state, const char* statename) {
816 yy_push_state(state);
817 if (yy_flex_debug) print_yy_stack("--ENTER(%s) : ",statename);
820 static void debug_leave(void) {
821 if (yy_flex_debug) print_yy_stack("--LEAVE : ");
825 static void debug_set(int state, const char* statename) {
827 if (yy_flex_debug) print_yy_stack("--SET(%s) : ",statename);
831 enum {flexml_max_err_msg_size = 512};
833 static char flexml_err_msg[flexml_max_err_msg_size];
834 const char * parse_err_msg()
836 return flexml_err_msg;
839 static void reset_parse_err_msg()
841 flexml_err_msg[0] = '\0';
845 static int fail(const char* fmt, ...)
847 int chars_left, used;
848 va_list ap; va_start(ap, fmt);
849 #ifdef FLEXML_yylineno
850 used = sprintf(flexml_err_msg,
851 "Invalid XML (XML input line %d, state %d): ",
854 used = sprintf(flexml_err_msg,
855 "Invalid XML (state %d): ",
858 chars_left = flexml_max_err_msg_size - used - 1;
859 vsnprintf(flexml_err_msg + used, chars_left, fmt, ap);
862 #ifndef FLEXML_quiet_parser
863 /* print directly to sdterr */
864 fprintf(stderr, "%s\n", flexml_err_msg);
865 flexml_err_msg[0] = '\0';