Logo AND Algorithmique Numérique Distribuée

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