Logo AND Algorithmique Numérique Distribuée

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