1 /* Validating XML processor for surfxml.dtd.
2 * Generated 2006/05/29 23:03:05.
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.48 2006/03/21 13:09:12 mquinson 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.28 2006/03/21 12:04:13 legranda Exp $";
52 const char rcs_surfxml_flexml[] =
53 "$" "Id: flexml.pl,v 1.48 2006/03/21 13:09:12 mquinson Exp $";
63 /* Generated definitions. */
64 #define FLEXML_yylineno
65 #define FLEXML_BUFFERSTACKSIZE 1000000
67 /* XML processor api. */
68 /* FleXML-provided data. */
69 const char* surfxml_pcdata;
70 AT_surfxml_network_link_bandwidth A_surfxml_network_link_bandwidth;
71 AT_surfxml_process_host A_surfxml_process_host;
72 AT_surfxml_network_link_latency_file A_surfxml_network_link_latency_file;
73 AT_surfxml_route_impact_on_dst_with_other_send A_surfxml_route_impact_on_dst_with_other_send;
74 AT_surfxml_cpu_interference_send_recv A_surfxml_cpu_interference_send_recv;
75 AT_surfxml_route_impact_on_dst A_surfxml_route_impact_on_dst;
76 AT_surfxml_platform_description_version A_surfxml_platform_description_version;
77 AT_surfxml_route_impact_on_src_with_other_recv A_surfxml_route_impact_on_src_with_other_recv;
78 AT_surfxml_route_element_name A_surfxml_route_element_name;
79 AT_surfxml_process_start_time A_surfxml_process_start_time;
80 AT_surfxml_process_function A_surfxml_process_function;
81 AT_surfxml_cpu_state A_surfxml_cpu_state;
82 AT_surfxml_cpu_interference_send A_surfxml_cpu_interference_send;
83 AT_surfxml_network_link_bandwidth_file A_surfxml_network_link_bandwidth_file;
84 AT_surfxml_cpu_name A_surfxml_cpu_name;
85 AT_surfxml_process_kill_time A_surfxml_process_kill_time;
86 AT_surfxml_network_link_state A_surfxml_network_link_state;
87 AT_surfxml_cpu_availability_file A_surfxml_cpu_availability_file;
88 AT_surfxml_argument_value A_surfxml_argument_value;
89 AT_surfxml_route_src A_surfxml_route_src;
90 AT_surfxml_route_impact_on_src A_surfxml_route_impact_on_src;
91 AT_surfxml_cpu_max_outgoing_rate A_surfxml_cpu_max_outgoing_rate;
92 AT_surfxml_cpu_availability A_surfxml_cpu_availability;
93 AT_surfxml_cpu_interference_recv A_surfxml_cpu_interference_recv;
94 AT_surfxml_network_link_name A_surfxml_network_link_name;
95 AT_surfxml_cpu_power A_surfxml_cpu_power;
96 AT_surfxml_include_file A_surfxml_include_file;
97 AT_surfxml_network_link_sharing_policy A_surfxml_network_link_sharing_policy;
98 AT_surfxml_route_dst A_surfxml_route_dst;
99 AT_surfxml_network_link_latency A_surfxml_network_link_latency;
100 AT_surfxml_cpu_state_file A_surfxml_cpu_state_file;
101 AT_surfxml_network_link_state_file A_surfxml_network_link_state_file;
105 # define ENTER(state) debug_enter(state,#state)
106 # define LEAVE debug_leave()
107 # define SET(state) debug_set(state,#state)
108 static void debug_enter(int, const char*);
109 static void debug_leave(void);
110 static void debug_set(int, const char*);
112 # define ENTER(state) (yy_push_state(state))
113 # define LEAVE (yy_pop_state())
114 # define SET(state) BEGIN(state)
117 /* Generic actions. */
118 #define SKIP /*skip*/
119 #define SUCCEED CLEANUP; return 0
121 #define FAIL return fail
122 static int fail(const char*, ...);
123 const char * surfxml_parse_err_msg(void);
126 static void cleanup(void);
127 #define CLEANUP cleanup()
129 /* Text buffer stack handling. */
130 static char bufferstack[FLEXML_BUFFERSTACKSIZE];
131 static char* limit = bufferstack + FLEXML_BUFFERSTACKSIZE;
132 typedef struct BufferLast_s {
133 struct BufferLast_s *old; char* saved; char new1[1];
135 #ifdef FLEXML_HasMixed
136 static BufferLast* last = (BufferLast*)0;
138 static char* next = bufferstack;
140 #define BUFFERSET(P) (P = next)
141 #define BUFFERPUTC(C) (assert(next<limit), *(next++) = (C))
142 #define BUFFERDONE (BUFFERPUTC('\0'))
144 #define BUFFERLITERAL(C,P) bufferliteral(C,&(P),yytext)
145 static void bufferliteral(char c, const char** pp, char* text)
147 char *s = strchr(text,c), *e = strrchr(text,c);
148 assert(s <= e); BUFFERSET(*pp);
150 if (isspace(*s)) { BUFFERPUTC(' '); while (isspace(*s)) ++s; }
156 #ifdef FLEXML_HasMixed
157 static void pushbuffer(char* p)
159 BufferLast* l = (BufferLast*)next;
160 assert(next < limit);
167 static char* popbuffer(void)
169 BufferLast* l = last;
170 assert(last != (BufferLast*)0);
177 /* General internal entities are `unput' back onto the input stream... */
178 #define ENTITYTEXT(T) \
179 { char *s = (T), *e = s+strlen(s);\
180 while (--e >= s) { unput(*e); }}
183 /* Flex standard options. */
185 %option noyy_top_state
191 /* Flex user-requested options. */
195 /* XML character classes (currently restricted to ASCII). */
197 /* "Common syntactic structures." */
201 /* "Names and Tokens." */
202 NameChar [A-Za-z0-9.:_-]
203 Name [A-Za-z_:]{NameChar}*
204 Names {Name}({S}{Name})*
205 Nmtoken ({NameChar})+
206 Nmtokens {Nmtoken}({S}{Nmtoken})*
209 VersionNum [a-zA-Z0-9_.:-]+
211 Literal \'[^'']*\'|\"[^""]*\"
213 /* Parser states (flex `exclusive start conditions'):
215 * PROLOG the XML prolog of the document before <?xml...>
216 * DOCTYPE the XML prolog of the document after <?xml...>
217 * EPILOG after the root element
218 * INCOMMENT inside an XML comment <!--....-->
219 * INPI inside an XML PI <?...?>
220 * VALUE1 inside a '...'-delimited literal
221 * VALUE2 inside a "..."-delimited literal
222 * CDATA inside a <![CDATA[...] ]> section.
223 * ROOT_<tag> expect root element <tag>
224 * AL_<tag> inside the attribute list for <tag>
225 * IN_<tag> inside a <tag> with element contents (ready for end tag)
226 * IMPOSSIBLE dummy to permit disabling rules; must be last
228 %x PROLOG DOCTYPE EPILOG INCOMMENT INPI VALUE1 VALUE2 CDATA
229 %x ROOT_surfxml_platform_description AL_surfxml_platform_description S_surfxml_platform_description S_surfxml_platform_description_1 S_surfxml_platform_description_2 E_surfxml_platform_description
230 %x ROOT_surfxml_include AL_surfxml_include S_surfxml_include S_surfxml_include_1 S_surfxml_include_2 E_surfxml_include
231 %x ROOT_surfxml_cpu AL_surfxml_cpu E_surfxml_cpu
232 %x ROOT_surfxml_network_link AL_surfxml_network_link E_surfxml_network_link
233 %x ROOT_surfxml_route AL_surfxml_route S_surfxml_route S_surfxml_route_1 S_surfxml_route_2 E_surfxml_route
234 %x ROOT_surfxml_route_element AL_surfxml_route_element E_surfxml_route_element
235 %x ROOT_surfxml_process AL_surfxml_process S_surfxml_process S_surfxml_process_1 S_surfxml_process_2 E_surfxml_process
236 %x ROOT_surfxml_argument AL_surfxml_argument E_surfxml_argument
241 const char* *surfxml_statenames=NULL;
246 /* Bypass Flex's default INITIAL state and begin by parsing the XML prolog. */
250 if(!surfxml_statenames) {surfxml_statenames= (const char **)calloc(IMPOSSIBLE,sizeof(char*));
251 surfxml_statenames[PROLOG] = NULL;
252 surfxml_statenames[DOCTYPE] = NULL;
253 surfxml_statenames[EPILOG] = NULL;
254 surfxml_statenames[INCOMMENT] = NULL;
255 surfxml_statenames[INPI] = NULL;
256 surfxml_statenames[VALUE1] = NULL;
257 surfxml_statenames[VALUE2] = NULL;
258 surfxml_statenames[CDATA] = NULL;
259 surfxml_statenames[ROOT_surfxml_platform_description] = NULL;
260 surfxml_statenames[AL_surfxml_platform_description] = NULL;
261 surfxml_statenames[S_surfxml_platform_description] = "platform_description";
262 surfxml_statenames[S_surfxml_platform_description_1] = "platform_description";
263 surfxml_statenames[S_surfxml_platform_description_2] = "platform_description";
264 surfxml_statenames[E_surfxml_platform_description] = "platform_description";
265 surfxml_statenames[ROOT_surfxml_include] = NULL;
266 surfxml_statenames[AL_surfxml_include] = NULL;
267 surfxml_statenames[S_surfxml_include] = "include";
268 surfxml_statenames[S_surfxml_include_1] = "include";
269 surfxml_statenames[S_surfxml_include_2] = "include";
270 surfxml_statenames[E_surfxml_include] = "include";
271 surfxml_statenames[ROOT_surfxml_cpu] = NULL;
272 surfxml_statenames[AL_surfxml_cpu] = NULL;
273 surfxml_statenames[E_surfxml_cpu] = "cpu";
274 surfxml_statenames[ROOT_surfxml_network_link] = NULL;
275 surfxml_statenames[AL_surfxml_network_link] = NULL;
276 surfxml_statenames[E_surfxml_network_link] = "network_link";
277 surfxml_statenames[ROOT_surfxml_route] = NULL;
278 surfxml_statenames[AL_surfxml_route] = NULL;
279 surfxml_statenames[S_surfxml_route] = "route";
280 surfxml_statenames[S_surfxml_route_1] = "route";
281 surfxml_statenames[S_surfxml_route_2] = "route";
282 surfxml_statenames[E_surfxml_route] = "route";
283 surfxml_statenames[ROOT_surfxml_route_element] = NULL;
284 surfxml_statenames[AL_surfxml_route_element] = NULL;
285 surfxml_statenames[E_surfxml_route_element] = "route_element";
286 surfxml_statenames[ROOT_surfxml_process] = NULL;
287 surfxml_statenames[AL_surfxml_process] = NULL;
288 surfxml_statenames[S_surfxml_process] = "process";
289 surfxml_statenames[S_surfxml_process_1] = "process";
290 surfxml_statenames[S_surfxml_process_2] = "process";
291 surfxml_statenames[E_surfxml_process] = "process";
292 surfxml_statenames[ROOT_surfxml_argument] = NULL;
293 surfxml_statenames[AL_surfxml_argument] = NULL;
294 surfxml_statenames[E_surfxml_argument] = "argument";
297 /* COMMENTS and PIs: handled uniformly for efficiency. */
299 <ROOT_surfxml_platform_description,AL_surfxml_platform_description,S_surfxml_platform_description,S_surfxml_platform_description_1,S_surfxml_platform_description_2,E_surfxml_platform_description,ROOT_surfxml_include,AL_surfxml_include,S_surfxml_include,S_surfxml_include_1,S_surfxml_include_2,E_surfxml_include,ROOT_surfxml_cpu,AL_surfxml_cpu,E_surfxml_cpu,ROOT_surfxml_network_link,AL_surfxml_network_link,E_surfxml_network_link,ROOT_surfxml_route,AL_surfxml_route,S_surfxml_route,S_surfxml_route_1,S_surfxml_route_2,E_surfxml_route,ROOT_surfxml_route_element,AL_surfxml_route_element,E_surfxml_route_element,ROOT_surfxml_process,AL_surfxml_process,S_surfxml_process,S_surfxml_process_1,S_surfxml_process_2,E_surfxml_process,ROOT_surfxml_argument,AL_surfxml_argument,E_surfxml_argument,PROLOG,DOCTYPE,EPILOG>{
300 "<!--" ENTER(INCOMMENT);
308 <<EOF>> FAIL("EOF in comment.");
314 <<EOF>> FAIL("EOF in PI (processing instruction).");
317 /* SPACES: skipped uniformly */
319 <ROOT_surfxml_platform_description,AL_surfxml_platform_description,S_surfxml_platform_description,S_surfxml_platform_description_1,S_surfxml_platform_description_2,E_surfxml_platform_description,ROOT_surfxml_include,AL_surfxml_include,S_surfxml_include,S_surfxml_include_1,S_surfxml_include_2,E_surfxml_include,ROOT_surfxml_cpu,AL_surfxml_cpu,E_surfxml_cpu,ROOT_surfxml_network_link,AL_surfxml_network_link,E_surfxml_network_link,ROOT_surfxml_route,AL_surfxml_route,S_surfxml_route,S_surfxml_route_1,S_surfxml_route_2,E_surfxml_route,ROOT_surfxml_route_element,AL_surfxml_route_element,E_surfxml_route_element,ROOT_surfxml_process,AL_surfxml_process,S_surfxml_process,S_surfxml_process_1,S_surfxml_process_2,E_surfxml_process,ROOT_surfxml_argument,AL_surfxml_argument,E_surfxml_argument,PROLOG,DOCTYPE,EPILOG>{S} SKIP;
321 /* PROLOG: determine root element and process it. */
324 "<?xml"({S}version{Eq}(\'{VersionNum}\'|\"{VersionNum}\"))?({S}encoding{Eq}(\'[^']*\'|\"[^"]*\"))?"?>" SET(DOCTYPE);
325 "<?xml"[^>]*">" FAIL("Bad declaration %s.",yytext);
329 "<!DOCTYPE"{S}"argument"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_surfxml_argument);
330 "<!DOCTYPE"{S}"route_element"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_surfxml_route_element);
331 "<!DOCTYPE"{S}"cpu"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_surfxml_cpu);
332 "<!DOCTYPE"{S}"include"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_surfxml_include);
333 "<!DOCTYPE"{S}"route"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_surfxml_route);
334 "<!DOCTYPE"{S}"platform_description"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_surfxml_platform_description);
335 "<!DOCTYPE"{S}"network_link"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_surfxml_network_link);
336 "<!DOCTYPE"{S}"process"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_surfxml_process);
337 "<!"[^>-][^>]*">" FAIL("Bad declaration %s.",yytext);
338 . FAIL("Unexpected character `%c' in prolog.", yytext[0]);
339 <<EOF>> FAIL("EOF in prolog.");
342 /* RULES DERIVED FROM DTD. */
344 /* <!-- Small DTD for SURF based tools. --> */
346 <ROOT_surfxml_platform_description>"<platform_description"{s} {
347 A_surfxml_platform_description_version = "0.0";
348 ENTER(AL_surfxml_platform_description);
351 <AL_surfxml_platform_description>{
352 "version"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_platform_description_version);
353 "version"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_platform_description_version);
356 LEAVE; STag_surfxml_platform_description();surfxml_pcdata = NULL; ENTER(S_surfxml_platform_description);
359 LEAVE; STag_surfxml_platform_description(); surfxml_pcdata = NULL; ETag_surfxml_platform_description();
361 case ROOT_surfxml_platform_description: SET(EPILOG); break;
364 . FAIL("Unexpected character `%c' in attribute list of platform_description element.", yytext[0]);
365 {Name} FAIL("Bad attribute `%s' in `platform_description' element start tag.",yytext);
366 <<EOF>> FAIL("EOF in attribute list of `platform_description' element.");
369 <E_surfxml_platform_description,S_surfxml_platform_description_2,S_surfxml_platform_description>{
370 "</platform_description"{s}">" {
372 ETag_surfxml_platform_description();
374 case ROOT_surfxml_platform_description: SET(EPILOG); break;
377 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</platform_description>' expected.",yytext);
378 . FAIL("Unexpected character `%c': `</platform_description>' expected.",yytext[0]);
379 <<EOF>> FAIL("Premature EOF: `</platform_description>' expected.");
382 <ROOT_surfxml_include,S_surfxml_platform_description_2,S_surfxml_include,S_surfxml_include_2,S_surfxml_platform_description_1,S_surfxml_include_1,S_surfxml_platform_description>"<include"{s} {
383 A_surfxml_include_file = NULL;
384 ENTER(AL_surfxml_include);
387 <AL_surfxml_include>{
388 "file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_include_file);
389 "file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_include_file);
392 if (!A_surfxml_include_file) FAIL("Required attribute `file' not set for `include' element.");
393 LEAVE; STag_surfxml_include();surfxml_pcdata = NULL; ENTER(S_surfxml_include);
396 if (!A_surfxml_include_file) FAIL("Required attribute `file' not set for `include' element.");
397 LEAVE; STag_surfxml_include(); surfxml_pcdata = NULL; ETag_surfxml_include();
399 case S_surfxml_platform_description_2: case S_surfxml_platform_description_1: case S_surfxml_platform_description: SET(S_surfxml_platform_description_2); break;
400 case ROOT_surfxml_include: SET(EPILOG); break;
401 case S_surfxml_include: case S_surfxml_include_2: case S_surfxml_include_1: SET(S_surfxml_include_2); break;
404 . FAIL("Unexpected character `%c' in attribute list of include element.", yytext[0]);
405 {Name} FAIL("Bad attribute `%s' in `include' element start tag.",yytext);
406 <<EOF>> FAIL("EOF in attribute list of `include' element.");
409 <E_surfxml_include,S_surfxml_include,S_surfxml_include_2>{
412 ETag_surfxml_include();
414 case S_surfxml_platform_description_2: case S_surfxml_platform_description_1: case S_surfxml_platform_description: SET(S_surfxml_platform_description_2); break;
415 case ROOT_surfxml_include: SET(EPILOG); break;
416 case S_surfxml_include: case S_surfxml_include_2: case S_surfxml_include_1: SET(S_surfxml_include_2); break;
419 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</include>' expected.",yytext);
420 . FAIL("Unexpected character `%c': `</include>' expected.",yytext[0]);
421 <<EOF>> FAIL("Premature EOF: `</include>' expected.");
424 <ROOT_surfxml_cpu,S_surfxml_platform_description_2,S_surfxml_include,S_surfxml_include_2,S_surfxml_platform_description_1,S_surfxml_include_1,S_surfxml_platform_description>"<cpu"{s} {
425 A_surfxml_cpu_name = NULL;
426 A_surfxml_cpu_power = NULL;
427 A_surfxml_cpu_availability = "1.0";
428 A_surfxml_cpu_availability_file = NULL;
429 A_surfxml_cpu_state = A_surfxml_cpu_state_ON;
430 A_surfxml_cpu_state_file = NULL;
431 A_surfxml_cpu_interference_send = "1.0";
432 A_surfxml_cpu_interference_recv = "1.0";
433 A_surfxml_cpu_interference_send_recv = "1.0";
434 A_surfxml_cpu_max_outgoing_rate = "-1.0";
435 ENTER(AL_surfxml_cpu);
439 "name"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_cpu_name);
440 "name"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_cpu_name);
442 "power"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_cpu_power);
443 "power"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_cpu_power);
445 "availability"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_cpu_availability);
446 "availability"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_cpu_availability);
448 "availability_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_cpu_availability_file);
449 "availability_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_cpu_availability_file);
452 "state"{Eq}"\"ON\"" A_surfxml_cpu_state = A_surfxml_cpu_state_ON;
454 "state"{Eq}"\"OFF\"" A_surfxml_cpu_state = A_surfxml_cpu_state_OFF;
456 "state_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_cpu_state_file);
457 "state_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_cpu_state_file);
459 "interference_send"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_cpu_interference_send);
460 "interference_send"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_cpu_interference_send);
462 "interference_recv"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_cpu_interference_recv);
463 "interference_recv"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_cpu_interference_recv);
465 "interference_send_recv"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_cpu_interference_send_recv);
466 "interference_send_recv"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_cpu_interference_send_recv);
468 "max_outgoing_rate"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_cpu_max_outgoing_rate);
469 "max_outgoing_rate"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_cpu_max_outgoing_rate);
472 if (!A_surfxml_cpu_name) FAIL("Required attribute `name' not set for `cpu' element.");
473 if (!A_surfxml_cpu_power) FAIL("Required attribute `power' not set for `cpu' element.");
474 LEAVE; STag_surfxml_cpu();surfxml_pcdata = NULL; ENTER(E_surfxml_cpu);
477 if (!A_surfxml_cpu_name) FAIL("Required attribute `name' not set for `cpu' element.");
478 if (!A_surfxml_cpu_power) FAIL("Required attribute `power' not set for `cpu' element.");
479 LEAVE; STag_surfxml_cpu(); surfxml_pcdata = NULL; ETag_surfxml_cpu();
481 case S_surfxml_platform_description_2: case S_surfxml_platform_description_1: case S_surfxml_platform_description: SET(S_surfxml_platform_description_2); break;
482 case ROOT_surfxml_cpu: SET(EPILOG); break;
483 case S_surfxml_include: case S_surfxml_include_2: case S_surfxml_include_1: SET(S_surfxml_include_2); break;
486 . FAIL("Unexpected character `%c' in attribute list of cpu element.", yytext[0]);
487 {Name} FAIL("Bad attribute `%s' in `cpu' element start tag.",yytext);
488 <<EOF>> FAIL("EOF in attribute list of `cpu' element.");
496 case S_surfxml_platform_description_2: case S_surfxml_platform_description_1: case S_surfxml_platform_description: SET(S_surfxml_platform_description_2); break;
497 case ROOT_surfxml_cpu: SET(EPILOG); break;
498 case S_surfxml_include: case S_surfxml_include_2: case S_surfxml_include_1: SET(S_surfxml_include_2); break;
501 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</cpu>' expected.",yytext);
502 . FAIL("Unexpected character `%c': `</cpu>' expected.",yytext[0]);
503 <<EOF>> FAIL("Premature EOF: `</cpu>' expected.");
506 <ROOT_surfxml_network_link,S_surfxml_platform_description_2,S_surfxml_include,S_surfxml_include_2,S_surfxml_platform_description_1,S_surfxml_include_1,S_surfxml_platform_description>"<network_link"{s} {
507 A_surfxml_network_link_name = NULL;
508 A_surfxml_network_link_bandwidth = NULL;
509 A_surfxml_network_link_bandwidth_file = NULL;
510 A_surfxml_network_link_latency = "0.0";
511 A_surfxml_network_link_latency_file = NULL;
512 A_surfxml_network_link_state = A_surfxml_network_link_state_ON;
513 A_surfxml_network_link_state_file = NULL;
514 A_surfxml_network_link_sharing_policy = A_surfxml_network_link_sharing_policy_SHARED;
515 ENTER(AL_surfxml_network_link);
518 <AL_surfxml_network_link>{
519 "name"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_network_link_name);
520 "name"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_network_link_name);
522 "bandwidth"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_network_link_bandwidth);
523 "bandwidth"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_network_link_bandwidth);
525 "bandwidth_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_network_link_bandwidth_file);
526 "bandwidth_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_network_link_bandwidth_file);
528 "latency"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_network_link_latency);
529 "latency"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_network_link_latency);
531 "latency_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_network_link_latency_file);
532 "latency_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_network_link_latency_file);
535 "state"{Eq}"\"ON\"" A_surfxml_network_link_state = A_surfxml_network_link_state_ON;
537 "state"{Eq}"\"OFF\"" A_surfxml_network_link_state = A_surfxml_network_link_state_OFF;
539 "state_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_network_link_state_file);
540 "state_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_network_link_state_file);
542 "sharing_policy"{Eq}"'SHARED'" |
543 "sharing_policy"{Eq}"\"SHARED\"" A_surfxml_network_link_sharing_policy = A_surfxml_network_link_sharing_policy_SHARED;
544 "sharing_policy"{Eq}"'FATPIPE'" |
545 "sharing_policy"{Eq}"\"FATPIPE\"" A_surfxml_network_link_sharing_policy = A_surfxml_network_link_sharing_policy_FATPIPE;
548 if (!A_surfxml_network_link_name) FAIL("Required attribute `name' not set for `network_link' element.");
549 if (!A_surfxml_network_link_bandwidth) FAIL("Required attribute `bandwidth' not set for `network_link' element.");
550 LEAVE; STag_surfxml_network_link();surfxml_pcdata = NULL; ENTER(E_surfxml_network_link);
553 if (!A_surfxml_network_link_name) FAIL("Required attribute `name' not set for `network_link' element.");
554 if (!A_surfxml_network_link_bandwidth) FAIL("Required attribute `bandwidth' not set for `network_link' element.");
555 LEAVE; STag_surfxml_network_link(); surfxml_pcdata = NULL; ETag_surfxml_network_link();
557 case S_surfxml_platform_description_2: case S_surfxml_platform_description_1: case S_surfxml_platform_description: SET(S_surfxml_platform_description_2); break;
558 case ROOT_surfxml_network_link: SET(EPILOG); break;
559 case S_surfxml_include: case S_surfxml_include_2: case S_surfxml_include_1: SET(S_surfxml_include_2); break;
562 . FAIL("Unexpected character `%c' in attribute list of network_link element.", yytext[0]);
563 {Name} FAIL("Bad attribute `%s' in `network_link' element start tag.",yytext);
564 <<EOF>> FAIL("EOF in attribute list of `network_link' element.");
567 <E_surfxml_network_link>{
568 "</network_link"{s}">" {
570 ETag_surfxml_network_link();
572 case S_surfxml_platform_description_2: case S_surfxml_platform_description_1: case S_surfxml_platform_description: SET(S_surfxml_platform_description_2); break;
573 case ROOT_surfxml_network_link: SET(EPILOG); break;
574 case S_surfxml_include: case S_surfxml_include_2: case S_surfxml_include_1: SET(S_surfxml_include_2); break;
577 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</network_link>' expected.",yytext);
578 . FAIL("Unexpected character `%c': `</network_link>' expected.",yytext[0]);
579 <<EOF>> FAIL("Premature EOF: `</network_link>' expected.");
582 <ROOT_surfxml_route,S_surfxml_platform_description_2,S_surfxml_include,S_surfxml_include_2,S_surfxml_platform_description_1,S_surfxml_include_1,S_surfxml_platform_description>"<route"{s} {
583 A_surfxml_route_src = NULL;
584 A_surfxml_route_dst = NULL;
585 A_surfxml_route_impact_on_src = "0.0";
586 A_surfxml_route_impact_on_dst = "0.0";
587 A_surfxml_route_impact_on_src_with_other_recv = "0.0";
588 A_surfxml_route_impact_on_dst_with_other_send = "0.0";
589 ENTER(AL_surfxml_route);
593 "src"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_route_src);
594 "src"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_route_src);
596 "dst"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_route_dst);
597 "dst"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_route_dst);
599 "impact_on_src"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_route_impact_on_src);
600 "impact_on_src"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_route_impact_on_src);
602 "impact_on_dst"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_route_impact_on_dst);
603 "impact_on_dst"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_route_impact_on_dst);
605 "impact_on_src_with_other_recv"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_route_impact_on_src_with_other_recv);
606 "impact_on_src_with_other_recv"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_route_impact_on_src_with_other_recv);
608 "impact_on_dst_with_other_send"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_route_impact_on_dst_with_other_send);
609 "impact_on_dst_with_other_send"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_route_impact_on_dst_with_other_send);
612 if (!A_surfxml_route_src) FAIL("Required attribute `src' not set for `route' element.");
613 if (!A_surfxml_route_dst) FAIL("Required attribute `dst' not set for `route' element.");
614 LEAVE; STag_surfxml_route();surfxml_pcdata = NULL; ENTER(S_surfxml_route);
617 if (!A_surfxml_route_src) FAIL("Required attribute `src' not set for `route' element.");
618 if (!A_surfxml_route_dst) FAIL("Required attribute `dst' not set for `route' element.");
619 LEAVE; STag_surfxml_route(); surfxml_pcdata = NULL; ETag_surfxml_route();
621 case S_surfxml_platform_description_2: case S_surfxml_platform_description_1: case S_surfxml_platform_description: SET(S_surfxml_platform_description_2); break;
622 case ROOT_surfxml_route: SET(EPILOG); break;
623 case S_surfxml_include: case S_surfxml_include_2: case S_surfxml_include_1: SET(S_surfxml_include_2); break;
626 . FAIL("Unexpected character `%c' in attribute list of route element.", yytext[0]);
627 {Name} FAIL("Bad attribute `%s' in `route' element start tag.",yytext);
628 <<EOF>> FAIL("EOF in attribute list of `route' element.");
631 <S_surfxml_route,S_surfxml_route_2,E_surfxml_route>{
634 ETag_surfxml_route();
636 case S_surfxml_platform_description_2: case S_surfxml_platform_description_1: case S_surfxml_platform_description: SET(S_surfxml_platform_description_2); break;
637 case ROOT_surfxml_route: SET(EPILOG); break;
638 case S_surfxml_include: case S_surfxml_include_2: case S_surfxml_include_1: SET(S_surfxml_include_2); break;
641 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</route>' expected.",yytext);
642 . FAIL("Unexpected character `%c': `</route>' expected.",yytext[0]);
643 <<EOF>> FAIL("Premature EOF: `</route>' expected.");
646 <ROOT_surfxml_route_element,S_surfxml_route_1,S_surfxml_route,S_surfxml_route_2>"<route_element"{s} {
647 A_surfxml_route_element_name = NULL;
648 ENTER(AL_surfxml_route_element);
651 <AL_surfxml_route_element>{
652 "name"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_route_element_name);
653 "name"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_route_element_name);
656 if (!A_surfxml_route_element_name) FAIL("Required attribute `name' not set for `route_element' element.");
657 LEAVE; STag_surfxml_route_element();surfxml_pcdata = NULL; ENTER(E_surfxml_route_element);
660 if (!A_surfxml_route_element_name) FAIL("Required attribute `name' not set for `route_element' element.");
661 LEAVE; STag_surfxml_route_element(); surfxml_pcdata = NULL; ETag_surfxml_route_element();
663 case S_surfxml_route_1: case S_surfxml_route: case S_surfxml_route_2: SET(S_surfxml_route_2); break;
664 case ROOT_surfxml_route_element: SET(EPILOG); break;
667 . FAIL("Unexpected character `%c' in attribute list of route_element element.", yytext[0]);
668 {Name} FAIL("Bad attribute `%s' in `route_element' element start tag.",yytext);
669 <<EOF>> FAIL("EOF in attribute list of `route_element' element.");
672 <E_surfxml_route_element>{
673 "</route_element"{s}">" {
675 ETag_surfxml_route_element();
677 case S_surfxml_route_1: case S_surfxml_route: case S_surfxml_route_2: SET(S_surfxml_route_2); break;
678 case ROOT_surfxml_route_element: SET(EPILOG); break;
681 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</route_element>' expected.",yytext);
682 . FAIL("Unexpected character `%c': `</route_element>' expected.",yytext[0]);
683 <<EOF>> FAIL("Premature EOF: `</route_element>' expected.");
686 <ROOT_surfxml_process,S_surfxml_platform_description_2,S_surfxml_include,S_surfxml_include_2,S_surfxml_platform_description_1,S_surfxml_include_1,S_surfxml_platform_description>"<process"{s} {
687 A_surfxml_process_host = NULL;
688 A_surfxml_process_function = NULL;
689 A_surfxml_process_start_time = "-1.0";
690 A_surfxml_process_kill_time = "-1.0";
691 ENTER(AL_surfxml_process);
694 <AL_surfxml_process>{
695 "host"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_process_host);
696 "host"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_process_host);
698 "function"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_process_function);
699 "function"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_process_function);
701 "start_time"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_process_start_time);
702 "start_time"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_process_start_time);
704 "kill_time"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_process_kill_time);
705 "kill_time"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_process_kill_time);
708 if (!A_surfxml_process_host) FAIL("Required attribute `host' not set for `process' element.");
709 if (!A_surfxml_process_function) FAIL("Required attribute `function' not set for `process' element.");
710 LEAVE; STag_surfxml_process();surfxml_pcdata = NULL; ENTER(S_surfxml_process);
713 if (!A_surfxml_process_host) FAIL("Required attribute `host' not set for `process' element.");
714 if (!A_surfxml_process_function) FAIL("Required attribute `function' not set for `process' element.");
715 LEAVE; STag_surfxml_process(); surfxml_pcdata = NULL; ETag_surfxml_process();
717 case S_surfxml_platform_description_2: case S_surfxml_platform_description_1: case S_surfxml_platform_description: SET(S_surfxml_platform_description_2); break;
718 case ROOT_surfxml_process: SET(EPILOG); break;
719 case S_surfxml_include: case S_surfxml_include_2: case S_surfxml_include_1: SET(S_surfxml_include_2); break;
722 . FAIL("Unexpected character `%c' in attribute list of process element.", yytext[0]);
723 {Name} FAIL("Bad attribute `%s' in `process' element start tag.",yytext);
724 <<EOF>> FAIL("EOF in attribute list of `process' element.");
727 <S_surfxml_process,E_surfxml_process,S_surfxml_process_2>{
730 ETag_surfxml_process();
732 case S_surfxml_platform_description_2: case S_surfxml_platform_description_1: case S_surfxml_platform_description: SET(S_surfxml_platform_description_2); break;
733 case ROOT_surfxml_process: SET(EPILOG); break;
734 case S_surfxml_include: case S_surfxml_include_2: case S_surfxml_include_1: SET(S_surfxml_include_2); break;
737 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</process>' expected.",yytext);
738 . FAIL("Unexpected character `%c': `</process>' expected.",yytext[0]);
739 <<EOF>> FAIL("Premature EOF: `</process>' expected.");
742 <ROOT_surfxml_argument,S_surfxml_process_1,S_surfxml_process,S_surfxml_process_2>"<argument"{s} {
743 A_surfxml_argument_value = NULL;
744 ENTER(AL_surfxml_argument);
747 <AL_surfxml_argument>{
748 "value"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_argument_value);
749 "value"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_argument_value);
752 if (!A_surfxml_argument_value) FAIL("Required attribute `value' not set for `argument' element.");
753 LEAVE; STag_surfxml_argument();surfxml_pcdata = NULL; ENTER(E_surfxml_argument);
756 if (!A_surfxml_argument_value) FAIL("Required attribute `value' not set for `argument' element.");
757 LEAVE; STag_surfxml_argument(); surfxml_pcdata = NULL; ETag_surfxml_argument();
759 case S_surfxml_process_1: case S_surfxml_process: case S_surfxml_process_2: SET(S_surfxml_process_2); break;
760 case ROOT_surfxml_argument: SET(EPILOG); break;
763 . FAIL("Unexpected character `%c' in attribute list of argument element.", yytext[0]);
764 {Name} FAIL("Bad attribute `%s' in `argument' element start tag.",yytext);
765 <<EOF>> FAIL("EOF in attribute list of `argument' element.");
768 <E_surfxml_argument>{
771 ETag_surfxml_argument();
773 case S_surfxml_process_1: case S_surfxml_process: case S_surfxml_process_2: SET(S_surfxml_process_2); break;
774 case ROOT_surfxml_argument: SET(EPILOG); break;
777 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</argument>' expected.",yytext);
778 . FAIL("Unexpected character `%c': `</argument>' expected.",yytext[0]);
779 <<EOF>> FAIL("Premature EOF: `</argument>' expected.");
782 /* EPILOG: after the root element. */
785 . {SET(PROLOG); yyless(0); CLEANUP; return -1;}
789 /* CHARACTER DATA. */
791 <IMPOSSIBLE,VALUE1,VALUE2>{
792 /* Non-defined standard entities... */
793 "&" BUFFERPUTC('&');
794 "<" BUFFERPUTC('<');
795 ">" BUFFERPUTC('>');
796 "'" BUFFERPUTC('\'');
797 """ BUFFERPUTC('"');
799 /* Character entities. */
800 "&#"[[:digit:]]+";" BUFFERPUTC((unsigned char)atoi(yytext+2));
801 "&#x"[[:xdigit:]]+";" BUFFERPUTC((unsigned char)strtol(yytext+3,NULL,16));
804 <IMPOSSIBLE,VALUE1,VALUE2,CDATA>{
808 "\n\r" BUFFERPUTC('\n');
812 "<![CDATA[" ENTER(CDATA);
813 "]""]>" FAIL("Unexpected `]""]>' in character data.");
817 \' BUFFERDONE; LEAVE;
818 <<EOF>> FAIL("EOF in literal (\"'\" expected).");
822 \" BUFFERDONE; LEAVE;
823 <<EOF>> FAIL("EOF in literal (`\"' expected).");
826 <IMPOSSIBLE,VALUE1,VALUE2>{
827 [^<&] BUFFERPUTC(yytext[0]);
828 [<&] FAIL("Spurious `%c' in character data.",yytext[0]);
833 /* "]""]" BUFFERPUTC(yytext[0]); BUFFERPUTC(yytext[1]); */
834 . BUFFERPUTC(yytext[0]);
835 <<EOF>> FAIL("EOF in CDATA section.");
838 /* Impossible rules to avoid warnings from flex(1). */
839 /* Ideally, this should be replaced by code in flexml.pl that
840 generates just the states not covered by other rules. */
842 .|[\n] FAIL("Syntax error on character `%c'.", yytext[0]);
847 /* Element context stack lookup. */
848 int surfxml_element_context(int i)
850 return (0<i && i<yy_start_stack_depth
851 ? yy_start_stack[yy_start_stack_ptr - i]
856 void print_yy_stack(char* fmt, ...)
858 int i = 0; va_list ap; va_start(ap, fmt);
859 vfprintf(stderr, fmt, ap);
860 for (i=1; i<yy_start_stack_ptr; i++)
861 fprintf(stderr, "%s/", surfxml_statenames[yy_start_stack[i] ]);
862 fprintf(stderr,"%s\n", surfxml_statenames[YY_START]);
866 static void debug_enter(int state, const char* statename) {
867 yy_push_state(state);
868 if (yy_flex_debug) print_yy_stack("--ENTER(%s) : ",statename);
871 static void debug_leave(void) {
872 if (yy_flex_debug) print_yy_stack("--LEAVE : ");
876 static void debug_set(int state, const char* statename) {
878 if (yy_flex_debug) print_yy_stack("--SET(%s) : ",statename);
882 enum {flexml_max_err_msg_size = 512};
884 static char flexml_err_msg[flexml_max_err_msg_size];
885 const char * surfxml_parse_err_msg()
887 return flexml_err_msg;
890 static void reset_surfxml_parse_err_msg()
892 flexml_err_msg[0] = '\0';
896 static void cleanup(void)
898 if (surfxml_statenames) {
899 free(surfxml_statenames);
900 surfxml_statenames = NULL;
905 static int fail(const char* fmt, ...)
907 int chars_left, used;
908 va_list ap; va_start(ap, fmt);
909 #ifdef FLEXML_yylineno
910 used = sprintf(flexml_err_msg,
911 "Invalid XML (XML input line %d, state %d): ",
914 used = sprintf(flexml_err_msg,
915 "Invalid XML (state %d): ",
918 chars_left = flexml_max_err_msg_size - used - 1;
919 vsnprintf(flexml_err_msg + used, chars_left, fmt, ap);
922 #ifndef FLEXML_quiet_parser
923 /* print directly to sdterr */
924 fprintf(stderr, "%s\n", flexml_err_msg);
925 flexml_err_msg[0] = '\0';