Logo AND Algorithmique Numérique Distribuée

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