Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
14d69de734f1f4b5b09cea97bab9616176ac70cb
[simgrid.git] / src / surf / surfxml.l
1 /* Validating XML processor for surfxml.dtd.
2  * Generated 2005/06/09 14:30:33.
3  *
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.44 2005/02/23 23:08:16 mquinson Exp).
7  * 
8  * There are two, intertwined parts to this program, part A and part B.
9  *
10  * Part A
11  * ------
12  * 
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.
16  *
17  * You can redistribute, use, perform, display and/or modify "Part A"
18  * provided the following two conditions hold:
19  *
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.
23  *
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.
27  *
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.
31  * 
32  * Part B
33  * ------
34  * 
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".
40  *
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.
44  * 
45  */
46
47 %{
48
49 /* Version strings. */
50 const char rcs_flexml_skeleton[] =
51  "$" "Id: skel,v 1.26 2005/02/23 22:22:20 wdowling Exp $";
52 const char rcs_flexml[] =
53  "$" "Id: flexml.pl,v 1.44 2005/02/23 23:08:16 mquinson Exp $";
54
55 /* ANSI headers. */
56 #include <unistd.h>
57 #include <stdio.h>
58 #include <string.h>
59 #include <assert.h>
60 #include <stdarg.h>
61 #include <ctype.h>
62
63 /* Generated definitions. */
64 #define FLEXML_yylineno
65 #define FLEXML_BUFFERSTACKSIZE 1000000
66
67 /* XML processor api. */
68 /* FleXML-provided data. */
69 const char* pcdata;
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_route_dst A_route_dst;
94 AT_cpu_state A_cpu_state;
95 AT_network_link_latency A_network_link_latency;
96 AT_network_link_state_file A_network_link_state_file;
97 AT_cpu_interference_send A_cpu_interference_send;
98 AT_cpu_state_file A_cpu_state_file;
99 AT_network_link_bandwidth_file A_network_link_bandwidth_file;
100
101 /* XML state. */
102 #ifdef FLEX_DEBUG
103 # define ENTER(state)   debug_enter(state,#state)
104 # define LEAVE          debug_leave()
105 # define SET(state)     debug_set(state,#state)
106   static void debug_enter(int, const char*);
107   static void debug_leave(void);
108   static void debug_set(int, const char*);
109 #else
110 # define ENTER(state)   (yy_push_state(state))
111 # define LEAVE          (yy_pop_state())
112 # define SET(state)     BEGIN(state)
113 #endif
114
115 /* Generic actions. */
116 #define SKIP    /*skip*/
117 #define SUCCEED        CLEANUP; return 0
118
119 #define FAIL    return fail
120 static int fail(const char*, ...);
121 const char * parse_err_msg(void);
122
123 /* Cleanup */
124 static void cleanup(void);
125 #define CLEANUP  cleanup()
126
127 /* Text buffer stack handling. */
128 char bufferstack[FLEXML_BUFFERSTACKSIZE];
129 char* limit = bufferstack + FLEXML_BUFFERSTACKSIZE;
130 typedef struct BufferLast_s {
131   struct BufferLast_s *old; char* saved; char new1[1];
132 } BufferLast;
133 BufferLast* last = (BufferLast*)0;
134 char* next = bufferstack;
135
136 #define BUFFERSET(P)  (P = next)
137 #define BUFFERPUTC(C) (assert(next<limit), *(next++) = (C))
138 #define BUFFERDONE    (BUFFERPUTC('\0'))
139
140 #define BUFFERLITERAL(C,P) bufferliteral(C,&(P),yytext)
141 static void bufferliteral(char c, const char** pp, char* text)
142 {
143   char *s = strchr(text,c), *e = strrchr(text,c);
144   assert(s <= e); BUFFERSET(*pp);
145   while (++s<e) {
146     if (isspace(*s)) { BUFFERPUTC(' '); while (isspace(*s)) ++s; }
147     else BUFFERPUTC(*s);
148   }
149   BUFFERDONE;
150 }
151
152 #ifdef FLEXML_HasMixed
153 static void pushbuffer(char* p)
154 {
155   BufferLast* l = (BufferLast*)next;
156   assert(next < limit);
157   l->old = last;
158   l->saved = p;
159   next = l->new1;
160   last = l;
161 }
162
163 static char* popbuffer(void)
164 {
165   BufferLast* l = last;
166   assert(last != (BufferLast*)0);
167   last = l->old;
168   next = (char*)l;
169   return l->saved;
170 }
171 #endif
172
173 /* General internal entities are `unput' back onto the input stream... */
174 #define ENTITYTEXT(T) \
175   { char *s = (T), *e = s+strlen(s);\
176     while (--e >= s) { unput(*e); }}
177 %}
178
179 /* Flex standard options. */
180 %option stack
181 %option noyy_top_state
182 %option noinput
183 %option noreject
184 %option noyymore
185 %option noyywrap
186
187 /* Flex user-requested options. */
188 %option yylineno
189 %option nounput
190
191 /* XML character classes (currently restricted to ASCII). */
192
193 /* "Common syntactic structures." */
194 S               [ \t\n\r\f]+
195 s               [ \t\n\r\f]*
196
197 /* "Names and Tokens." */
198 NameChar        [A-Za-z0-9.:_-]
199 Name            [A-Za-z_:]{NameChar}*
200 Names           {Name}({S}{Name})*
201 Nmtoken         ({NameChar})+
202 Nmtokens        {Nmtoken}({S}{Nmtoken})*
203
204 /* Miscellaneous. */
205 VersionNum      [a-zA-Z0-9_.:-]+
206 Eq              {s}"="{s}
207 Literal         \'[^'']*\'|\"[^""]*\"
208
209 /* Parser states (flex `exclusive start conditions'):
210  *
211  * PROLOG       the XML prolog of the document before <?xml...>
212  * DOCTYPE      the XML prolog of the document after <?xml...>
213  * EPILOG       after the root element
214  * INCOMMENT    inside an XML comment <!--....-->
215  * INPI         inside an XML PI <?...?>
216  * VALUE1       inside a '...'-delimited literal
217  * VALUE2       inside a "..."-delimited literal
218  * CDATA        inside a <![CDATA[...]]> section.
219  * ROOT_<tag>   expect root element <tag>
220  * AL_<tag>     inside the attribute list for <tag>
221  * IN_<tag>     inside a <tag> with element contents (ready for end tag)
222  * IMPOSSIBLE   dummy to permit disabling rules; must be last
223  */
224 %x PROLOG DOCTYPE EPILOG INCOMMENT INPI VALUE1 VALUE2 CDATA
225 %x ROOT_platform_description AL_platform_description S_platform_description S_platform_description_1 S_platform_description_2 E_platform_description
226 %x ROOT_include AL_include S_include S_include_1 S_include_2 E_include
227 %x ROOT_cpu AL_cpu E_cpu
228 %x ROOT_network_link AL_network_link E_network_link
229 %x ROOT_route AL_route S_route S_route_1 S_route_2 E_route
230 %x ROOT_route_element AL_route_element E_route_element
231 %x ROOT_process AL_process S_process S_process_1 S_process_2 E_process
232 %x ROOT_argument AL_argument E_argument
233 %x IMPOSSIBLE
234
235 %{
236 /* State names. */
237 const char* *statenames=NULL;
238 %}
239
240 %%
241
242  /* Bypass Flex's default INITIAL state and begin by parsing the XML prolog. */
243  SET(PROLOG);
244   /* FleXML_init */
245   next = bufferstack;
246   if(!statenames) {statenames= (const char **)calloc(IMPOSSIBLE,sizeof(char*));
247   statenames[PROLOG] = NULL;
248   statenames[DOCTYPE] = NULL;
249   statenames[EPILOG] = NULL;
250   statenames[INCOMMENT] = NULL;
251   statenames[INPI] = NULL;
252   statenames[VALUE1] = NULL;
253   statenames[VALUE2] = NULL;
254   statenames[CDATA] = NULL;
255   statenames[ROOT_platform_description] = NULL;
256   statenames[AL_platform_description] = NULL;
257   statenames[S_platform_description] = "platform_description";
258   statenames[S_platform_description_1] = "platform_description";
259   statenames[S_platform_description_2] = "platform_description";
260   statenames[E_platform_description] = "platform_description";
261   statenames[ROOT_include] = NULL;
262   statenames[AL_include] = NULL;
263   statenames[S_include] = "include";
264   statenames[S_include_1] = "include";
265   statenames[S_include_2] = "include";
266   statenames[E_include] = "include";
267   statenames[ROOT_cpu] = NULL;
268   statenames[AL_cpu] = NULL;
269   statenames[E_cpu] = "cpu";
270   statenames[ROOT_network_link] = NULL;
271   statenames[AL_network_link] = NULL;
272   statenames[E_network_link] = "network_link";
273   statenames[ROOT_route] = NULL;
274   statenames[AL_route] = NULL;
275   statenames[S_route] = "route";
276   statenames[S_route_1] = "route";
277   statenames[S_route_2] = "route";
278   statenames[E_route] = "route";
279   statenames[ROOT_route_element] = NULL;
280   statenames[AL_route_element] = NULL;
281   statenames[E_route_element] = "route_element";
282   statenames[ROOT_process] = NULL;
283   statenames[AL_process] = NULL;
284   statenames[S_process] = "process";
285   statenames[S_process_1] = "process";
286   statenames[S_process_2] = "process";
287   statenames[E_process] = "process";
288   statenames[ROOT_argument] = NULL;
289   statenames[AL_argument] = NULL;
290   statenames[E_argument] = "argument";
291   }
292
293  /* COMMENTS and PIs: handled uniformly for efficiency. */
294
295 <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>{
296  "<!--" ENTER(INCOMMENT);
297  "<?" ENTER(INPI);
298 }
299 <INCOMMENT>{
300  "-->"          LEAVE;
301  "--"           |
302  .              |
303  \n             SKIP;
304  <<EOF>>        FAIL("EOF in comment.");
305 }
306 <INPI>{
307  "?>"           LEAVE;
308  .              |
309  \n             SKIP;
310  <<EOF>>        FAIL("EOF in PI (processing instruction).");
311 }
312
313  /* SPACES: skipped uniformly */
314
315 <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;
316
317  /* PROLOG: determine root element and process it. */
318
319 <PROLOG>{
320  "<?xml"({S}version{Eq}(\'{VersionNum}\'|\"{VersionNum}\"))?({S}encoding{Eq}(\'[^']*\'|\"[^"]*\"))?"?>" SET(DOCTYPE); 
321  "<?xml"[^>]*">" FAIL("Bad declaration %s.",yytext);
322 }
323
324 <PROLOG,DOCTYPE>{
325  "<!DOCTYPE"{S}"argument"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_argument);
326  "<!DOCTYPE"{S}"route_element"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_route_element);
327  "<!DOCTYPE"{S}"cpu"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_cpu);
328  "<!DOCTYPE"{S}"include"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_include);
329  "<!DOCTYPE"{S}"route"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_route);
330  "<!DOCTYPE"{S}"platform_description"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_platform_description);
331  "<!DOCTYPE"{S}"network_link"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_network_link);
332  "<!DOCTYPE"{S}"process"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_process);
333  "<!"[^>-][^>]*">" FAIL("Bad declaration %s.",yytext);
334  .              FAIL("Unexpected character `%c' in prolog.", yytext[0]);
335  <<EOF>>        FAIL("EOF in prolog.");
336 }
337
338  /* RULES DERIVED FROM DTD. */
339
340  /* <!-- Small DTD for SURF based tools. -->  */
341
342 <ROOT_platform_description>"<platform_description"{s} {
343   ENTER(AL_platform_description);
344   }
345
346 <AL_platform_description>{
347  ">" {
348   LEAVE; STag_platform_description();pcdata = NULL; ENTER(S_platform_description);
349  }
350  "/>" {
351   LEAVE; STag_platform_description(); pcdata = NULL; ETag_platform_description();
352   switch (YY_START) {
353    case ROOT_platform_description: SET(EPILOG); break;
354   }
355  }
356  .       FAIL("Unexpected character `%c' in attribute list of platform_description element.", yytext[0]);
357  {Name} FAIL("Bad attribute `%s' in `platform_description' element start tag.",yytext);
358  <<EOF>> FAIL("EOF in attribute list of `platform_description' element.");
359 }
360
361 <E_platform_description,S_platform_description_2,S_platform_description>{
362  "</platform_description"{s}">" {
363   LEAVE;
364   ETag_platform_description();
365   switch (YY_START) {
366    case ROOT_platform_description: SET(EPILOG); break;
367   }
368  }
369  "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</platform_description>' expected.",yytext);
370  .       FAIL("Unexpected character `%c': `</platform_description>' expected.",yytext[0]);
371  <<EOF>> FAIL("Premature EOF: `</platform_description>' expected.");
372 }
373
374 <ROOT_include,S_platform_description_2,S_include,S_include_2,S_platform_description_1,S_include_1,S_platform_description>"<include"{s} {
375   A_include_file = NULL;
376   ENTER(AL_include);
377   }
378
379 <AL_include>{
380  "file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_include_file);
381  "file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_include_file);
382
383  ">" {
384   if (!A_include_file) FAIL("Required attribute `file' not set for `include' element.");
385   LEAVE; STag_include();pcdata = NULL; ENTER(S_include);
386  }
387  "/>" {
388   if (!A_include_file) FAIL("Required attribute `file' not set for `include' element.");
389   LEAVE; STag_include(); pcdata = NULL; ETag_include();
390   switch (YY_START) {
391    case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
392    case S_include: case S_include_2: case S_include_1: SET(S_include_2); break;
393    case ROOT_include: SET(EPILOG); break;
394   }
395  }
396  .       FAIL("Unexpected character `%c' in attribute list of include element.", yytext[0]);
397  {Name} FAIL("Bad attribute `%s' in `include' element start tag.",yytext);
398  <<EOF>> FAIL("EOF in attribute list of `include' element.");
399 }
400
401 <E_include,S_include,S_include_2>{
402  "</include"{s}">" {
403   LEAVE;
404   ETag_include();
405   switch (YY_START) {
406    case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
407    case S_include: case S_include_2: case S_include_1: SET(S_include_2); break;
408    case ROOT_include: SET(EPILOG); break;
409   }
410  }
411  "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</include>' expected.",yytext);
412  .       FAIL("Unexpected character `%c': `</include>' expected.",yytext[0]);
413  <<EOF>> FAIL("Premature EOF: `</include>' expected.");
414 }
415
416 <ROOT_cpu,S_platform_description_2,S_include,S_include_2,S_platform_description_1,S_include_1,S_platform_description>"<cpu"{s} {
417   A_cpu_name = NULL;
418   A_cpu_power = NULL;
419   A_cpu_availability = "1.0";
420   A_cpu_availability_file = NULL;
421   A_cpu_state = A_cpu_state_ON;
422   A_cpu_state_file = NULL;
423   A_cpu_interference_send = "1.0";
424   A_cpu_interference_recv = "1.0";
425   A_cpu_interference_send_recv = "1.0";
426   A_cpu_max_outgoing_rate = "-1.0";
427   ENTER(AL_cpu);
428   }
429
430 <AL_cpu>{
431  "name"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_name);
432  "name"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_name);
433
434  "power"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_power);
435  "power"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_power);
436
437  "availability"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_availability);
438  "availability"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_availability);
439
440  "availability_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_availability_file);
441  "availability_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_availability_file);
442
443  "state"{Eq}"'ON'" |
444  "state"{Eq}"\"ON\"" A_cpu_state = A_cpu_state_ON;
445  "state"{Eq}"'OFF'" |
446  "state"{Eq}"\"OFF\"" A_cpu_state = A_cpu_state_OFF;
447
448  "state_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_state_file);
449  "state_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_state_file);
450
451  "interference_send"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_interference_send);
452  "interference_send"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_interference_send);
453
454  "interference_recv"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_interference_recv);
455  "interference_recv"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_interference_recv);
456
457  "interference_send_recv"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_interference_send_recv);
458  "interference_send_recv"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_interference_send_recv);
459
460  "max_outgoing_rate"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_max_outgoing_rate);
461  "max_outgoing_rate"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_max_outgoing_rate);
462
463  ">" {
464   if (!A_cpu_name) FAIL("Required attribute `name' not set for `cpu' element.");
465   if (!A_cpu_power) FAIL("Required attribute `power' not set for `cpu' element.");
466   LEAVE; STag_cpu();pcdata = NULL; ENTER(E_cpu);
467  }
468  "/>" {
469   if (!A_cpu_name) FAIL("Required attribute `name' not set for `cpu' element.");
470   if (!A_cpu_power) FAIL("Required attribute `power' not set for `cpu' element.");
471   LEAVE; STag_cpu(); pcdata = NULL; ETag_cpu();
472   switch (YY_START) {
473    case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
474    case S_include: case S_include_2: case S_include_1: SET(S_include_2); break;
475    case ROOT_cpu: SET(EPILOG); break;
476   }
477  }
478  .       FAIL("Unexpected character `%c' in attribute list of cpu element.", yytext[0]);
479  {Name} FAIL("Bad attribute `%s' in `cpu' element start tag.",yytext);
480  <<EOF>> FAIL("EOF in attribute list of `cpu' element.");
481 }
482
483 <E_cpu>{
484  "</cpu"{s}">" {
485   LEAVE;
486   ETag_cpu();
487   switch (YY_START) {
488    case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
489    case S_include: case S_include_2: case S_include_1: SET(S_include_2); break;
490    case ROOT_cpu: SET(EPILOG); break;
491   }
492  }
493  "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</cpu>' expected.",yytext);
494  .       FAIL("Unexpected character `%c': `</cpu>' expected.",yytext[0]);
495  <<EOF>> FAIL("Premature EOF: `</cpu>' expected.");
496 }
497
498 <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} {
499   A_network_link_name = NULL;
500   A_network_link_bandwidth = NULL;
501   A_network_link_bandwidth_file = NULL;
502   A_network_link_latency = "0.0";
503   A_network_link_latency_file = NULL;
504   A_network_link_state = A_network_link_state_ON;
505   A_network_link_state_file = NULL;
506   ENTER(AL_network_link);
507   }
508
509 <AL_network_link>{
510  "name"{Eq}\' ENTER(VALUE1); BUFFERSET(A_network_link_name);
511  "name"{Eq}\" ENTER(VALUE2); BUFFERSET(A_network_link_name);
512
513  "bandwidth"{Eq}\' ENTER(VALUE1); BUFFERSET(A_network_link_bandwidth);
514  "bandwidth"{Eq}\" ENTER(VALUE2); BUFFERSET(A_network_link_bandwidth);
515
516  "bandwidth_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_network_link_bandwidth_file);
517  "bandwidth_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_network_link_bandwidth_file);
518
519  "latency"{Eq}\' ENTER(VALUE1); BUFFERSET(A_network_link_latency);
520  "latency"{Eq}\" ENTER(VALUE2); BUFFERSET(A_network_link_latency);
521
522  "latency_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_network_link_latency_file);
523  "latency_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_network_link_latency_file);
524
525  "state"{Eq}"'ON'" |
526  "state"{Eq}"\"ON\"" A_network_link_state = A_network_link_state_ON;
527  "state"{Eq}"'OFF'" |
528  "state"{Eq}"\"OFF\"" A_network_link_state = A_network_link_state_OFF;
529
530  "state_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_network_link_state_file);
531  "state_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_network_link_state_file);
532
533  ">" {
534   if (!A_network_link_name) FAIL("Required attribute `name' not set for `network_link' element.");
535   if (!A_network_link_bandwidth) FAIL("Required attribute `bandwidth' not set for `network_link' element.");
536   LEAVE; STag_network_link();pcdata = NULL; ENTER(E_network_link);
537  }
538  "/>" {
539   if (!A_network_link_name) FAIL("Required attribute `name' not set for `network_link' element.");
540   if (!A_network_link_bandwidth) FAIL("Required attribute `bandwidth' not set for `network_link' element.");
541   LEAVE; STag_network_link(); pcdata = NULL; ETag_network_link();
542   switch (YY_START) {
543    case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
544    case S_include: case S_include_2: case S_include_1: SET(S_include_2); break;
545    case ROOT_network_link: SET(EPILOG); break;
546   }
547  }
548  .       FAIL("Unexpected character `%c' in attribute list of network_link element.", yytext[0]);
549  {Name} FAIL("Bad attribute `%s' in `network_link' element start tag.",yytext);
550  <<EOF>> FAIL("EOF in attribute list of `network_link' element.");
551 }
552
553 <E_network_link>{
554  "</network_link"{s}">" {
555   LEAVE;
556   ETag_network_link();
557   switch (YY_START) {
558    case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
559    case S_include: case S_include_2: case S_include_1: SET(S_include_2); break;
560    case ROOT_network_link: SET(EPILOG); break;
561   }
562  }
563  "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</network_link>' expected.",yytext);
564  .       FAIL("Unexpected character `%c': `</network_link>' expected.",yytext[0]);
565  <<EOF>> FAIL("Premature EOF: `</network_link>' expected.");
566 }
567
568 <ROOT_route,S_platform_description_2,S_include,S_include_2,S_platform_description_1,S_include_1,S_platform_description>"<route"{s} {
569   A_route_src = NULL;
570   A_route_dst = NULL;
571   A_route_impact_on_src = "0.0";
572   A_route_impact_on_dst = "0.0";
573   A_route_impact_on_src_with_other_recv = "0.0";
574   A_route_impact_on_dst_with_other_send = "0.0";
575   ENTER(AL_route);
576   }
577
578 <AL_route>{
579  "src"{Eq}\' ENTER(VALUE1); BUFFERSET(A_route_src);
580  "src"{Eq}\" ENTER(VALUE2); BUFFERSET(A_route_src);
581
582  "dst"{Eq}\' ENTER(VALUE1); BUFFERSET(A_route_dst);
583  "dst"{Eq}\" ENTER(VALUE2); BUFFERSET(A_route_dst);
584
585  "impact_on_src"{Eq}\' ENTER(VALUE1); BUFFERSET(A_route_impact_on_src);
586  "impact_on_src"{Eq}\" ENTER(VALUE2); BUFFERSET(A_route_impact_on_src);
587
588  "impact_on_dst"{Eq}\' ENTER(VALUE1); BUFFERSET(A_route_impact_on_dst);
589  "impact_on_dst"{Eq}\" ENTER(VALUE2); BUFFERSET(A_route_impact_on_dst);
590
591  "impact_on_src_with_other_recv"{Eq}\' ENTER(VALUE1); BUFFERSET(A_route_impact_on_src_with_other_recv);
592  "impact_on_src_with_other_recv"{Eq}\" ENTER(VALUE2); BUFFERSET(A_route_impact_on_src_with_other_recv);
593
594  "impact_on_dst_with_other_send"{Eq}\' ENTER(VALUE1); BUFFERSET(A_route_impact_on_dst_with_other_send);
595  "impact_on_dst_with_other_send"{Eq}\" ENTER(VALUE2); BUFFERSET(A_route_impact_on_dst_with_other_send);
596
597  ">" {
598   if (!A_route_src) FAIL("Required attribute `src' not set for `route' element.");
599   if (!A_route_dst) FAIL("Required attribute `dst' not set for `route' element.");
600   LEAVE; STag_route();pcdata = NULL; ENTER(S_route);
601  }
602  "/>" {
603   if (!A_route_src) FAIL("Required attribute `src' not set for `route' element.");
604   if (!A_route_dst) FAIL("Required attribute `dst' not set for `route' element.");
605   LEAVE; STag_route(); pcdata = NULL; ETag_route();
606   switch (YY_START) {
607    case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
608    case S_include: case S_include_2: case S_include_1: SET(S_include_2); break;
609    case ROOT_route: SET(EPILOG); break;
610   }
611  }
612  .       FAIL("Unexpected character `%c' in attribute list of route element.", yytext[0]);
613  {Name} FAIL("Bad attribute `%s' in `route' element start tag.",yytext);
614  <<EOF>> FAIL("EOF in attribute list of `route' element.");
615 }
616
617 <S_route,S_route_2,E_route>{
618  "</route"{s}">" {
619   LEAVE;
620   ETag_route();
621   switch (YY_START) {
622    case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
623    case S_include: case S_include_2: case S_include_1: SET(S_include_2); break;
624    case ROOT_route: SET(EPILOG); break;
625   }
626  }
627  "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</route>' expected.",yytext);
628  .       FAIL("Unexpected character `%c': `</route>' expected.",yytext[0]);
629  <<EOF>> FAIL("Premature EOF: `</route>' expected.");
630 }
631
632 <ROOT_route_element,S_route_1,S_route,S_route_2>"<route_element"{s} {
633   A_route_element_name = NULL;
634   ENTER(AL_route_element);
635   }
636
637 <AL_route_element>{
638  "name"{Eq}\' ENTER(VALUE1); BUFFERSET(A_route_element_name);
639  "name"{Eq}\" ENTER(VALUE2); BUFFERSET(A_route_element_name);
640
641  ">" {
642   if (!A_route_element_name) FAIL("Required attribute `name' not set for `route_element' element.");
643   LEAVE; STag_route_element();pcdata = NULL; ENTER(E_route_element);
644  }
645  "/>" {
646   if (!A_route_element_name) FAIL("Required attribute `name' not set for `route_element' element.");
647   LEAVE; STag_route_element(); pcdata = NULL; ETag_route_element();
648   switch (YY_START) {
649    case S_route_1: case S_route: case S_route_2: SET(S_route_2); break;
650    case ROOT_route_element: SET(EPILOG); break;
651   }
652  }
653  .       FAIL("Unexpected character `%c' in attribute list of route_element element.", yytext[0]);
654  {Name} FAIL("Bad attribute `%s' in `route_element' element start tag.",yytext);
655  <<EOF>> FAIL("EOF in attribute list of `route_element' element.");
656 }
657
658 <E_route_element>{
659  "</route_element"{s}">" {
660   LEAVE;
661   ETag_route_element();
662   switch (YY_START) {
663    case S_route_1: case S_route: case S_route_2: SET(S_route_2); break;
664    case ROOT_route_element: SET(EPILOG); break;
665   }
666  }
667  "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</route_element>' expected.",yytext);
668  .       FAIL("Unexpected character `%c': `</route_element>' expected.",yytext[0]);
669  <<EOF>> FAIL("Premature EOF: `</route_element>' expected.");
670 }
671
672 <ROOT_process,S_platform_description_2,S_include,S_include_2,S_platform_description_1,S_include_1,S_platform_description>"<process"{s} {
673   A_process_host = NULL;
674   A_process_function = NULL;
675   A_process_start_time = "-1.0";
676   A_process_kill_time = "-1.0";
677   ENTER(AL_process);
678   }
679
680 <AL_process>{
681  "host"{Eq}\' ENTER(VALUE1); BUFFERSET(A_process_host);
682  "host"{Eq}\" ENTER(VALUE2); BUFFERSET(A_process_host);
683
684  "function"{Eq}\' ENTER(VALUE1); BUFFERSET(A_process_function);
685  "function"{Eq}\" ENTER(VALUE2); BUFFERSET(A_process_function);
686
687  "start_time"{Eq}\' ENTER(VALUE1); BUFFERSET(A_process_start_time);
688  "start_time"{Eq}\" ENTER(VALUE2); BUFFERSET(A_process_start_time);
689
690  "kill_time"{Eq}\' ENTER(VALUE1); BUFFERSET(A_process_kill_time);
691  "kill_time"{Eq}\" ENTER(VALUE2); BUFFERSET(A_process_kill_time);
692
693  ">" {
694   if (!A_process_host) FAIL("Required attribute `host' not set for `process' element.");
695   if (!A_process_function) FAIL("Required attribute `function' not set for `process' element.");
696   LEAVE; STag_process();pcdata = NULL; ENTER(S_process);
697  }
698  "/>" {
699   if (!A_process_host) FAIL("Required attribute `host' not set for `process' element.");
700   if (!A_process_function) FAIL("Required attribute `function' not set for `process' element.");
701   LEAVE; STag_process(); pcdata = NULL; ETag_process();
702   switch (YY_START) {
703    case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
704    case S_include: case S_include_2: case S_include_1: SET(S_include_2); break;
705    case ROOT_process: SET(EPILOG); break;
706   }
707  }
708  .       FAIL("Unexpected character `%c' in attribute list of process element.", yytext[0]);
709  {Name} FAIL("Bad attribute `%s' in `process' element start tag.",yytext);
710  <<EOF>> FAIL("EOF in attribute list of `process' element.");
711 }
712
713 <S_process,E_process,S_process_2>{
714  "</process"{s}">" {
715   LEAVE;
716   ETag_process();
717   switch (YY_START) {
718    case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
719    case S_include: case S_include_2: case S_include_1: SET(S_include_2); break;
720    case ROOT_process: SET(EPILOG); break;
721   }
722  }
723  "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</process>' expected.",yytext);
724  .       FAIL("Unexpected character `%c': `</process>' expected.",yytext[0]);
725  <<EOF>> FAIL("Premature EOF: `</process>' expected.");
726 }
727
728 <ROOT_argument,S_process_1,S_process,S_process_2>"<argument"{s} {
729   A_argument_value = NULL;
730   ENTER(AL_argument);
731   }
732
733 <AL_argument>{
734  "value"{Eq}\' ENTER(VALUE1); BUFFERSET(A_argument_value);
735  "value"{Eq}\" ENTER(VALUE2); BUFFERSET(A_argument_value);
736
737  ">" {
738   if (!A_argument_value) FAIL("Required attribute `value' not set for `argument' element.");
739   LEAVE; STag_argument();pcdata = NULL; ENTER(E_argument);
740  }
741  "/>" {
742   if (!A_argument_value) FAIL("Required attribute `value' not set for `argument' element.");
743   LEAVE; STag_argument(); pcdata = NULL; ETag_argument();
744   switch (YY_START) {
745    case ROOT_argument: SET(EPILOG); break;
746    case S_process_1: case S_process: case S_process_2: SET(S_process_2); break;
747   }
748  }
749  .       FAIL("Unexpected character `%c' in attribute list of argument element.", yytext[0]);
750  {Name} FAIL("Bad attribute `%s' in `argument' element start tag.",yytext);
751  <<EOF>> FAIL("EOF in attribute list of `argument' element.");
752 }
753
754 <E_argument>{
755  "</argument"{s}">" {
756   LEAVE;
757   ETag_argument();
758   switch (YY_START) {
759    case ROOT_argument: SET(EPILOG); break;
760    case S_process_1: case S_process: case S_process_2: SET(S_process_2); break;
761   }
762  }
763  "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</argument>' expected.",yytext);
764  .       FAIL("Unexpected character `%c': `</argument>' expected.",yytext[0]);
765  <<EOF>> FAIL("Premature EOF: `</argument>' expected.");
766 }
767
768  /* EPILOG: after the root element. */
769
770 <EPILOG>{
771  . {SET(PROLOG); yyless(0); CLEANUP; return -1;}
772  <<EOF>>        SUCCEED;
773 }
774
775  /* CHARACTER DATA. */
776
777 <IMPOSSIBLE,VALUE1,VALUE2>{
778  /* Non-defined standard entities... */
779 "&amp;"  BUFFERPUTC('&');
780 "&lt;"   BUFFERPUTC('<');
781 "&gt;"   BUFFERPUTC('>');
782 "&apos;" BUFFERPUTC('\'');
783 "&quot;" BUFFERPUTC('"');
784
785  /* Character entities. */
786  "&#"[[:digit:]]+";"    BUFFERPUTC((unsigned char)atoi(yytext+2));
787  "&#x"[[:xdigit:]]+";"  BUFFERPUTC((unsigned char)strtol(yytext+3,NULL,16));
788 }
789
790 <IMPOSSIBLE,VALUE1,VALUE2,CDATA>{
791  "\n"           |
792  "\r"           |
793  "\r\n"         |
794  "\n\r"         BUFFERPUTC('\n');
795 }
796
797 <IMPOSSIBLE>{
798  "<![CDATA["    ENTER(CDATA);
799  "]""]>"                FAIL("Unexpected `]""]>' in character data.");
800 }
801
802 <VALUE1>{
803  \'             BUFFERDONE; LEAVE;
804  <<EOF>>        FAIL("EOF in literal (\"'\" expected).");
805 }
806
807 <VALUE2>{
808  \"             BUFFERDONE; LEAVE;
809  <<EOF>>        FAIL("EOF in literal (`\"' expected).");
810 }
811
812 <IMPOSSIBLE,VALUE1,VALUE2>{
813  [^<&]          BUFFERPUTC(yytext[0]);
814  [<&]           FAIL("Spurious `%c' in character data.",yytext[0]);
815 }
816
817 <CDATA>{
818  "]""]>"                LEAVE;
819  /* "]""]"              BUFFERPUTC(yytext[0]); BUFFERPUTC(yytext[1]); */
820  .              BUFFERPUTC(yytext[0]);
821  <<EOF>>        FAIL("EOF in CDATA section.");
822 }
823
824  /* Impossible rules to avoid warnings from flex(1). */
825  /* Ideally, this should be replaced by code in flexml.pl that
826     generates just the states not covered by other rules. */
827 <*>{
828  .|[\n] FAIL("Syntax error on character `%c'.", yytext[0]);
829 }
830
831 %%
832
833 /* Element context stack lookup. */
834 int element_context(int i)
835 {
836   return (0<i && i<yy_start_stack_depth
837           ? yy_start_stack[yy_start_stack_ptr - i]
838           : 0);
839 }
840
841 #ifdef FLEX_DEBUG
842 void print_yy_stack(char* fmt, ...)
843 {
844   int i = 0; va_list ap; va_start(ap, fmt);
845   vfprintf(stderr, fmt, ap);
846   for (i=1; i<yy_start_stack_ptr; i++)
847     fprintf(stderr, "%s/", statenames[yy_start_stack[i] ]);
848   fprintf(stderr,"%s\n", statenames[YY_START]);
849   va_end(ap);
850 }
851
852 static void debug_enter(int state, const char* statename) {
853   yy_push_state(state);
854   if (yy_flex_debug) print_yy_stack("--ENTER(%s) : ",statename);
855 }
856
857 static void debug_leave(void) {
858   if (yy_flex_debug) print_yy_stack("--LEAVE : ");
859   yy_pop_state();
860 }
861
862 static void debug_set(int state, const char* statename) {
863   BEGIN(state);
864   if (yy_flex_debug) print_yy_stack("--SET(%s) : ",statename);
865 }
866 #endif
867
868 enum {flexml_max_err_msg_size = 512};
869
870 static char flexml_err_msg[flexml_max_err_msg_size];
871 const char * parse_err_msg()
872 {
873     return flexml_err_msg;
874 }
875
876 static void reset_parse_err_msg()
877 {
878     flexml_err_msg[0] = '\0';
879 }
880
881
882 static void cleanup(void)
883 {
884     if (statenames) {
885         free(statenames);
886         statenames = NULL;
887     }
888 }
889
890
891 static int fail(const char* fmt, ...)
892 {
893     int chars_left, used;
894     va_list ap; va_start(ap, fmt);
895 #ifdef FLEXML_yylineno
896     used = sprintf(flexml_err_msg,
897                    "Invalid XML (XML input line %d, state %d): ",
898                    yylineno, YY_START);
899 #else
900     used = sprintf(flexml_err_msg,
901                    "Invalid XML (state %d): ",
902                    YY_START);
903 #endif
904     chars_left = flexml_max_err_msg_size - used - 1;
905     vsnprintf(flexml_err_msg + used, chars_left, fmt, ap);
906     va_end(ap);
907
908 #ifndef FLEXML_quiet_parser
909     /* print directly to sdterr */
910     fprintf(stderr, "%s\n", flexml_err_msg);
911     flexml_err_msg[0] = '\0';
912 #endif
913
914     cleanup();
915
916     return 1;
917 }