1 /* Validating XML processor for surf/surfxml.dtd.
2 * Generated 2006/07/18 21:02:15.
4 * This program was generated with the FleXML XML processor generator.
5 * FleXML is Copyright (C) 1999-2005 Kristoffer Rose. All rights reserved.
6 * FleXML is Copyright (C) 2003-2006 Martin Quinson. All rights reserved.
7 * (Id: flexml.pl,v 1.53 2006/07/18 12:12:06 mquinson Exp).
9 * There are two, intertwined parts to this program, part A and part B.
14 * Some parts, here collectively called "Part A", are found in the
15 * FleXML package. They are Copyright (C) 1999-2005 Kristoffer Rose
16 * and Copyright (C) 2003-2006 Martin Quinson. All rights reserved.
18 * You can redistribute, use, perform, display and/or modify "Part A"
19 * provided the following two conditions hold:
21 * 1. The program is distributed WITHOUT ANY WARRANTY from the author of
22 * FleXML; without even the implied warranty of MERCHANTABILITY or
23 * FITNESS FOR A PARTICULAR PURPOSE.
25 * 2. The program distribution conditions do not in any way affect the
26 * distribution conditions of the FleXML system used to generate this
27 * file or any version of FleXML derived from that system.
29 * Notice that these are explicit rights granted to you for files
30 * generated by the FleXML system. For your rights in connection with
31 * the FleXML system itself please consult the GNU General Public License.
36 * The other parts, here collectively called "Part B", and which came
37 * from the DTD used by FleXML to generate this program, can be
38 * distributed (or not, as the case may be) under the terms of whoever
39 * wrote them, provided these terms respect and obey the two conditions
40 * above under the heading "Part A".
42 * The author of and contributors to FleXML specifically disclaim
43 * any copyright interest in "Part B", unless "Part B" was written
44 * by the author of or contributors to FleXML.
50 /* Version strings. */
51 const char rcs_surfxml_flexml_skeleton[] =
52 "$" "Id: skel,v 1.31 2006/07/18 18:21:13 mquinson Exp $";
53 const char rcs_surfxml_flexml[] =
54 "$" "Id: flexml.pl,v 1.53 2006/07/18 12:12:06 mquinson Exp $";
64 /* Generated definitions. */
65 #define FLEXML_yylineno
66 #define FLEXML_BUFFERSTACKSIZE 1000000
68 /* XML processor api. */
69 /* FleXML-provided data. */
70 const char* surfxml_pcdata;
71 AT_surfxml_network_link_bandwidth A_surfxml_network_link_bandwidth;
72 AT_surfxml_process_host A_surfxml_process_host;
73 AT_surfxml_network_link_latency_file A_surfxml_network_link_latency_file;
74 AT_surfxml_route_impact_on_dst_with_other_send A_surfxml_route_impact_on_dst_with_other_send;
75 AT_surfxml_cpu_interference_send_recv A_surfxml_cpu_interference_send_recv;
76 AT_surfxml_route_impact_on_dst A_surfxml_route_impact_on_dst;
77 AT_surfxml_platform_description_version A_surfxml_platform_description_version;
78 AT_surfxml_route_impact_on_src_with_other_recv A_surfxml_route_impact_on_src_with_other_recv;
79 AT_surfxml_route_element_name A_surfxml_route_element_name;
80 AT_surfxml_process_start_time A_surfxml_process_start_time;
81 AT_surfxml_process_function A_surfxml_process_function;
82 AT_surfxml_cpu_state A_surfxml_cpu_state;
83 AT_surfxml_cpu_interference_send A_surfxml_cpu_interference_send;
84 AT_surfxml_network_link_bandwidth_file A_surfxml_network_link_bandwidth_file;
85 AT_surfxml_cpu_name A_surfxml_cpu_name;
86 AT_surfxml_process_kill_time A_surfxml_process_kill_time;
87 AT_surfxml_network_link_state A_surfxml_network_link_state;
88 AT_surfxml_cpu_availability_file A_surfxml_cpu_availability_file;
89 AT_surfxml_argument_value A_surfxml_argument_value;
90 AT_surfxml_route_src A_surfxml_route_src;
91 AT_surfxml_route_impact_on_src A_surfxml_route_impact_on_src;
92 AT_surfxml_cpu_max_outgoing_rate A_surfxml_cpu_max_outgoing_rate;
93 AT_surfxml_cpu_availability A_surfxml_cpu_availability;
94 AT_surfxml_cpu_interference_recv A_surfxml_cpu_interference_recv;
95 AT_surfxml_network_link_name A_surfxml_network_link_name;
96 AT_surfxml_cpu_power A_surfxml_cpu_power;
97 AT_surfxml_include_file A_surfxml_include_file;
98 AT_surfxml_network_link_sharing_policy A_surfxml_network_link_sharing_policy;
99 AT_surfxml_route_dst A_surfxml_route_dst;
100 AT_surfxml_network_link_latency A_surfxml_network_link_latency;
101 AT_surfxml_cpu_state_file A_surfxml_cpu_state_file;
102 AT_surfxml_network_link_state_file A_surfxml_network_link_state_file;
106 # define ENTER(state) debug_enter(state,#state)
107 # define LEAVE debug_leave()
108 # define SET(state) debug_set(state,#state)
109 static void debug_enter(int, const char*);
110 static void debug_leave(void);
111 static void debug_set(int, const char*);
113 # define ENTER(state) (yy_push_state(state))
114 # define LEAVE (yy_pop_state())
115 # define SET(state) BEGIN(state)
118 /* Generic actions. */
119 #define SKIP /*skip*/
120 #define SUCCEED CLEANUP; return 0
122 #define FAIL return fail
123 static int fail(const char*, ...);
124 const char * surfxml_parse_err_msg(void);
127 static void cleanup(void);
128 #define CLEANUP cleanup()
130 /* Text buffer stack handling. */
131 static char bufferstack[FLEXML_BUFFERSTACKSIZE];
132 static char* limit = bufferstack + FLEXML_BUFFERSTACKSIZE;
133 typedef struct BufferLast_s {
134 struct BufferLast_s *old; const char* saved; char new1[1];
136 #ifdef FLEXML_HasMixed
137 static BufferLast* last = (BufferLast*)0;
139 static char* next = bufferstack;
141 #define BUFFERSET(P) (P = next)
142 #define BUFFERPUTC(C) (assert(next<limit), *(next++) = (C))
143 #define BUFFERDONE (BUFFERPUTC('\0'))
145 #define BUFFERLITERAL(C,P) bufferliteral(C,&(P),yytext)
146 static void bufferliteral(char c, const char** pp, char* text)
148 char *s = strchr(text,c), *e = strrchr(text,c);
149 assert(s <= e); BUFFERSET(*pp);
151 if (isspace(*s)) { BUFFERPUTC(' '); while (isspace(*s)) ++s; }
157 #ifdef FLEXML_HasMixed
158 static void pushbuffer(const char* p)
160 BufferLast* l = (BufferLast*)next;
161 assert(next < limit);
168 static const char* popbuffer(void)
170 BufferLast* l = last;
171 assert(last != (BufferLast*)0);
178 /* General internal entities are `unput' back onto the input stream... */
179 #define ENTITYTEXT(T) \
180 { char *s = (T), *e = s+strlen(s);\
181 while (--e >= s) { unput(*e); }}
184 /* Flex standard options. */
186 %option noyy_top_state
192 /* Flex user-requested options. */
196 /* XML character classes (currently restricted to ASCII). */
198 /* "Common syntactic structures." */
202 /* "Names and Tokens." */
203 NameChar [A-Za-z0-9.:_-]
204 Name [A-Za-z_:]{NameChar}*
205 Names {Name}({S}{Name})*
206 Nmtoken ({NameChar})+
207 Nmtokens {Nmtoken}({S}{Nmtoken})*
210 VersionNum [a-zA-Z0-9_.:-]+
212 Literal \'[^'']*\'|\"[^""]*\"
214 /* Parser states (flex `exclusive start conditions'):
216 * PROLOG the XML prolog of the document before <?xml...>
217 * DOCTYPE the XML prolog of the document after <?xml...>
218 * EPILOG after the root element
219 * INCOMMENT inside an XML comment <!--....-->
220 * INPI inside an XML PI <?...?>
221 * VALUE1 inside a '...'-delimited literal
222 * VALUE2 inside a "..."-delimited literal
223 * CDATA inside a <![CDATA[...] ]> section.
224 * ROOT_<tag> expect root element <tag>
225 * AL_<tag> inside the attribute list for <tag>
226 * IN_<tag> inside a <tag> with element contents (ready for end tag)
227 * IMPOSSIBLE dummy to permit disabling rules; must be last
229 %x PROLOG DOCTYPE EPILOG INCOMMENT INPI VALUE1 VALUE2 CDATA
230 %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
231 %x ROOT_surfxml_include AL_surfxml_include S_surfxml_include S_surfxml_include_1 S_surfxml_include_2 E_surfxml_include
232 %x ROOT_surfxml_cpu AL_surfxml_cpu E_surfxml_cpu
233 %x ROOT_surfxml_network_link AL_surfxml_network_link E_surfxml_network_link
234 %x ROOT_surfxml_route AL_surfxml_route S_surfxml_route S_surfxml_route_1 S_surfxml_route_2 E_surfxml_route
235 %x ROOT_surfxml_route_element AL_surfxml_route_element E_surfxml_route_element
236 %x ROOT_surfxml_process AL_surfxml_process S_surfxml_process S_surfxml_process_1 S_surfxml_process_2 E_surfxml_process
237 %x ROOT_surfxml_argument AL_surfxml_argument E_surfxml_argument
242 const char* *surfxml_statenames=NULL;
247 /* Bypass Flex's default INITIAL state and begin by parsing the XML prolog. */
251 if(!surfxml_statenames) {surfxml_statenames= (const char **)calloc(IMPOSSIBLE,sizeof(char*));
252 surfxml_statenames[PROLOG] = NULL;
253 surfxml_statenames[DOCTYPE] = NULL;
254 surfxml_statenames[EPILOG] = NULL;
255 surfxml_statenames[INCOMMENT] = NULL;
256 surfxml_statenames[INPI] = NULL;
257 surfxml_statenames[VALUE1] = NULL;
258 surfxml_statenames[VALUE2] = NULL;
259 surfxml_statenames[CDATA] = NULL;
260 surfxml_statenames[ROOT_surfxml_platform_description] = NULL;
261 surfxml_statenames[AL_surfxml_platform_description] = NULL;
262 surfxml_statenames[S_surfxml_platform_description] = "platform_description";
263 surfxml_statenames[S_surfxml_platform_description_1] = "platform_description";
264 surfxml_statenames[S_surfxml_platform_description_2] = "platform_description";
265 surfxml_statenames[E_surfxml_platform_description] = "platform_description";
266 surfxml_statenames[ROOT_surfxml_include] = NULL;
267 surfxml_statenames[AL_surfxml_include] = NULL;
268 surfxml_statenames[S_surfxml_include] = "include";
269 surfxml_statenames[S_surfxml_include_1] = "include";
270 surfxml_statenames[S_surfxml_include_2] = "include";
271 surfxml_statenames[E_surfxml_include] = "include";
272 surfxml_statenames[ROOT_surfxml_cpu] = NULL;
273 surfxml_statenames[AL_surfxml_cpu] = NULL;
274 surfxml_statenames[E_surfxml_cpu] = "cpu";
275 surfxml_statenames[ROOT_surfxml_network_link] = NULL;
276 surfxml_statenames[AL_surfxml_network_link] = NULL;
277 surfxml_statenames[E_surfxml_network_link] = "network_link";
278 surfxml_statenames[ROOT_surfxml_route] = NULL;
279 surfxml_statenames[AL_surfxml_route] = NULL;
280 surfxml_statenames[S_surfxml_route] = "route";
281 surfxml_statenames[S_surfxml_route_1] = "route";
282 surfxml_statenames[S_surfxml_route_2] = "route";
283 surfxml_statenames[E_surfxml_route] = "route";
284 surfxml_statenames[ROOT_surfxml_route_element] = NULL;
285 surfxml_statenames[AL_surfxml_route_element] = NULL;
286 surfxml_statenames[E_surfxml_route_element] = "route_element";
287 surfxml_statenames[ROOT_surfxml_process] = NULL;
288 surfxml_statenames[AL_surfxml_process] = NULL;
289 surfxml_statenames[S_surfxml_process] = "process";
290 surfxml_statenames[S_surfxml_process_1] = "process";
291 surfxml_statenames[S_surfxml_process_2] = "process";
292 surfxml_statenames[E_surfxml_process] = "process";
293 surfxml_statenames[ROOT_surfxml_argument] = NULL;
294 surfxml_statenames[AL_surfxml_argument] = NULL;
295 surfxml_statenames[E_surfxml_argument] = "argument";
298 /* COMMENTS and PIs: handled uniformly for efficiency. */
300 <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>{
301 "<!--" ENTER(INCOMMENT);
309 <<EOF>> FAIL("EOF in comment.");
315 <<EOF>> FAIL("EOF in PI (processing instruction).");
318 /* SPACES: skipped uniformly */
320 <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;
322 /* PROLOG: determine root element and process it. */
325 "<?xml"({S}version{Eq}(\'{VersionNum}\'|\"{VersionNum}\"))?({S}encoding{Eq}(\'[^']*\'|\"[^"]*\"))?"?>" SET(DOCTYPE);
326 "<?xml"[^>]*">" FAIL("Bad declaration %s.",yytext);
330 "<!DOCTYPE"{S}"argument"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_surfxml_argument);
331 "<!DOCTYPE"{S}"route_element"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_surfxml_route_element);
332 "<!DOCTYPE"{S}"cpu"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_surfxml_cpu);
333 "<!DOCTYPE"{S}"include"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_surfxml_include);
334 "<!DOCTYPE"{S}"route"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_surfxml_route);
335 "<!DOCTYPE"{S}"platform_description"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_surfxml_platform_description);
336 "<!DOCTYPE"{S}"network_link"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_surfxml_network_link);
337 "<!DOCTYPE"{S}"process"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_surfxml_process);
338 "<!"[^>-][^>]*">" FAIL("Bad declaration %s.",yytext);
339 . FAIL("Unexpected character `%c' in prolog.", yytext[0]);
340 <<EOF>> FAIL("EOF in prolog.");
343 /* RULES DERIVED FROM DTD. */
345 /* <!-- Small DTD for SURF based tools. --> */
347 <ROOT_surfxml_platform_description>"<platform_description"{s} {
348 A_surfxml_platform_description_version = "0.0";
349 ENTER(AL_surfxml_platform_description);
352 <AL_surfxml_platform_description>{
353 "version"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_platform_description_version);
354 "version"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_platform_description_version);
357 LEAVE; STag_surfxml_platform_description();surfxml_pcdata = NULL; ENTER(S_surfxml_platform_description);
360 LEAVE; STag_surfxml_platform_description(); surfxml_pcdata = NULL; ETag_surfxml_platform_description();
362 case ROOT_surfxml_platform_description: SET(EPILOG); break;
365 . FAIL("Unexpected character `%c' in attribute list of platform_description element.", yytext[0]);
366 {Name} FAIL("Bad attribute `%s' in `platform_description' element start tag.",yytext);
367 <<EOF>> FAIL("EOF in attribute list of `platform_description' element.");
370 <E_surfxml_platform_description,S_surfxml_platform_description_2,S_surfxml_platform_description>{
371 "</platform_description"{s}">" {
373 ETag_surfxml_platform_description();
375 case ROOT_surfxml_platform_description: SET(EPILOG); break;
378 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</platform_description>' expected.",yytext);
379 . FAIL("Unexpected character `%c': `</platform_description>' expected.",yytext[0]);
380 <<EOF>> FAIL("Premature EOF: `</platform_description>' expected.");
383 <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} {
384 A_surfxml_include_file = NULL;
385 ENTER(AL_surfxml_include);
388 <AL_surfxml_include>{
389 "file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_include_file);
390 "file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_include_file);
393 if (!A_surfxml_include_file) FAIL("Required attribute `file' not set for `include' element.");
394 LEAVE; STag_surfxml_include();surfxml_pcdata = NULL; ENTER(S_surfxml_include);
397 if (!A_surfxml_include_file) FAIL("Required attribute `file' not set for `include' element.");
398 LEAVE; STag_surfxml_include(); surfxml_pcdata = NULL; ETag_surfxml_include();
400 case S_surfxml_platform_description_2: case S_surfxml_platform_description_1: case S_surfxml_platform_description: SET(S_surfxml_platform_description_2); break;
401 case ROOT_surfxml_include: SET(EPILOG); break;
402 case S_surfxml_include: case S_surfxml_include_2: case S_surfxml_include_1: SET(S_surfxml_include_2); break;
405 . FAIL("Unexpected character `%c' in attribute list of include element.", yytext[0]);
406 {Name} FAIL("Bad attribute `%s' in `include' element start tag.",yytext);
407 <<EOF>> FAIL("EOF in attribute list of `include' element.");
410 <E_surfxml_include,S_surfxml_include,S_surfxml_include_2>{
413 ETag_surfxml_include();
415 case S_surfxml_platform_description_2: case S_surfxml_platform_description_1: case S_surfxml_platform_description: SET(S_surfxml_platform_description_2); break;
416 case ROOT_surfxml_include: SET(EPILOG); break;
417 case S_surfxml_include: case S_surfxml_include_2: case S_surfxml_include_1: SET(S_surfxml_include_2); break;
420 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</include>' expected.",yytext);
421 . FAIL("Unexpected character `%c': `</include>' expected.",yytext[0]);
422 <<EOF>> FAIL("Premature EOF: `</include>' expected.");
425 <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} {
426 A_surfxml_cpu_name = NULL;
427 A_surfxml_cpu_power = NULL;
428 A_surfxml_cpu_availability = "1.0";
429 A_surfxml_cpu_availability_file = NULL;
430 A_surfxml_cpu_state = A_surfxml_cpu_state_ON;
431 A_surfxml_cpu_state_file = NULL;
432 A_surfxml_cpu_interference_send = "1.0";
433 A_surfxml_cpu_interference_recv = "1.0";
434 A_surfxml_cpu_interference_send_recv = "1.0";
435 A_surfxml_cpu_max_outgoing_rate = "-1.0";
436 ENTER(AL_surfxml_cpu);
440 "name"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_cpu_name);
441 "name"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_cpu_name);
443 "power"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_cpu_power);
444 "power"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_cpu_power);
446 "availability"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_cpu_availability);
447 "availability"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_cpu_availability);
449 "availability_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_cpu_availability_file);
450 "availability_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_cpu_availability_file);
453 "state"{Eq}"\"ON\"" A_surfxml_cpu_state = A_surfxml_cpu_state_ON;
455 "state"{Eq}"\"OFF\"" A_surfxml_cpu_state = A_surfxml_cpu_state_OFF;
457 "state_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_cpu_state_file);
458 "state_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_cpu_state_file);
460 "interference_send"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_cpu_interference_send);
461 "interference_send"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_cpu_interference_send);
463 "interference_recv"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_cpu_interference_recv);
464 "interference_recv"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_cpu_interference_recv);
466 "interference_send_recv"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_cpu_interference_send_recv);
467 "interference_send_recv"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_cpu_interference_send_recv);
469 "max_outgoing_rate"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_cpu_max_outgoing_rate);
470 "max_outgoing_rate"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_cpu_max_outgoing_rate);
473 if (!A_surfxml_cpu_name) FAIL("Required attribute `name' not set for `cpu' element.");
474 if (!A_surfxml_cpu_power) FAIL("Required attribute `power' not set for `cpu' element.");
475 LEAVE; STag_surfxml_cpu();surfxml_pcdata = NULL; ENTER(E_surfxml_cpu);
478 if (!A_surfxml_cpu_name) FAIL("Required attribute `name' not set for `cpu' element.");
479 if (!A_surfxml_cpu_power) FAIL("Required attribute `power' not set for `cpu' element.");
480 LEAVE; STag_surfxml_cpu(); surfxml_pcdata = NULL; ETag_surfxml_cpu();
482 case S_surfxml_platform_description_2: case S_surfxml_platform_description_1: case S_surfxml_platform_description: SET(S_surfxml_platform_description_2); break;
483 case ROOT_surfxml_cpu: SET(EPILOG); break;
484 case S_surfxml_include: case S_surfxml_include_2: case S_surfxml_include_1: SET(S_surfxml_include_2); break;
487 . FAIL("Unexpected character `%c' in attribute list of cpu element.", yytext[0]);
488 {Name} FAIL("Bad attribute `%s' in `cpu' element start tag.",yytext);
489 <<EOF>> FAIL("EOF in attribute list of `cpu' element.");
497 case S_surfxml_platform_description_2: case S_surfxml_platform_description_1: case S_surfxml_platform_description: SET(S_surfxml_platform_description_2); break;
498 case ROOT_surfxml_cpu: SET(EPILOG); break;
499 case S_surfxml_include: case S_surfxml_include_2: case S_surfxml_include_1: SET(S_surfxml_include_2); break;
502 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</cpu>' expected.",yytext);
503 . FAIL("Unexpected character `%c': `</cpu>' expected.",yytext[0]);
504 <<EOF>> FAIL("Premature EOF: `</cpu>' expected.");
507 <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} {
508 A_surfxml_network_link_name = NULL;
509 A_surfxml_network_link_bandwidth = NULL;
510 A_surfxml_network_link_bandwidth_file = NULL;
511 A_surfxml_network_link_latency = "0.0";
512 A_surfxml_network_link_latency_file = NULL;
513 A_surfxml_network_link_state = A_surfxml_network_link_state_ON;
514 A_surfxml_network_link_state_file = NULL;
515 A_surfxml_network_link_sharing_policy = A_surfxml_network_link_sharing_policy_SHARED;
516 ENTER(AL_surfxml_network_link);
519 <AL_surfxml_network_link>{
520 "name"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_network_link_name);
521 "name"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_network_link_name);
523 "bandwidth"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_network_link_bandwidth);
524 "bandwidth"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_network_link_bandwidth);
526 "bandwidth_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_network_link_bandwidth_file);
527 "bandwidth_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_network_link_bandwidth_file);
529 "latency"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_network_link_latency);
530 "latency"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_network_link_latency);
532 "latency_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_network_link_latency_file);
533 "latency_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_network_link_latency_file);
536 "state"{Eq}"\"ON\"" A_surfxml_network_link_state = A_surfxml_network_link_state_ON;
538 "state"{Eq}"\"OFF\"" A_surfxml_network_link_state = A_surfxml_network_link_state_OFF;
540 "state_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_network_link_state_file);
541 "state_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_network_link_state_file);
543 "sharing_policy"{Eq}"'SHARED'" |
544 "sharing_policy"{Eq}"\"SHARED\"" A_surfxml_network_link_sharing_policy = A_surfxml_network_link_sharing_policy_SHARED;
545 "sharing_policy"{Eq}"'FATPIPE'" |
546 "sharing_policy"{Eq}"\"FATPIPE\"" A_surfxml_network_link_sharing_policy = A_surfxml_network_link_sharing_policy_FATPIPE;
549 if (!A_surfxml_network_link_name) FAIL("Required attribute `name' not set for `network_link' element.");
550 if (!A_surfxml_network_link_bandwidth) FAIL("Required attribute `bandwidth' not set for `network_link' element.");
551 LEAVE; STag_surfxml_network_link();surfxml_pcdata = NULL; ENTER(E_surfxml_network_link);
554 if (!A_surfxml_network_link_name) FAIL("Required attribute `name' not set for `network_link' element.");
555 if (!A_surfxml_network_link_bandwidth) FAIL("Required attribute `bandwidth' not set for `network_link' element.");
556 LEAVE; STag_surfxml_network_link(); surfxml_pcdata = NULL; ETag_surfxml_network_link();
558 case S_surfxml_platform_description_2: case S_surfxml_platform_description_1: case S_surfxml_platform_description: SET(S_surfxml_platform_description_2); break;
559 case ROOT_surfxml_network_link: SET(EPILOG); break;
560 case S_surfxml_include: case S_surfxml_include_2: case S_surfxml_include_1: SET(S_surfxml_include_2); break;
563 . FAIL("Unexpected character `%c' in attribute list of network_link element.", yytext[0]);
564 {Name} FAIL("Bad attribute `%s' in `network_link' element start tag.",yytext);
565 <<EOF>> FAIL("EOF in attribute list of `network_link' element.");
568 <E_surfxml_network_link>{
569 "</network_link"{s}">" {
571 ETag_surfxml_network_link();
573 case S_surfxml_platform_description_2: case S_surfxml_platform_description_1: case S_surfxml_platform_description: SET(S_surfxml_platform_description_2); break;
574 case ROOT_surfxml_network_link: SET(EPILOG); break;
575 case S_surfxml_include: case S_surfxml_include_2: case S_surfxml_include_1: SET(S_surfxml_include_2); break;
578 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</network_link>' expected.",yytext);
579 . FAIL("Unexpected character `%c': `</network_link>' expected.",yytext[0]);
580 <<EOF>> FAIL("Premature EOF: `</network_link>' expected.");
583 <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} {
584 A_surfxml_route_src = NULL;
585 A_surfxml_route_dst = NULL;
586 A_surfxml_route_impact_on_src = "0.0";
587 A_surfxml_route_impact_on_dst = "0.0";
588 A_surfxml_route_impact_on_src_with_other_recv = "0.0";
589 A_surfxml_route_impact_on_dst_with_other_send = "0.0";
590 ENTER(AL_surfxml_route);
594 "src"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_route_src);
595 "src"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_route_src);
597 "dst"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_route_dst);
598 "dst"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_route_dst);
600 "impact_on_src"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_route_impact_on_src);
601 "impact_on_src"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_route_impact_on_src);
603 "impact_on_dst"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_route_impact_on_dst);
604 "impact_on_dst"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_route_impact_on_dst);
606 "impact_on_src_with_other_recv"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_route_impact_on_src_with_other_recv);
607 "impact_on_src_with_other_recv"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_route_impact_on_src_with_other_recv);
609 "impact_on_dst_with_other_send"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_route_impact_on_dst_with_other_send);
610 "impact_on_dst_with_other_send"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_route_impact_on_dst_with_other_send);
613 if (!A_surfxml_route_src) FAIL("Required attribute `src' not set for `route' element.");
614 if (!A_surfxml_route_dst) FAIL("Required attribute `dst' not set for `route' element.");
615 LEAVE; STag_surfxml_route();surfxml_pcdata = NULL; ENTER(S_surfxml_route);
618 if (!A_surfxml_route_src) FAIL("Required attribute `src' not set for `route' element.");
619 if (!A_surfxml_route_dst) FAIL("Required attribute `dst' not set for `route' element.");
620 LEAVE; STag_surfxml_route(); surfxml_pcdata = NULL; ETag_surfxml_route();
622 case S_surfxml_platform_description_2: case S_surfxml_platform_description_1: case S_surfxml_platform_description: SET(S_surfxml_platform_description_2); break;
623 case ROOT_surfxml_route: SET(EPILOG); break;
624 case S_surfxml_include: case S_surfxml_include_2: case S_surfxml_include_1: SET(S_surfxml_include_2); break;
627 . FAIL("Unexpected character `%c' in attribute list of route element.", yytext[0]);
628 {Name} FAIL("Bad attribute `%s' in `route' element start tag.",yytext);
629 <<EOF>> FAIL("EOF in attribute list of `route' element.");
632 <S_surfxml_route,S_surfxml_route_2,E_surfxml_route>{
635 ETag_surfxml_route();
637 case S_surfxml_platform_description_2: case S_surfxml_platform_description_1: case S_surfxml_platform_description: SET(S_surfxml_platform_description_2); break;
638 case ROOT_surfxml_route: SET(EPILOG); break;
639 case S_surfxml_include: case S_surfxml_include_2: case S_surfxml_include_1: SET(S_surfxml_include_2); break;
642 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</route>' expected.",yytext);
643 . FAIL("Unexpected character `%c': `</route>' expected.",yytext[0]);
644 <<EOF>> FAIL("Premature EOF: `</route>' expected.");
647 <ROOT_surfxml_route_element,S_surfxml_route_1,S_surfxml_route,S_surfxml_route_2>"<route_element"{s} {
648 A_surfxml_route_element_name = NULL;
649 ENTER(AL_surfxml_route_element);
652 <AL_surfxml_route_element>{
653 "name"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_route_element_name);
654 "name"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_route_element_name);
657 if (!A_surfxml_route_element_name) FAIL("Required attribute `name' not set for `route_element' element.");
658 LEAVE; STag_surfxml_route_element();surfxml_pcdata = NULL; ENTER(E_surfxml_route_element);
661 if (!A_surfxml_route_element_name) FAIL("Required attribute `name' not set for `route_element' element.");
662 LEAVE; STag_surfxml_route_element(); surfxml_pcdata = NULL; ETag_surfxml_route_element();
664 case S_surfxml_route_1: case S_surfxml_route: case S_surfxml_route_2: SET(S_surfxml_route_2); break;
665 case ROOT_surfxml_route_element: SET(EPILOG); break;
668 . FAIL("Unexpected character `%c' in attribute list of route_element element.", yytext[0]);
669 {Name} FAIL("Bad attribute `%s' in `route_element' element start tag.",yytext);
670 <<EOF>> FAIL("EOF in attribute list of `route_element' element.");
673 <E_surfxml_route_element>{
674 "</route_element"{s}">" {
676 ETag_surfxml_route_element();
678 case S_surfxml_route_1: case S_surfxml_route: case S_surfxml_route_2: SET(S_surfxml_route_2); break;
679 case ROOT_surfxml_route_element: SET(EPILOG); break;
682 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</route_element>' expected.",yytext);
683 . FAIL("Unexpected character `%c': `</route_element>' expected.",yytext[0]);
684 <<EOF>> FAIL("Premature EOF: `</route_element>' expected.");
687 <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} {
688 A_surfxml_process_host = NULL;
689 A_surfxml_process_function = NULL;
690 A_surfxml_process_start_time = "-1.0";
691 A_surfxml_process_kill_time = "-1.0";
692 ENTER(AL_surfxml_process);
695 <AL_surfxml_process>{
696 "host"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_process_host);
697 "host"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_process_host);
699 "function"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_process_function);
700 "function"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_process_function);
702 "start_time"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_process_start_time);
703 "start_time"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_process_start_time);
705 "kill_time"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_process_kill_time);
706 "kill_time"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_process_kill_time);
709 if (!A_surfxml_process_host) FAIL("Required attribute `host' not set for `process' element.");
710 if (!A_surfxml_process_function) FAIL("Required attribute `function' not set for `process' element.");
711 LEAVE; STag_surfxml_process();surfxml_pcdata = NULL; ENTER(S_surfxml_process);
714 if (!A_surfxml_process_host) FAIL("Required attribute `host' not set for `process' element.");
715 if (!A_surfxml_process_function) FAIL("Required attribute `function' not set for `process' element.");
716 LEAVE; STag_surfxml_process(); surfxml_pcdata = NULL; ETag_surfxml_process();
718 case S_surfxml_platform_description_2: case S_surfxml_platform_description_1: case S_surfxml_platform_description: SET(S_surfxml_platform_description_2); break;
719 case ROOT_surfxml_process: SET(EPILOG); break;
720 case S_surfxml_include: case S_surfxml_include_2: case S_surfxml_include_1: SET(S_surfxml_include_2); break;
723 . FAIL("Unexpected character `%c' in attribute list of process element.", yytext[0]);
724 {Name} FAIL("Bad attribute `%s' in `process' element start tag.",yytext);
725 <<EOF>> FAIL("EOF in attribute list of `process' element.");
728 <S_surfxml_process,E_surfxml_process,S_surfxml_process_2>{
731 ETag_surfxml_process();
733 case S_surfxml_platform_description_2: case S_surfxml_platform_description_1: case S_surfxml_platform_description: SET(S_surfxml_platform_description_2); break;
734 case ROOT_surfxml_process: SET(EPILOG); break;
735 case S_surfxml_include: case S_surfxml_include_2: case S_surfxml_include_1: SET(S_surfxml_include_2); break;
738 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</process>' expected.",yytext);
739 . FAIL("Unexpected character `%c': `</process>' expected.",yytext[0]);
740 <<EOF>> FAIL("Premature EOF: `</process>' expected.");
743 <ROOT_surfxml_argument,S_surfxml_process_1,S_surfxml_process,S_surfxml_process_2>"<argument"{s} {
744 A_surfxml_argument_value = NULL;
745 ENTER(AL_surfxml_argument);
748 <AL_surfxml_argument>{
749 "value"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_argument_value);
750 "value"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_argument_value);
753 if (!A_surfxml_argument_value) FAIL("Required attribute `value' not set for `argument' element.");
754 LEAVE; STag_surfxml_argument();surfxml_pcdata = NULL; ENTER(E_surfxml_argument);
757 if (!A_surfxml_argument_value) FAIL("Required attribute `value' not set for `argument' element.");
758 LEAVE; STag_surfxml_argument(); surfxml_pcdata = NULL; ETag_surfxml_argument();
760 case S_surfxml_process_1: case S_surfxml_process: case S_surfxml_process_2: SET(S_surfxml_process_2); break;
761 case ROOT_surfxml_argument: SET(EPILOG); break;
764 . FAIL("Unexpected character `%c' in attribute list of argument element.", yytext[0]);
765 {Name} FAIL("Bad attribute `%s' in `argument' element start tag.",yytext);
766 <<EOF>> FAIL("EOF in attribute list of `argument' element.");
769 <E_surfxml_argument>{
772 ETag_surfxml_argument();
774 case S_surfxml_process_1: case S_surfxml_process: case S_surfxml_process_2: SET(S_surfxml_process_2); break;
775 case ROOT_surfxml_argument: SET(EPILOG); break;
778 "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</argument>' expected.",yytext);
779 . FAIL("Unexpected character `%c': `</argument>' expected.",yytext[0]);
780 <<EOF>> FAIL("Premature EOF: `</argument>' expected.");
783 /* EPILOG: after the root element. */
786 . {SET(PROLOG); yyless(0); CLEANUP; return -1;}
790 /* CHARACTER DATA. */
792 <IMPOSSIBLE,VALUE1,VALUE2>{
793 /* Non-defined standard entities... */
794 "&" BUFFERPUTC('&');
795 "<" BUFFERPUTC('<');
796 ">" BUFFERPUTC('>');
797 "'" BUFFERPUTC('\'');
798 """ BUFFERPUTC('"');
800 /* Character entities. */
801 "&#"[[:digit:]]+";" BUFFERPUTC((unsigned char)atoi(yytext+2));
802 "&#x"[[:xdigit:]]+";" BUFFERPUTC((unsigned char)strtol(yytext+3,NULL,16));
805 <IMPOSSIBLE,VALUE1,VALUE2,CDATA>{
809 "\n\r" BUFFERPUTC('\n');
813 "<![CDATA[" ENTER(CDATA);
814 "]""]>" FAIL("Unexpected `]""]>' in character data.");
818 \' BUFFERDONE; LEAVE;
819 <<EOF>> FAIL("EOF in literal (\"'\" expected).");
823 \" BUFFERDONE; LEAVE;
824 <<EOF>> FAIL("EOF in literal (`\"' expected).");
827 <IMPOSSIBLE,VALUE1,VALUE2>{
828 [^<&] BUFFERPUTC(yytext[0]);
829 [<&] FAIL("Spurious `%c' in character data.",yytext[0]);
834 /* "]""]" BUFFERPUTC(yytext[0]); BUFFERPUTC(yytext[1]); */
835 . BUFFERPUTC(yytext[0]);
836 <<EOF>> FAIL("EOF in CDATA section.");
839 /* Impossible rules to avoid warnings from flex(1). */
840 /* Ideally, this should be replaced by code in flexml.pl that
841 generates just the states not covered by other rules. */
843 .|[\n] FAIL("Syntax error on character `%c'.", yytext[0]);
848 /* Element context stack lookup. */
849 int surfxml_element_context(int i)
851 return (0<i && i<yy_start_stack_depth
852 ? yy_start_stack[yy_start_stack_ptr - i]
857 void print_yy_stack(char* fmt, ...)
859 int i = 0; va_list ap; va_start(ap, fmt);
860 vfprintf(stderr, fmt, ap);
861 for (i=1; i<yy_start_stack_ptr; i++)
862 fprintf(stderr, "%s/", surfxml_statenames[yy_start_stack[i] ]);
863 fprintf(stderr,"%s\n", surfxml_statenames[YY_START]);
867 static void debug_enter(int state, const char* statename) {
868 yy_push_state(state);
869 if (yy_flex_debug) print_yy_stack("--ENTER(%s) : ",statename);
872 static void debug_leave(void) {
873 if (yy_flex_debug) print_yy_stack("--LEAVE : ");
877 static void debug_set(int state, const char* statename) {
879 if (yy_flex_debug) print_yy_stack("--SET(%s) : ",statename);
883 enum {flexml_max_err_msg_size = 512};
885 static char flexml_err_msg[flexml_max_err_msg_size];
886 const char * surfxml_parse_err_msg()
888 return flexml_err_msg;
891 static void reset_surfxml_parse_err_msg()
893 flexml_err_msg[0] = '\0';
897 static void cleanup(void)
899 if (surfxml_statenames) {
900 free(surfxml_statenames);
901 surfxml_statenames = NULL;
906 static int fail(const char* fmt, ...)
908 int chars_left, used;
909 va_list ap; va_start(ap, fmt);
910 #ifdef FLEXML_yylineno
911 used = sprintf(flexml_err_msg,
912 "Invalid XML (XML input line %d, state %d): ",
915 used = sprintf(flexml_err_msg,
916 "Invalid XML (state %d): ",
919 chars_left = flexml_max_err_msg_size - used - 1;
920 vsnprintf(flexml_err_msg + used, chars_left, fmt, ap);
923 #ifndef FLEXML_quiet_parser
924 /* print directly to sdterr */
925 fprintf(stderr, "%s\n", flexml_err_msg);
926 flexml_err_msg[0] = '\0';