1 /* Validating XML processor for surfxml.dtd.
2 * Generated 2006/03/20 15:32:38.
4 * This program was generated with the FleXML XML processor generator.
5 * FleXML is Copyright © 1999-2005 Kristoffer Rose. All rights reserved.
6 * (Id: flexml.pl,v 1.45 2006/03/03 19:25:46 wdowling Exp).
8 * There are two, intertwined parts to this program, part A and part B.
13 * Some parts, here collectively called "Part A", are found in the
14 * FleXML package. They are Copyright © 1999-2005 Kristoffer Rose.
15 * All rights reserved.
17 * You can redistribute, use, perform, display and/or modify "Part A"
18 * provided the following two conditions hold:
20 * 1. The program is distributed WITHOUT ANY WARRANTY from the author of
21 * FleXML; without even the implied warranty of MERCHANTABILITY or
22 * FITNESS FOR A PARTICULAR PURPOSE.
24 * 2. The program distribution conditions do not in any way affect the
25 * distribution conditions of the FleXML system used to generate this
26 * file or any version of FleXML derived from that system.
28 * Notice that these are explicit rights granted to you for files
29 * generated by the FleXML system. For your rights in connection with
30 * the FleXML system itself please consult the GNU General Public License.
35 * The other parts, here collectively called "Part B", and which came
36 * from the DTD used by FleXML to generate this program, can be
37 * distributed (or not, as the case may be) under the terms of whoever
38 * wrote them, provided these terms respect and obey the two conditions
39 * above under the heading "Part A".
41 * The author of and contributors to FleXML specifically disclaim
42 * any copyright interest in "Part B", unless "Part B" was written
43 * by the author of or contributors to FleXML.
49 /* Version strings. */
50 const char rcs_surfxml_flexml_skeleton[] =
51 "$" "Id: skel,v 1.26 2005/02/23 22:22:20 wdowling Exp $";
52 const char rcs_surfxml_flexml[] =
53 "$" "Id: flexml.pl,v 1.45 2006/03/03 19:25:46 wdowling Exp $";
63 /* Generated definitions. */
64 #define FLEXML_yylineno
65 #define FLEXML_BUFFERSTACKSIZE 1000000
67 /* XML processor api. */
68 /* FleXML-provided data. */
70 AT_network_link_bandwidth A_network_link_bandwidth;
71 AT_cpu_name A_cpu_name;
72 AT_process_kill_time A_process_kill_time;
73 AT_network_link_state A_network_link_state;
74 AT_argument_value A_argument_value;
75 AT_cpu_availability_file A_cpu_availability_file;
76 AT_process_host A_process_host;
77 AT_route_impact_on_src A_route_impact_on_src;
78 AT_route_src A_route_src;
79 AT_network_link_latency_file A_network_link_latency_file;
80 AT_cpu_max_outgoing_rate A_cpu_max_outgoing_rate;
81 AT_route_impact_on_dst_with_other_send A_route_impact_on_dst_with_other_send;
82 AT_cpu_interference_send_recv A_cpu_interference_send_recv;
83 AT_cpu_availability A_cpu_availability;
84 AT_route_impact_on_dst A_route_impact_on_dst;
85 AT_cpu_interference_recv A_cpu_interference_recv;
86 AT_route_impact_on_src_with_other_recv A_route_impact_on_src_with_other_recv;
87 AT_network_link_name A_network_link_name;
88 AT_route_element_name A_route_element_name;
89 AT_cpu_power A_cpu_power;
90 AT_process_start_time A_process_start_time;
91 AT_include_file A_include_file;
92 AT_process_function A_process_function;
93 AT_network_link_sharing_policy A_network_link_sharing_policy;
94 AT_route_dst A_route_dst;
95 AT_cpu_state A_cpu_state;
96 AT_network_link_latency A_network_link_latency;
97 AT_network_link_state_file A_network_link_state_file;
98 AT_cpu_interference_send A_cpu_interference_send;
99 AT_cpu_state_file A_cpu_state_file;
100 AT_network_link_bandwidth_file A_network_link_bandwidth_file;
104 # define ENTER(state) debug_enter(state,#state)
105 # define LEAVE debug_leave()
106 # define SET(state) debug_set(state,#state)
107 static void debug_enter(int, const char*);
108 static void debug_leave(void);
109 static void debug_set(int, const char*);
111 # define ENTER(state) (yy_push_state(state))
112 # define LEAVE (yy_pop_state())
113 # define SET(state) BEGIN(state)
116 /* Generic actions. */
117 #define SKIP /*skip*/
118 #define SUCCEED CLEANUP; return 0
120 #define FAIL return fail
121 static int fail(const char*, ...);
122 const char * surfxml_parse_err_msg(void);
125 static void cleanup(void);
126 #define CLEANUP cleanup()
128 /* Text buffer stack handling. */
129 char bufferstack[FLEXML_BUFFERSTACKSIZE];
130 static char* limit = bufferstack + FLEXML_BUFFERSTACKSIZE;
131 typedef struct BufferLast_s {
132 struct BufferLast_s *old; char* saved; char new1[1];
134 #ifdef FLEXML_HasMixed
135 static BufferLast* last = (BufferLast*)0;
137 static char* next = bufferstack;
139 #define BUFFERSET(P) (P = next)
140 #define BUFFERPUTC(C) (assert(next<limit), *(next++) = (C))
141 #define BUFFERDONE (BUFFERPUTC('\0'))
143 #define BUFFERLITERAL(C,P) bufferliteral(C,&(P),yytext)
144 static void bufferliteral(char c, const char** pp, char* text)
146 char *s = strchr(text,c), *e = strrchr(text,c);
147 assert(s <= e); BUFFERSET(*pp);
149 if (isspace(*s)) { BUFFERPUTC(' '); while (isspace(*s)) ++s; }
155 #ifdef FLEXML_HasMixed
156 static void pushbuffer(char* p)
158 BufferLast* l = (BufferLast*)next;
159 assert(next < limit);
166 static char* popbuffer(void)
168 BufferLast* l = last;
169 assert(last != (BufferLast*)0);
176 /* General internal entities are `unput' back onto the input stream... */
177 #define ENTITYTEXT(T) \
178 { char *s = (T), *e = s+strlen(s);\
179 while (--e >= s) { unput(*e); }}
182 /* Flex standard options. */
184 %option noyy_top_state
190 /* Flex user-requested options. */
194 /* XML character classes (currently restricted to ASCII). */
196 /* "Common syntactic structures." */
200 /* "Names and Tokens." */
201 NameChar [A-Za-z0-9.:_-]
202 Name [A-Za-z_:]{NameChar}*
203 Names {Name}({S}{Name})*
204 Nmtoken ({NameChar})+
205 Nmtokens {Nmtoken}({S}{Nmtoken})*
208 VersionNum [a-zA-Z0-9_.:-]+
210 Literal \'[^'']*\'|\"[^""]*\"
212 /* Parser states (flex `exclusive start conditions'):
214 * PROLOG the XML prolog of the document before <?xml...>
215 * DOCTYPE the XML prolog of the document after <?xml...>
216 * EPILOG after the root element
217 * INCOMMENT inside an XML comment <!--....-->
218 * INPI inside an XML PI <?...?>
219 * VALUE1 inside a '...'-delimited literal
220 * VALUE2 inside a "..."-delimited literal
221 * CDATA inside a <![CDATA[...]]> section.
222 * ROOT_<tag> expect root element <tag>
223 * AL_<tag> inside the attribute list for <tag>
224 * IN_<tag> inside a <tag> with element contents (ready for end tag)
225 * IMPOSSIBLE dummy to permit disabling rules; must be last
227 %x PROLOG DOCTYPE EPILOG INCOMMENT INPI VALUE1 VALUE2 CDATA
228 %x ROOT_platform_description AL_platform_description S_platform_description S_platform_description_1 S_platform_description_2 E_platform_description
229 %x ROOT_include AL_include S_include S_include_1 S_include_2 E_include
230 %x ROOT_cpu AL_cpu E_cpu
231 %x ROOT_network_link AL_network_link E_network_link
232 %x ROOT_route AL_route S_route S_route_1 S_route_2 E_route
233 %x ROOT_route_element AL_route_element E_route_element
234 %x ROOT_process AL_process S_process S_process_1 S_process_2 E_process
235 %x ROOT_argument AL_argument E_argument
240 const char* *surfxml_statenames=NULL;
245 /* Bypass Flex's default INITIAL state and begin by parsing the XML prolog. */
249 if(!surfxml_statenames) {surfxml_statenames= (const char **)calloc(IMPOSSIBLE,sizeof(char*));
250 surfxml_statenames[PROLOG] = NULL;
251 surfxml_statenames[DOCTYPE] = NULL;
252 surfxml_statenames[EPILOG] = NULL;
253 surfxml_statenames[INCOMMENT] = NULL;
254 surfxml_statenames[INPI] = NULL;
255 surfxml_statenames[VALUE1] = NULL;
256 surfxml_statenames[VALUE2] = NULL;
257 surfxml_statenames[CDATA] = NULL;
258 surfxml_statenames[ROOT_platform_description] = NULL;
259 surfxml_statenames[AL_platform_description] = NULL;
260 surfxml_statenames[S_platform_description] = "platform_description";
261 surfxml_statenames[S_platform_description_1] = "platform_description";
262 surfxml_statenames[S_platform_description_2] = "platform_description";
263 surfxml_statenames[E_platform_description] = "platform_description";
264 surfxml_statenames[ROOT_include] = NULL;
265 surfxml_statenames[AL_include] = NULL;
266 surfxml_statenames[S_include] = "include";
267 surfxml_statenames[S_include_1] = "include";
268 surfxml_statenames[S_include_2] = "include";
269 surfxml_statenames[E_include] = "include";
270 surfxml_statenames[ROOT_cpu] = NULL;
271 surfxml_statenames[AL_cpu] = NULL;
272 surfxml_statenames[E_cpu] = "cpu";
273 surfxml_statenames[ROOT_network_link] = NULL;
274 surfxml_statenames[AL_network_link] = NULL;
275 surfxml_statenames[E_network_link] = "network_link";
276 surfxml_statenames[ROOT_route] = NULL;
277 surfxml_statenames[AL_route] = NULL;
278 surfxml_statenames[S_route] = "route";
279 surfxml_statenames[S_route_1] = "route";
280 surfxml_statenames[S_route_2] = "route";
281 surfxml_statenames[E_route] = "route";
282 surfxml_statenames[ROOT_route_element] = NULL;
283 surfxml_statenames[AL_route_element] = NULL;
284 surfxml_statenames[E_route_element] = "route_element";
285 surfxml_statenames[ROOT_process] = NULL;
286 surfxml_statenames[AL_process] = NULL;
287 surfxml_statenames[S_process] = "process";
288 surfxml_statenames[S_process_1] = "process";
289 surfxml_statenames[S_process_2] = "process";
290 surfxml_statenames[E_process] = "process";
291 surfxml_statenames[ROOT_argument] = NULL;
292 surfxml_statenames[AL_argument] = NULL;
293 surfxml_statenames[E_argument] = "argument";
296 /* COMMENTS and PIs: handled uniformly for efficiency. */
298 <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>{
299 "<!--" ENTER(INCOMMENT);
307 <<EOF>> FAIL("EOF in comment.");
313 <<EOF>> FAIL("EOF in PI (processing instruction).");
316 /* SPACES: skipped uniformly */
318 <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;
320 /* PROLOG: determine root element and process it. */
323 "<?xml"({S}version{Eq}(\'{VersionNum}\'|\"{VersionNum}\"))?({S}encoding{Eq}(\'[^']*\'|\"[^"]*\"))?"?>" SET(DOCTYPE);
324 "<?xml"[^>]*">" FAIL("Bad declaration %s.",yytext);
328 "<!DOCTYPE"{S}"argument"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_argument);
329 "<!DOCTYPE"{S}"route_element"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_route_element);
330 "<!DOCTYPE"{S}"cpu"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_cpu);
331 "<!DOCTYPE"{S}"include"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_include);
332 "<!DOCTYPE"{S}"route"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_route);
333 "<!DOCTYPE"{S}"platform_description"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_platform_description);
334 "<!DOCTYPE"{S}"network_link"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_network_link);
335 "<!DOCTYPE"{S}"process"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_process);
336 "<!"[^>-][^>]*">" FAIL("Bad declaration %s.",yytext);
337 . FAIL("Unexpected character `%c' in prolog.", yytext[0]);
338 <<EOF>> FAIL("EOF in prolog.");
341 /* RULES DERIVED FROM DTD. */
343 /* <!-- Small DTD for SURF based tools. --> */
345 <ROOT_platform_description>"<platform_description"{s} {
346 ENTER(AL_platform_description);
349 <AL_platform_description>{
351 LEAVE; STag_platform_description();pcdata = NULL; ENTER(S_platform_description);
354 LEAVE; STag_platform_description(); pcdata = NULL; ETag_platform_description();
356 case ROOT_platform_description: SET(EPILOG); break;
359 . FAIL("Unexpected character `%c' in attribute list of platform_description element.", yytext[0]);
360 {Name} FAIL("Bad attribute `%s' in `platform_description' element start tag.",yytext);
361 <<EOF>> FAIL("EOF in attribute list of `platform_description' element.");
364 <E_platform_description,S_platform_description_2,S_platform_description>{
365 "</platform_description"{s}">" {
367 ETag_platform_description();
369 case ROOT_platform_description: SET(EPILOG); break;
372 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</platform_description>' expected.",yytext);
373 . FAIL("Unexpected character `%c': `</platform_description>' expected.",yytext[0]);
374 <<EOF>> FAIL("Premature EOF: `</platform_description>' expected.");
377 <ROOT_include,S_platform_description_2,S_include,S_include_2,S_platform_description_1,S_include_1,S_platform_description>"<include"{s} {
378 A_include_file = NULL;
383 "file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_include_file);
384 "file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_include_file);
387 if (!A_include_file) FAIL("Required attribute `file' not set for `include' element.");
388 LEAVE; STag_include();pcdata = NULL; ENTER(S_include);
391 if (!A_include_file) FAIL("Required attribute `file' not set for `include' element.");
392 LEAVE; STag_include(); pcdata = NULL; ETag_include();
394 case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
395 case S_include: case S_include_2: case S_include_1: SET(S_include_2); break;
396 case ROOT_include: SET(EPILOG); break;
399 . FAIL("Unexpected character `%c' in attribute list of include element.", yytext[0]);
400 {Name} FAIL("Bad attribute `%s' in `include' element start tag.",yytext);
401 <<EOF>> FAIL("EOF in attribute list of `include' element.");
404 <E_include,S_include,S_include_2>{
409 case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
410 case S_include: case S_include_2: case S_include_1: SET(S_include_2); break;
411 case ROOT_include: SET(EPILOG); break;
414 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</include>' expected.",yytext);
415 . FAIL("Unexpected character `%c': `</include>' expected.",yytext[0]);
416 <<EOF>> FAIL("Premature EOF: `</include>' expected.");
419 <ROOT_cpu,S_platform_description_2,S_include,S_include_2,S_platform_description_1,S_include_1,S_platform_description>"<cpu"{s} {
422 A_cpu_availability = "1.0";
423 A_cpu_availability_file = NULL;
424 A_cpu_state = A_cpu_state_ON;
425 A_cpu_state_file = NULL;
426 A_cpu_interference_send = "1.0";
427 A_cpu_interference_recv = "1.0";
428 A_cpu_interference_send_recv = "1.0";
429 A_cpu_max_outgoing_rate = "-1.0";
434 "name"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_name);
435 "name"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_name);
437 "power"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_power);
438 "power"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_power);
440 "availability"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_availability);
441 "availability"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_availability);
443 "availability_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_availability_file);
444 "availability_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_availability_file);
447 "state"{Eq}"\"ON\"" A_cpu_state = A_cpu_state_ON;
449 "state"{Eq}"\"OFF\"" A_cpu_state = A_cpu_state_OFF;
451 "state_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_state_file);
452 "state_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_state_file);
454 "interference_send"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_interference_send);
455 "interference_send"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_interference_send);
457 "interference_recv"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_interference_recv);
458 "interference_recv"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_interference_recv);
460 "interference_send_recv"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_interference_send_recv);
461 "interference_send_recv"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_interference_send_recv);
463 "max_outgoing_rate"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_max_outgoing_rate);
464 "max_outgoing_rate"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_max_outgoing_rate);
467 if (!A_cpu_name) FAIL("Required attribute `name' not set for `cpu' element.");
468 if (!A_cpu_power) FAIL("Required attribute `power' not set for `cpu' element.");
469 LEAVE; STag_cpu();pcdata = NULL; ENTER(E_cpu);
472 if (!A_cpu_name) FAIL("Required attribute `name' not set for `cpu' element.");
473 if (!A_cpu_power) FAIL("Required attribute `power' not set for `cpu' element.");
474 LEAVE; STag_cpu(); pcdata = NULL; ETag_cpu();
476 case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
477 case S_include: case S_include_2: case S_include_1: SET(S_include_2); break;
478 case ROOT_cpu: SET(EPILOG); break;
481 . FAIL("Unexpected character `%c' in attribute list of cpu element.", yytext[0]);
482 {Name} FAIL("Bad attribute `%s' in `cpu' element start tag.",yytext);
483 <<EOF>> FAIL("EOF in attribute list of `cpu' element.");
491 case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
492 case S_include: case S_include_2: case S_include_1: SET(S_include_2); break;
493 case ROOT_cpu: SET(EPILOG); break;
496 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</cpu>' expected.",yytext);
497 . FAIL("Unexpected character `%c': `</cpu>' expected.",yytext[0]);
498 <<EOF>> FAIL("Premature EOF: `</cpu>' expected.");
501 <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} {
502 A_network_link_name = NULL;
503 A_network_link_bandwidth = NULL;
504 A_network_link_bandwidth_file = NULL;
505 A_network_link_latency = "0.0";
506 A_network_link_latency_file = NULL;
507 A_network_link_state = A_network_link_state_ON;
508 A_network_link_state_file = NULL;
509 A_network_link_sharing_policy = A_network_link_sharing_policy_SHARED;
510 ENTER(AL_network_link);
514 "name"{Eq}\' ENTER(VALUE1); BUFFERSET(A_network_link_name);
515 "name"{Eq}\" ENTER(VALUE2); BUFFERSET(A_network_link_name);
517 "bandwidth"{Eq}\' ENTER(VALUE1); BUFFERSET(A_network_link_bandwidth);
518 "bandwidth"{Eq}\" ENTER(VALUE2); BUFFERSET(A_network_link_bandwidth);
520 "bandwidth_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_network_link_bandwidth_file);
521 "bandwidth_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_network_link_bandwidth_file);
523 "latency"{Eq}\' ENTER(VALUE1); BUFFERSET(A_network_link_latency);
524 "latency"{Eq}\" ENTER(VALUE2); BUFFERSET(A_network_link_latency);
526 "latency_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_network_link_latency_file);
527 "latency_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_network_link_latency_file);
530 "state"{Eq}"\"ON\"" A_network_link_state = A_network_link_state_ON;
532 "state"{Eq}"\"OFF\"" A_network_link_state = A_network_link_state_OFF;
534 "state_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_network_link_state_file);
535 "state_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_network_link_state_file);
537 "sharing_policy"{Eq}"'SHARED'" |
538 "sharing_policy"{Eq}"\"SHARED\"" A_network_link_sharing_policy = A_network_link_sharing_policy_SHARED;
539 "sharing_policy"{Eq}"'FATPIPE'" |
540 "sharing_policy"{Eq}"\"FATPIPE\"" A_network_link_sharing_policy = A_network_link_sharing_policy_FATPIPE;
543 if (!A_network_link_name) FAIL("Required attribute `name' not set for `network_link' element.");
544 if (!A_network_link_bandwidth) FAIL("Required attribute `bandwidth' not set for `network_link' element.");
545 LEAVE; STag_network_link();pcdata = NULL; ENTER(E_network_link);
548 if (!A_network_link_name) FAIL("Required attribute `name' not set for `network_link' element.");
549 if (!A_network_link_bandwidth) FAIL("Required attribute `bandwidth' not set for `network_link' element.");
550 LEAVE; STag_network_link(); pcdata = NULL; ETag_network_link();
552 case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
553 case S_include: case S_include_2: case S_include_1: SET(S_include_2); break;
554 case ROOT_network_link: SET(EPILOG); break;
557 . FAIL("Unexpected character `%c' in attribute list of network_link element.", yytext[0]);
558 {Name} FAIL("Bad attribute `%s' in `network_link' element start tag.",yytext);
559 <<EOF>> FAIL("EOF in attribute list of `network_link' element.");
563 "</network_link"{s}">" {
567 case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
568 case S_include: case S_include_2: case S_include_1: SET(S_include_2); break;
569 case ROOT_network_link: SET(EPILOG); break;
572 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</network_link>' expected.",yytext);
573 . FAIL("Unexpected character `%c': `</network_link>' expected.",yytext[0]);
574 <<EOF>> FAIL("Premature EOF: `</network_link>' expected.");
577 <ROOT_route,S_platform_description_2,S_include,S_include_2,S_platform_description_1,S_include_1,S_platform_description>"<route"{s} {
580 A_route_impact_on_src = "0.0";
581 A_route_impact_on_dst = "0.0";
582 A_route_impact_on_src_with_other_recv = "0.0";
583 A_route_impact_on_dst_with_other_send = "0.0";
588 "src"{Eq}\' ENTER(VALUE1); BUFFERSET(A_route_src);
589 "src"{Eq}\" ENTER(VALUE2); BUFFERSET(A_route_src);
591 "dst"{Eq}\' ENTER(VALUE1); BUFFERSET(A_route_dst);
592 "dst"{Eq}\" ENTER(VALUE2); BUFFERSET(A_route_dst);
594 "impact_on_src"{Eq}\' ENTER(VALUE1); BUFFERSET(A_route_impact_on_src);
595 "impact_on_src"{Eq}\" ENTER(VALUE2); BUFFERSET(A_route_impact_on_src);
597 "impact_on_dst"{Eq}\' ENTER(VALUE1); BUFFERSET(A_route_impact_on_dst);
598 "impact_on_dst"{Eq}\" ENTER(VALUE2); BUFFERSET(A_route_impact_on_dst);
600 "impact_on_src_with_other_recv"{Eq}\' ENTER(VALUE1); BUFFERSET(A_route_impact_on_src_with_other_recv);
601 "impact_on_src_with_other_recv"{Eq}\" ENTER(VALUE2); BUFFERSET(A_route_impact_on_src_with_other_recv);
603 "impact_on_dst_with_other_send"{Eq}\' ENTER(VALUE1); BUFFERSET(A_route_impact_on_dst_with_other_send);
604 "impact_on_dst_with_other_send"{Eq}\" ENTER(VALUE2); BUFFERSET(A_route_impact_on_dst_with_other_send);
607 if (!A_route_src) FAIL("Required attribute `src' not set for `route' element.");
608 if (!A_route_dst) FAIL("Required attribute `dst' not set for `route' element.");
609 LEAVE; STag_route();pcdata = NULL; ENTER(S_route);
612 if (!A_route_src) FAIL("Required attribute `src' not set for `route' element.");
613 if (!A_route_dst) FAIL("Required attribute `dst' not set for `route' element.");
614 LEAVE; STag_route(); pcdata = NULL; ETag_route();
616 case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
617 case S_include: case S_include_2: case S_include_1: SET(S_include_2); break;
618 case ROOT_route: SET(EPILOG); break;
621 . FAIL("Unexpected character `%c' in attribute list of route element.", yytext[0]);
622 {Name} FAIL("Bad attribute `%s' in `route' element start tag.",yytext);
623 <<EOF>> FAIL("EOF in attribute list of `route' element.");
626 <S_route,S_route_2,E_route>{
631 case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
632 case S_include: case S_include_2: case S_include_1: SET(S_include_2); break;
633 case ROOT_route: SET(EPILOG); break;
636 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</route>' expected.",yytext);
637 . FAIL("Unexpected character `%c': `</route>' expected.",yytext[0]);
638 <<EOF>> FAIL("Premature EOF: `</route>' expected.");
641 <ROOT_route_element,S_route_1,S_route,S_route_2>"<route_element"{s} {
642 A_route_element_name = NULL;
643 ENTER(AL_route_element);
647 "name"{Eq}\' ENTER(VALUE1); BUFFERSET(A_route_element_name);
648 "name"{Eq}\" ENTER(VALUE2); BUFFERSET(A_route_element_name);
651 if (!A_route_element_name) FAIL("Required attribute `name' not set for `route_element' element.");
652 LEAVE; STag_route_element();pcdata = NULL; ENTER(E_route_element);
655 if (!A_route_element_name) FAIL("Required attribute `name' not set for `route_element' element.");
656 LEAVE; STag_route_element(); pcdata = NULL; ETag_route_element();
658 case S_route_1: case S_route: case S_route_2: SET(S_route_2); break;
659 case ROOT_route_element: SET(EPILOG); break;
662 . FAIL("Unexpected character `%c' in attribute list of route_element element.", yytext[0]);
663 {Name} FAIL("Bad attribute `%s' in `route_element' element start tag.",yytext);
664 <<EOF>> FAIL("EOF in attribute list of `route_element' element.");
668 "</route_element"{s}">" {
670 ETag_route_element();
672 case S_route_1: case S_route: case S_route_2: SET(S_route_2); break;
673 case ROOT_route_element: SET(EPILOG); break;
676 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</route_element>' expected.",yytext);
677 . FAIL("Unexpected character `%c': `</route_element>' expected.",yytext[0]);
678 <<EOF>> FAIL("Premature EOF: `</route_element>' expected.");
681 <ROOT_process,S_platform_description_2,S_include,S_include_2,S_platform_description_1,S_include_1,S_platform_description>"<process"{s} {
682 A_process_host = NULL;
683 A_process_function = NULL;
684 A_process_start_time = "-1.0";
685 A_process_kill_time = "-1.0";
690 "host"{Eq}\' ENTER(VALUE1); BUFFERSET(A_process_host);
691 "host"{Eq}\" ENTER(VALUE2); BUFFERSET(A_process_host);
693 "function"{Eq}\' ENTER(VALUE1); BUFFERSET(A_process_function);
694 "function"{Eq}\" ENTER(VALUE2); BUFFERSET(A_process_function);
696 "start_time"{Eq}\' ENTER(VALUE1); BUFFERSET(A_process_start_time);
697 "start_time"{Eq}\" ENTER(VALUE2); BUFFERSET(A_process_start_time);
699 "kill_time"{Eq}\' ENTER(VALUE1); BUFFERSET(A_process_kill_time);
700 "kill_time"{Eq}\" ENTER(VALUE2); BUFFERSET(A_process_kill_time);
703 if (!A_process_host) FAIL("Required attribute `host' not set for `process' element.");
704 if (!A_process_function) FAIL("Required attribute `function' not set for `process' element.");
705 LEAVE; STag_process();pcdata = NULL; ENTER(S_process);
708 if (!A_process_host) FAIL("Required attribute `host' not set for `process' element.");
709 if (!A_process_function) FAIL("Required attribute `function' not set for `process' element.");
710 LEAVE; STag_process(); pcdata = NULL; ETag_process();
712 case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
713 case S_include: case S_include_2: case S_include_1: SET(S_include_2); break;
714 case ROOT_process: SET(EPILOG); break;
717 . FAIL("Unexpected character `%c' in attribute list of process element.", yytext[0]);
718 {Name} FAIL("Bad attribute `%s' in `process' element start tag.",yytext);
719 <<EOF>> FAIL("EOF in attribute list of `process' element.");
722 <S_process,E_process,S_process_2>{
727 case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
728 case S_include: case S_include_2: case S_include_1: SET(S_include_2); break;
729 case ROOT_process: SET(EPILOG); break;
732 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</process>' expected.",yytext);
733 . FAIL("Unexpected character `%c': `</process>' expected.",yytext[0]);
734 <<EOF>> FAIL("Premature EOF: `</process>' expected.");
737 <ROOT_argument,S_process_1,S_process,S_process_2>"<argument"{s} {
738 A_argument_value = NULL;
743 "value"{Eq}\' ENTER(VALUE1); BUFFERSET(A_argument_value);
744 "value"{Eq}\" ENTER(VALUE2); BUFFERSET(A_argument_value);
747 if (!A_argument_value) FAIL("Required attribute `value' not set for `argument' element.");
748 LEAVE; STag_argument();pcdata = NULL; ENTER(E_argument);
751 if (!A_argument_value) FAIL("Required attribute `value' not set for `argument' element.");
752 LEAVE; STag_argument(); pcdata = NULL; ETag_argument();
754 case ROOT_argument: SET(EPILOG); break;
755 case S_process_1: case S_process: case S_process_2: SET(S_process_2); break;
758 . FAIL("Unexpected character `%c' in attribute list of argument element.", yytext[0]);
759 {Name} FAIL("Bad attribute `%s' in `argument' element start tag.",yytext);
760 <<EOF>> FAIL("EOF in attribute list of `argument' element.");
768 case ROOT_argument: SET(EPILOG); break;
769 case S_process_1: case S_process: case S_process_2: SET(S_process_2); break;
772 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</argument>' expected.",yytext);
773 . FAIL("Unexpected character `%c': `</argument>' expected.",yytext[0]);
774 <<EOF>> FAIL("Premature EOF: `</argument>' expected.");
777 /* EPILOG: after the root element. */
780 . {SET(PROLOG); yyless(0); CLEANUP; return -1;}
784 /* CHARACTER DATA. */
786 <IMPOSSIBLE,VALUE1,VALUE2>{
787 /* Non-defined standard entities... */
788 "&" BUFFERPUTC('&');
789 "<" BUFFERPUTC('<');
790 ">" BUFFERPUTC('>');
791 "'" BUFFERPUTC('\'');
792 """ BUFFERPUTC('"');
794 /* Character entities. */
795 "&#"[[:digit:]]+";" BUFFERPUTC((unsigned char)atoi(yytext+2));
796 "&#x"[[:xdigit:]]+";" BUFFERPUTC((unsigned char)strtol(yytext+3,NULL,16));
799 <IMPOSSIBLE,VALUE1,VALUE2,CDATA>{
803 "\n\r" BUFFERPUTC('\n');
807 "<![CDATA[" ENTER(CDATA);
808 "]""]>" FAIL("Unexpected `]""]>' in character data.");
812 \' BUFFERDONE; LEAVE;
813 <<EOF>> FAIL("EOF in literal (\"'\" expected).");
817 \" BUFFERDONE; LEAVE;
818 <<EOF>> FAIL("EOF in literal (`\"' expected).");
821 <IMPOSSIBLE,VALUE1,VALUE2>{
822 [^<&] BUFFERPUTC(yytext[0]);
823 [<&] FAIL("Spurious `%c' in character data.",yytext[0]);
828 /* "]""]" BUFFERPUTC(yytext[0]); BUFFERPUTC(yytext[1]); */
829 . BUFFERPUTC(yytext[0]);
830 <<EOF>> FAIL("EOF in CDATA section.");
833 /* Impossible rules to avoid warnings from flex(1). */
834 /* Ideally, this should be replaced by code in flexml.pl that
835 generates just the states not covered by other rules. */
837 .|[\n] FAIL("Syntax error on character `%c'.", yytext[0]);
842 /* Element context stack lookup. */
843 int surfxml_element_context(int i)
845 return (0<i && i<yy_start_stack_depth
846 ? yy_start_stack[yy_start_stack_ptr - i]
851 void print_yy_stack(char* fmt, ...)
853 int i = 0; va_list ap; va_start(ap, fmt);
854 vfprintf(stderr, fmt, ap);
855 for (i=1; i<yy_start_stack_ptr; i++)
856 fprintf(stderr, "%s/", surfxml_statenames[yy_start_stack[i] ]);
857 fprintf(stderr,"%s\n", surfxml_statenames[YY_START]);
861 static void debug_enter(int state, const char* statename) {
862 yy_push_state(state);
863 if (yy_flex_debug) print_yy_stack("--ENTER(%s) : ",statename);
866 static void debug_leave(void) {
867 if (yy_flex_debug) print_yy_stack("--LEAVE : ");
871 static void debug_set(int state, const char* statename) {
873 if (yy_flex_debug) print_yy_stack("--SET(%s) : ",statename);
877 enum {flexml_max_err_msg_size = 512};
879 static char flexml_err_msg[flexml_max_err_msg_size];
880 const char * surfxml_parse_err_msg()
882 return flexml_err_msg;
885 static void reset_surfxml_parse_err_msg()
887 flexml_err_msg[0] = '\0';
891 static void cleanup(void)
893 if (surfxml_statenames) {
894 free(surfxml_statenames);
895 surfxml_statenames = NULL;
900 static int fail(const char* fmt, ...)
902 int chars_left, used;
903 va_list ap; va_start(ap, fmt);
904 #ifdef FLEXML_yylineno
905 used = sprintf(flexml_err_msg,
906 "Invalid XML (XML input line %d, state %d): ",
909 used = sprintf(flexml_err_msg,
910 "Invalid XML (state %d): ",
913 chars_left = flexml_max_err_msg_size - used - 1;
914 vsnprintf(flexml_err_msg + used, chars_left, fmt, ap);
917 #ifndef FLEXML_quiet_parser
918 /* print directly to sdterr */
919 fprintf(stderr, "%s\n", flexml_err_msg);
920 flexml_err_msg[0] = '\0';