Logo AND Algorithmique Numérique Distribuée

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