Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
4e1d0b1179eb1e3508fc6cca0e0b1b7e3b9abf07
[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 1000000
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   next = bufferstack;
219   if(!statenames) {statenames= (const char **)calloc(IMPOSSIBLE,sizeof(char*));
220   statenames[PROLOG] = NULL;
221   statenames[DOCTYPE] = NULL;
222   statenames[EPILOG] = NULL;
223   statenames[INCOMMENT] = NULL;
224   statenames[INPI] = NULL;
225   statenames[VALUE1] = NULL;
226   statenames[VALUE2] = NULL;
227   statenames[CDATA] = NULL;
228   statenames[ROOT_platform_description] = NULL;
229   statenames[AL_platform_description] = NULL;
230   statenames[S_platform_description] = "platform_description";
231   statenames[S_platform_description_1] = "platform_description";
232   statenames[S_platform_description_2] = "platform_description";
233   statenames[E_platform_description] = "platform_description";
234   statenames[ROOT_include] = NULL;
235   statenames[AL_include] = NULL;
236   statenames[S_include] = "include";
237   statenames[S_include_1] = "include";
238   statenames[S_include_2] = "include";
239   statenames[E_include] = "include";
240   statenames[ROOT_cpu] = NULL;
241   statenames[AL_cpu] = NULL;
242   statenames[E_cpu] = "cpu";
243   statenames[ROOT_network_link] = NULL;
244   statenames[AL_network_link] = NULL;
245   statenames[E_network_link] = "network_link";
246   statenames[ROOT_route] = NULL;
247   statenames[AL_route] = NULL;
248   statenames[S_route] = "route";
249   statenames[S_route_1] = "route";
250   statenames[S_route_2] = "route";
251   statenames[E_route] = "route";
252   statenames[ROOT_route_element] = NULL;
253   statenames[AL_route_element] = NULL;
254   statenames[E_route_element] = "route_element";
255   statenames[ROOT_process] = NULL;
256   statenames[AL_process] = NULL;
257   statenames[S_process] = "process";
258   statenames[S_process_1] = "process";
259   statenames[S_process_2] = "process";
260   statenames[E_process] = "process";
261   statenames[ROOT_argument] = NULL;
262   statenames[AL_argument] = NULL;
263   statenames[E_argument] = "argument";
264   }
265  /* COMMENTS and PIs: handled uniformly for efficiency. */
266
267 <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>{
268  "<!--" ENTER(INCOMMENT);
269  "<?" ENTER(INPI);
270 }
271 <INCOMMENT>{
272  "-->"          LEAVE;
273  "--"           |
274  .              |
275  \n             SKIP;
276  <<EOF>>        FAIL("EOF in comment.");
277 }
278 <INPI>{
279  "?>"           LEAVE;
280  .              |
281  \n             SKIP;
282  <<EOF>>        FAIL("EOF in PI (processing instruction).");
283 }
284
285  /* SPACES: skipped uniformly */
286
287 <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;
288
289  /* PROLOG: determine root element and process it. */
290
291 <PROLOG>{
292  "<?xml"({S}version{Eq}(\'{VersionNum}\'|\"{VersionNum}\"))?({S}encoding{Eq}(\'[^']*\'|\"[^"]*\"))?"?>" SET(DOCTYPE); 
293  "<?xml"[^>]*">" FAIL("Bad declaration %s.",yytext);
294 }
295
296 <PROLOG,DOCTYPE>{
297  "<!DOCTYPE"{S}"argument"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_argument);
298  "<!DOCTYPE"{S}"route_element"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_route_element);
299  "<!DOCTYPE"{S}"cpu"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_cpu);
300  "<!DOCTYPE"{S}"include"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_include);
301  "<!DOCTYPE"{S}"route"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_route);
302  "<!DOCTYPE"{S}"platform_description"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_platform_description);
303  "<!DOCTYPE"{S}"network_link"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_network_link);
304  "<!DOCTYPE"{S}"process"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_process);
305  "<!"[^>-][^>]*">" FAIL("Bad declaration %s.",yytext);
306  .              FAIL("Unexpected character `%c' in prolog.", yytext[0]);
307  <<EOF>>        FAIL("EOF in prolog.");
308 }
309
310  /* RULES DERIVED FROM DTD. */
311
312  /* <!-- Small DTD for SURF based tools. -->  */
313
314 <ROOT_platform_description>"<platform_description"{s} {
315   ENTER(AL_platform_description);
316   }
317
318 <AL_platform_description>{
319  ">" {
320   LEAVE; STag_platform_description();pcdata = NULL; ENTER(S_platform_description);
321  }
322  "/>" {
323   LEAVE; STag_platform_description(); pcdata = NULL; ETag_platform_description();
324   switch (YY_START) {
325    case ROOT_platform_description: SET(EPILOG); break;
326   }
327  }
328  .       FAIL("Unexpected character `%c' in attribute list of platform_description element.", yytext[0]);
329  {Name} FAIL("Bad attribute `%s' in `platform_description' element start tag.",yytext);
330  <<EOF>> FAIL("EOF in attribute list of `platform_description' element.");
331 }
332
333 <E_platform_description,S_platform_description_2,S_platform_description>{
334  "</platform_description"{s}">" {
335   LEAVE;
336   ETag_platform_description();
337   switch (YY_START) {
338    case ROOT_platform_description: SET(EPILOG); break;
339   }
340  }
341  "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</platform_description>' expected.",yytext);
342  .       FAIL("Unexpected character `%c': `</platform_description>' expected.",yytext[0]);
343  <<EOF>> FAIL("Premature EOF: `</platform_description>' expected.");
344 }
345
346 <ROOT_include,S_platform_description_2,S_include,S_include_2,S_platform_description_1,S_include_1,S_platform_description>"<include"{s} {
347   A_include_file = NULL;
348   ENTER(AL_include);
349   }
350
351 <AL_include>{
352  "file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_include_file);
353  "file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_include_file);
354
355  ">" {
356   if (!A_include_file) FAIL("Required attribute `file' not set for `include' element.");
357   LEAVE; STag_include();pcdata = NULL; ENTER(S_include);
358  }
359  "/>" {
360   if (!A_include_file) FAIL("Required attribute `file' not set for `include' element.");
361   LEAVE; STag_include(); pcdata = NULL; ETag_include();
362   switch (YY_START) {
363    case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
364    case S_include: case S_include_2: case S_include_1: SET(S_include_2); break;
365    case ROOT_include: SET(EPILOG); break;
366   }
367  }
368  .       FAIL("Unexpected character `%c' in attribute list of include element.", yytext[0]);
369  {Name} FAIL("Bad attribute `%s' in `include' element start tag.",yytext);
370  <<EOF>> FAIL("EOF in attribute list of `include' element.");
371 }
372
373 <E_include,S_include,S_include_2>{
374  "</include"{s}">" {
375   LEAVE;
376   ETag_include();
377   switch (YY_START) {
378    case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
379    case S_include: case S_include_2: case S_include_1: SET(S_include_2); break;
380    case ROOT_include: SET(EPILOG); break;
381   }
382  }
383  "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</include>' expected.",yytext);
384  .       FAIL("Unexpected character `%c': `</include>' expected.",yytext[0]);
385  <<EOF>> FAIL("Premature EOF: `</include>' expected.");
386 }
387
388 <ROOT_cpu,S_platform_description_2,S_include,S_include_2,S_platform_description_1,S_include_1,S_platform_description>"<cpu"{s} {
389   A_cpu_name = NULL;
390   A_cpu_power = NULL;
391   A_cpu_availability = "1.0";
392   A_cpu_availability_file = NULL;
393   A_cpu_state = A_cpu_state_ON;
394   A_cpu_state_file = NULL;
395   A_cpu_interference_send = "1.0";
396   A_cpu_interference_recv = "1.0";
397   A_cpu_interference_send_recv = "1.0";
398   A_cpu_max_outgoing_rate = "-1.0";
399   ENTER(AL_cpu);
400   }
401
402 <AL_cpu>{
403  "name"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_name);
404  "name"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_name);
405
406  "power"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_power);
407  "power"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_power);
408
409  "availability"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_availability);
410  "availability"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_availability);
411
412  "availability_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_availability_file);
413  "availability_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_availability_file);
414
415  "state"{Eq}"'ON'" |
416  "state"{Eq}"\"ON\"" A_cpu_state = A_cpu_state_ON;
417  "state"{Eq}"'OFF'" |
418  "state"{Eq}"\"OFF\"" A_cpu_state = A_cpu_state_OFF;
419
420  "state_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_state_file);
421  "state_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_state_file);
422
423  "interference_send"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_interference_send);
424  "interference_send"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_interference_send);
425
426  "interference_recv"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_interference_recv);
427  "interference_recv"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_interference_recv);
428
429  "interference_send_recv"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_interference_send_recv);
430  "interference_send_recv"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_interference_send_recv);
431
432  "max_outgoing_rate"{Eq}\' ENTER(VALUE1); BUFFERSET(A_cpu_max_outgoing_rate);
433  "max_outgoing_rate"{Eq}\" ENTER(VALUE2); BUFFERSET(A_cpu_max_outgoing_rate);
434
435  ">" {
436   if (!A_cpu_name) FAIL("Required attribute `name' not set for `cpu' element.");
437   if (!A_cpu_power) FAIL("Required attribute `power' not set for `cpu' element.");
438   LEAVE; STag_cpu();pcdata = NULL; ENTER(E_cpu);
439  }
440  "/>" {
441   if (!A_cpu_name) FAIL("Required attribute `name' not set for `cpu' element.");
442   if (!A_cpu_power) FAIL("Required attribute `power' not set for `cpu' element.");
443   LEAVE; STag_cpu(); pcdata = NULL; ETag_cpu();
444   switch (YY_START) {
445    case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
446    case S_include: case S_include_2: case S_include_1: SET(S_include_2); break;
447    case ROOT_cpu: SET(EPILOG); break;
448   }
449  }
450  .       FAIL("Unexpected character `%c' in attribute list of cpu element.", yytext[0]);
451  {Name} FAIL("Bad attribute `%s' in `cpu' element start tag.",yytext);
452  <<EOF>> FAIL("EOF in attribute list of `cpu' element.");
453 }
454
455 <E_cpu>{
456  "</cpu"{s}">" {
457   LEAVE;
458   ETag_cpu();
459   switch (YY_START) {
460    case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
461    case S_include: case S_include_2: case S_include_1: SET(S_include_2); break;
462    case ROOT_cpu: SET(EPILOG); break;
463   }
464  }
465  "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</cpu>' expected.",yytext);
466  .       FAIL("Unexpected character `%c': `</cpu>' expected.",yytext[0]);
467  <<EOF>> FAIL("Premature EOF: `</cpu>' expected.");
468 }
469
470 <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} {
471   A_network_link_name = NULL;
472   A_network_link_bandwidth = NULL;
473   A_network_link_bandwidth_file = NULL;
474   A_network_link_latency = "0.0";
475   A_network_link_latency_file = NULL;
476   A_network_link_state = A_network_link_state_ON;
477   A_network_link_state_file = NULL;
478   ENTER(AL_network_link);
479   }
480
481 <AL_network_link>{
482  "name"{Eq}\' ENTER(VALUE1); BUFFERSET(A_network_link_name);
483  "name"{Eq}\" ENTER(VALUE2); BUFFERSET(A_network_link_name);
484
485  "bandwidth"{Eq}\' ENTER(VALUE1); BUFFERSET(A_network_link_bandwidth);
486  "bandwidth"{Eq}\" ENTER(VALUE2); BUFFERSET(A_network_link_bandwidth);
487
488  "bandwidth_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_network_link_bandwidth_file);
489  "bandwidth_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_network_link_bandwidth_file);
490
491  "latency"{Eq}\' ENTER(VALUE1); BUFFERSET(A_network_link_latency);
492  "latency"{Eq}\" ENTER(VALUE2); BUFFERSET(A_network_link_latency);
493
494  "latency_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_network_link_latency_file);
495  "latency_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_network_link_latency_file);
496
497  "state"{Eq}"'ON'" |
498  "state"{Eq}"\"ON\"" A_network_link_state = A_network_link_state_ON;
499  "state"{Eq}"'OFF'" |
500  "state"{Eq}"\"OFF\"" A_network_link_state = A_network_link_state_OFF;
501
502  "state_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_network_link_state_file);
503  "state_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_network_link_state_file);
504
505  ">" {
506   if (!A_network_link_name) FAIL("Required attribute `name' not set for `network_link' element.");
507   if (!A_network_link_bandwidth) FAIL("Required attribute `bandwidth' not set for `network_link' element.");
508   LEAVE; STag_network_link();pcdata = NULL; ENTER(E_network_link);
509  }
510  "/>" {
511   if (!A_network_link_name) FAIL("Required attribute `name' not set for `network_link' element.");
512   if (!A_network_link_bandwidth) FAIL("Required attribute `bandwidth' not set for `network_link' element.");
513   LEAVE; STag_network_link(); pcdata = NULL; ETag_network_link();
514   switch (YY_START) {
515    case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
516    case S_include: case S_include_2: case S_include_1: SET(S_include_2); break;
517    case ROOT_network_link: SET(EPILOG); break;
518   }
519  }
520  .       FAIL("Unexpected character `%c' in attribute list of network_link element.", yytext[0]);
521  {Name} FAIL("Bad attribute `%s' in `network_link' element start tag.",yytext);
522  <<EOF>> FAIL("EOF in attribute list of `network_link' element.");
523 }
524
525 <E_network_link>{
526  "</network_link"{s}">" {
527   LEAVE;
528   ETag_network_link();
529   switch (YY_START) {
530    case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
531    case S_include: case S_include_2: case S_include_1: SET(S_include_2); break;
532    case ROOT_network_link: SET(EPILOG); break;
533   }
534  }
535  "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</network_link>' expected.",yytext);
536  .       FAIL("Unexpected character `%c': `</network_link>' expected.",yytext[0]);
537  <<EOF>> FAIL("Premature EOF: `</network_link>' expected.");
538 }
539
540 <ROOT_route,S_platform_description_2,S_include,S_include_2,S_platform_description_1,S_include_1,S_platform_description>"<route"{s} {
541   A_route_src = NULL;
542   A_route_dst = NULL;
543   A_route_impact_on_src = "0.0";
544   A_route_impact_on_dst = "0.0";
545   A_route_impact_on_src_with_other_recv = "0.0";
546   A_route_impact_on_dst_with_other_send = "0.0";
547   ENTER(AL_route);
548   }
549
550 <AL_route>{
551  "src"{Eq}\' ENTER(VALUE1); BUFFERSET(A_route_src);
552  "src"{Eq}\" ENTER(VALUE2); BUFFERSET(A_route_src);
553
554  "dst"{Eq}\' ENTER(VALUE1); BUFFERSET(A_route_dst);
555  "dst"{Eq}\" ENTER(VALUE2); BUFFERSET(A_route_dst);
556
557  "impact_on_src"{Eq}\' ENTER(VALUE1); BUFFERSET(A_route_impact_on_src);
558  "impact_on_src"{Eq}\" ENTER(VALUE2); BUFFERSET(A_route_impact_on_src);
559
560  "impact_on_dst"{Eq}\' ENTER(VALUE1); BUFFERSET(A_route_impact_on_dst);
561  "impact_on_dst"{Eq}\" ENTER(VALUE2); BUFFERSET(A_route_impact_on_dst);
562
563  "impact_on_src_with_other_recv"{Eq}\' ENTER(VALUE1); BUFFERSET(A_route_impact_on_src_with_other_recv);
564  "impact_on_src_with_other_recv"{Eq}\" ENTER(VALUE2); BUFFERSET(A_route_impact_on_src_with_other_recv);
565
566  "impact_on_dst_with_other_send"{Eq}\' ENTER(VALUE1); BUFFERSET(A_route_impact_on_dst_with_other_send);
567  "impact_on_dst_with_other_send"{Eq}\" ENTER(VALUE2); BUFFERSET(A_route_impact_on_dst_with_other_send);
568
569  ">" {
570   if (!A_route_src) FAIL("Required attribute `src' not set for `route' element.");
571   if (!A_route_dst) FAIL("Required attribute `dst' not set for `route' element.");
572   LEAVE; STag_route();pcdata = NULL; ENTER(S_route);
573  }
574  "/>" {
575   if (!A_route_src) FAIL("Required attribute `src' not set for `route' element.");
576   if (!A_route_dst) FAIL("Required attribute `dst' not set for `route' element.");
577   LEAVE; STag_route(); pcdata = NULL; ETag_route();
578   switch (YY_START) {
579    case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
580    case S_include: case S_include_2: case S_include_1: SET(S_include_2); break;
581    case ROOT_route: SET(EPILOG); break;
582   }
583  }
584  .       FAIL("Unexpected character `%c' in attribute list of route element.", yytext[0]);
585  {Name} FAIL("Bad attribute `%s' in `route' element start tag.",yytext);
586  <<EOF>> FAIL("EOF in attribute list of `route' element.");
587 }
588
589 <S_route,S_route_2,E_route>{
590  "</route"{s}">" {
591   LEAVE;
592   ETag_route();
593   switch (YY_START) {
594    case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
595    case S_include: case S_include_2: case S_include_1: SET(S_include_2); break;
596    case ROOT_route: SET(EPILOG); break;
597   }
598  }
599  "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</route>' expected.",yytext);
600  .       FAIL("Unexpected character `%c': `</route>' expected.",yytext[0]);
601  <<EOF>> FAIL("Premature EOF: `</route>' expected.");
602 }
603
604 <ROOT_route_element,S_route_1,S_route,S_route_2>"<route_element"{s} {
605   A_route_element_name = NULL;
606   ENTER(AL_route_element);
607   }
608
609 <AL_route_element>{
610  "name"{Eq}\' ENTER(VALUE1); BUFFERSET(A_route_element_name);
611  "name"{Eq}\" ENTER(VALUE2); BUFFERSET(A_route_element_name);
612
613  ">" {
614   if (!A_route_element_name) FAIL("Required attribute `name' not set for `route_element' element.");
615   LEAVE; STag_route_element();pcdata = NULL; ENTER(E_route_element);
616  }
617  "/>" {
618   if (!A_route_element_name) FAIL("Required attribute `name' not set for `route_element' element.");
619   LEAVE; STag_route_element(); pcdata = NULL; ETag_route_element();
620   switch (YY_START) {
621    case S_route_1: case S_route: case S_route_2: SET(S_route_2); break;
622    case ROOT_route_element: SET(EPILOG); break;
623   }
624  }
625  .       FAIL("Unexpected character `%c' in attribute list of route_element element.", yytext[0]);
626  {Name} FAIL("Bad attribute `%s' in `route_element' element start tag.",yytext);
627  <<EOF>> FAIL("EOF in attribute list of `route_element' element.");
628 }
629
630 <E_route_element>{
631  "</route_element"{s}">" {
632   LEAVE;
633   ETag_route_element();
634   switch (YY_START) {
635    case S_route_1: case S_route: case S_route_2: SET(S_route_2); break;
636    case ROOT_route_element: SET(EPILOG); break;
637   }
638  }
639  "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</route_element>' expected.",yytext);
640  .       FAIL("Unexpected character `%c': `</route_element>' expected.",yytext[0]);
641  <<EOF>> FAIL("Premature EOF: `</route_element>' expected.");
642 }
643
644 <ROOT_process,S_platform_description_2,S_include,S_include_2,S_platform_description_1,S_include_1,S_platform_description>"<process"{s} {
645   A_process_host = NULL;
646   A_process_function = NULL;
647   ENTER(AL_process);
648   }
649
650 <AL_process>{
651  "host"{Eq}\' ENTER(VALUE1); BUFFERSET(A_process_host);
652  "host"{Eq}\" ENTER(VALUE2); BUFFERSET(A_process_host);
653
654  "function"{Eq}\' ENTER(VALUE1); BUFFERSET(A_process_function);
655  "function"{Eq}\" ENTER(VALUE2); BUFFERSET(A_process_function);
656
657  ">" {
658   if (!A_process_host) FAIL("Required attribute `host' not set for `process' element.");
659   if (!A_process_function) FAIL("Required attribute `function' not set for `process' element.");
660   LEAVE; STag_process();pcdata = NULL; ENTER(S_process);
661  }
662  "/>" {
663   if (!A_process_host) FAIL("Required attribute `host' not set for `process' element.");
664   if (!A_process_function) FAIL("Required attribute `function' not set for `process' element.");
665   LEAVE; STag_process(); pcdata = NULL; ETag_process();
666   switch (YY_START) {
667    case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
668    case S_include: case S_include_2: case S_include_1: SET(S_include_2); break;
669    case ROOT_process: SET(EPILOG); break;
670   }
671  }
672  .       FAIL("Unexpected character `%c' in attribute list of process element.", yytext[0]);
673  {Name} FAIL("Bad attribute `%s' in `process' element start tag.",yytext);
674  <<EOF>> FAIL("EOF in attribute list of `process' element.");
675 }
676
677 <S_process,E_process,S_process_2>{
678  "</process"{s}">" {
679   LEAVE;
680   ETag_process();
681   switch (YY_START) {
682    case S_platform_description_2: case S_platform_description_1: case S_platform_description: SET(S_platform_description_2); break;
683    case S_include: case S_include_2: case S_include_1: SET(S_include_2); break;
684    case ROOT_process: SET(EPILOG); break;
685   }
686  }
687  "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</process>' expected.",yytext);
688  .       FAIL("Unexpected character `%c': `</process>' expected.",yytext[0]);
689  <<EOF>> FAIL("Premature EOF: `</process>' expected.");
690 }
691
692 <ROOT_argument,S_process_1,S_process,S_process_2>"<argument"{s} {
693   A_argument_value = NULL;
694   ENTER(AL_argument);
695   }
696
697 <AL_argument>{
698  "value"{Eq}\' ENTER(VALUE1); BUFFERSET(A_argument_value);
699  "value"{Eq}\" ENTER(VALUE2); BUFFERSET(A_argument_value);
700
701  ">" {
702   if (!A_argument_value) FAIL("Required attribute `value' not set for `argument' element.");
703   LEAVE; STag_argument();pcdata = NULL; ENTER(E_argument);
704  }
705  "/>" {
706   if (!A_argument_value) FAIL("Required attribute `value' not set for `argument' element.");
707   LEAVE; STag_argument(); pcdata = NULL; ETag_argument();
708   switch (YY_START) {
709    case ROOT_argument: SET(EPILOG); break;
710    case S_process_1: case S_process: case S_process_2: SET(S_process_2); break;
711   }
712  }
713  .       FAIL("Unexpected character `%c' in attribute list of argument element.", yytext[0]);
714  {Name} FAIL("Bad attribute `%s' in `argument' element start tag.",yytext);
715  <<EOF>> FAIL("EOF in attribute list of `argument' element.");
716 }
717
718 <E_argument>{
719  "</argument"{s}">" {
720   LEAVE;
721   ETag_argument();
722   switch (YY_START) {
723    case ROOT_argument: SET(EPILOG); break;
724    case S_process_1: case S_process: case S_process_2: SET(S_process_2); break;
725   }
726  }
727  "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</argument>' expected.",yytext);
728  .       FAIL("Unexpected character `%c': `</argument>' expected.",yytext[0]);
729  <<EOF>> FAIL("Premature EOF: `</argument>' expected.");
730 }
731
732  /* EPILOG: after the root element. */
733
734 <EPILOG>{
735  . {SET(PROLOG); yyless(0); return -1;}
736  <<EOF>>        SUCCEED;
737 }
738
739  /* CHARACTER DATA. */
740
741 <IMPOSSIBLE,VALUE1,VALUE2>{
742  /* Non-defined standard entities... */
743 "&amp;"  BUFFERPUTC('&');
744 "&lt;"   BUFFERPUTC('<');
745 "&gt;"   BUFFERPUTC('>');
746 "&apos;" BUFFERPUTC('\'');
747 "&quot;" BUFFERPUTC('"');
748
749  /* Character entities. */
750  "&#"[[:digit:]]+";"    BUFFERPUTC((unsigned char)atoi(yytext+2));
751  "&#x"[[:xdigit:]]+";"  BUFFERPUTC((unsigned char)strtol(yytext+3,NULL,16));
752 }
753
754 <IMPOSSIBLE,VALUE1,VALUE2,CDATA>{
755  "\n"           |
756  "\r"           |
757  "\r\n"         |
758  "\n\r"         BUFFERPUTC('\n');
759 }
760
761 <IMPOSSIBLE>{
762  "<![CDATA["    ENTER(CDATA);
763  "]""]>"                FAIL("Unexpected `]""]>' in character data.");
764 }
765
766 <VALUE1>{
767  \'             BUFFERDONE; LEAVE;
768  <<EOF>>        FAIL("EOF in literal (\"'\" expected).");
769 }
770
771 <VALUE2>{
772  \"             BUFFERDONE; LEAVE;
773  <<EOF>>        FAIL("EOF in literal (`\"' expected).");
774 }
775
776 <IMPOSSIBLE,VALUE1,VALUE2>{
777  [^<&]          BUFFERPUTC(yytext[0]);
778  [<&]           FAIL("Spurious `%c' in character data.",yytext[0]);
779 }
780
781 <CDATA>{
782  "]""]>"                LEAVE;
783  /* "]""]"              BUFFERPUTC(yytext[0]); BUFFERPUTC(yytext[1]); */
784  .              BUFFERPUTC(yytext[0]);
785  <<EOF>>        FAIL("EOF in CDATA section.");
786 }
787
788  /* Impossible rules to avoid warnings from flex(1). */
789  /* Ideally, this should be replaced by code in flexml.pl that
790     generates just the states not covered by other rules. */
791 <*>{
792  .|[\n] FAIL("Syntax error on character `%c'.", yytext[0]);
793 }
794
795 %%
796
797 /* Element context stack lookup. */
798 int element_context(int i)
799 {
800   return (0<i && i<yy_start_stack_depth
801           ? yy_start_stack[yy_start_stack_ptr - i]
802           : 0);
803 }
804
805 #ifdef FLEX_DEBUG
806 void print_yy_stack(char* fmt, ...)
807 {
808   int i = 0; va_list ap; va_start(ap, fmt);
809   vfprintf(stderr, fmt, ap);
810   for (i=1; i<yy_start_stack_ptr; i++)
811     fprintf(stderr, "%s/", statenames[yy_start_stack[i] ]);
812   fprintf(stderr,"%s\n", statenames[YY_START]);
813   va_end(ap);
814 }
815
816 static void debug_enter(int state, const char* statename) {
817   yy_push_state(state);
818   if (yy_flex_debug) print_yy_stack("--ENTER(%s) : ",statename);
819 }
820
821 static void debug_leave(void) {
822   if (yy_flex_debug) print_yy_stack("--LEAVE : ");
823   yy_pop_state();
824 }
825
826 static void debug_set(int state, const char* statename) {
827   BEGIN(state);
828   if (yy_flex_debug) print_yy_stack("--SET(%s) : ",statename);
829 }
830 #endif
831
832 enum {flexml_max_err_msg_size = 512};
833
834 static char flexml_err_msg[flexml_max_err_msg_size];
835 const char * parse_err_msg()
836 {
837     return flexml_err_msg;
838 }
839
840 static void reset_parse_err_msg()
841 {
842     flexml_err_msg[0] = '\0';
843 }
844
845
846 static int fail(const char* fmt, ...)
847 {
848     int chars_left, used;
849     va_list ap; va_start(ap, fmt);
850 #ifdef FLEXML_yylineno
851     used = sprintf(flexml_err_msg,
852                    "Invalid XML (XML input line %d, state %d): ",
853                    yylineno, YY_START);
854 #else
855     used = sprintf(flexml_err_msg,
856                    "Invalid XML (state %d): ",
857                    YY_START);
858 #endif
859     chars_left = flexml_max_err_msg_size - used - 1;
860     vsnprintf(flexml_err_msg + used, chars_left, fmt, ap);
861     va_end(ap);
862
863 #ifndef FLEXML_quiet_parser
864     /* print directly to sdterr */
865     fprintf(stderr, "%s\n", flexml_err_msg);
866     flexml_err_msg[0] = '\0';
867 #endif
868    
869     return 1;
870 }