Logo AND Algorithmique Numérique Distribuée

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