Logo AND Algorithmique Numérique Distribuée

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