Logo AND Algorithmique Numérique Distribuée

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