Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update workstation handling in SimDag. Change the prefix of SimDag functions with...
[simgrid.git] / src / surf / surfxml.l
1 /* Validating XML processor for surfxml.dtd.
2  * Generated 2006/05/29 23:03:05.
3  *
4  * This program was generated with the FleXML XML processor generator.
5  * FleXML is Copyright © 1999-2005 Kristoffer Rose.  All rights reserved.
6  * (Id: flexml.pl,v 1.48 2006/03/21 13:09:12 mquinson Exp).
7  * 
8  * There are two, intertwined parts to this program, part A and part B.
9  *
10  * Part A
11  * ------
12  * 
13  * Some parts, here collectively called "Part A", are found in the 
14  * FleXML package.  They are Copyright © 1999-2005 Kristoffer Rose. 
15  * All rights reserved.
16  *
17  * You can redistribute, use, perform, display and/or modify "Part A"
18  * provided the following two conditions hold:
19  *
20  * 1. The program is distributed WITHOUT ANY WARRANTY from the author of
21  *    FleXML; without even the implied warranty of MERCHANTABILITY or
22  *    FITNESS FOR A PARTICULAR PURPOSE.
23  *
24  * 2. The program distribution conditions do not in any way affect the
25  *    distribution conditions of the FleXML system used to generate this
26  *    file or any version of FleXML derived from that system.
27  *
28  * Notice that these are explicit rights granted to you for files
29  * generated by the FleXML system.  For your rights in connection with
30  * the FleXML system itself please consult the GNU General Public License.
31  * 
32  * Part B
33  * ------
34  * 
35  * The other parts, here collectively called "Part B", and which came 
36  * from the DTD used by FleXML to generate this program, can be 
37  * distributed (or not, as the case may be) under the terms of whoever
38  * wrote them, provided these terms respect and obey the two conditions 
39  * above under the heading "Part A".
40  *
41  * The author of and contributors to FleXML specifically disclaim
42  * any copyright interest in "Part B", unless "Part B" was written 
43  * by the author of or contributors to FleXML.
44  * 
45  */
46
47 %{
48
49 /* Version strings. */
50 const char rcs_surfxml_flexml_skeleton[] =
51  "$" "Id: skel,v 1.28 2006/03/21 12:04:13 legranda Exp $";
52 const char rcs_surfxml_flexml[] =
53  "$" "Id: flexml.pl,v 1.48 2006/03/21 13:09:12 mquinson Exp $";
54
55 /* ANSI headers. */
56 #include <unistd.h>
57 #include <stdio.h>
58 #include <string.h>
59 #include <assert.h>
60 #include <stdarg.h>
61 #include <ctype.h>
62
63 /* Generated definitions. */
64 #define FLEXML_yylineno
65 #define FLEXML_BUFFERSTACKSIZE 1000000
66
67 /* XML processor api. */
68 /* FleXML-provided data. */
69 const char* surfxml_pcdata;
70 AT_surfxml_network_link_bandwidth A_surfxml_network_link_bandwidth;
71 AT_surfxml_process_host A_surfxml_process_host;
72 AT_surfxml_network_link_latency_file A_surfxml_network_link_latency_file;
73 AT_surfxml_route_impact_on_dst_with_other_send A_surfxml_route_impact_on_dst_with_other_send;
74 AT_surfxml_cpu_interference_send_recv A_surfxml_cpu_interference_send_recv;
75 AT_surfxml_route_impact_on_dst A_surfxml_route_impact_on_dst;
76 AT_surfxml_platform_description_version A_surfxml_platform_description_version;
77 AT_surfxml_route_impact_on_src_with_other_recv A_surfxml_route_impact_on_src_with_other_recv;
78 AT_surfxml_route_element_name A_surfxml_route_element_name;
79 AT_surfxml_process_start_time A_surfxml_process_start_time;
80 AT_surfxml_process_function A_surfxml_process_function;
81 AT_surfxml_cpu_state A_surfxml_cpu_state;
82 AT_surfxml_cpu_interference_send A_surfxml_cpu_interference_send;
83 AT_surfxml_network_link_bandwidth_file A_surfxml_network_link_bandwidth_file;
84 AT_surfxml_cpu_name A_surfxml_cpu_name;
85 AT_surfxml_process_kill_time A_surfxml_process_kill_time;
86 AT_surfxml_network_link_state A_surfxml_network_link_state;
87 AT_surfxml_cpu_availability_file A_surfxml_cpu_availability_file;
88 AT_surfxml_argument_value A_surfxml_argument_value;
89 AT_surfxml_route_src A_surfxml_route_src;
90 AT_surfxml_route_impact_on_src A_surfxml_route_impact_on_src;
91 AT_surfxml_cpu_max_outgoing_rate A_surfxml_cpu_max_outgoing_rate;
92 AT_surfxml_cpu_availability A_surfxml_cpu_availability;
93 AT_surfxml_cpu_interference_recv A_surfxml_cpu_interference_recv;
94 AT_surfxml_network_link_name A_surfxml_network_link_name;
95 AT_surfxml_cpu_power A_surfxml_cpu_power;
96 AT_surfxml_include_file A_surfxml_include_file;
97 AT_surfxml_network_link_sharing_policy A_surfxml_network_link_sharing_policy;
98 AT_surfxml_route_dst A_surfxml_route_dst;
99 AT_surfxml_network_link_latency A_surfxml_network_link_latency;
100 AT_surfxml_cpu_state_file A_surfxml_cpu_state_file;
101 AT_surfxml_network_link_state_file A_surfxml_network_link_state_file;
102
103 /* XML state. */
104 #ifdef FLEX_DEBUG
105 # define ENTER(state)   debug_enter(state,#state)
106 # define LEAVE          debug_leave()
107 # define SET(state)     debug_set(state,#state)
108   static void debug_enter(int, const char*);
109   static void debug_leave(void);
110   static void debug_set(int, const char*);
111 #else
112 # define ENTER(state)   (yy_push_state(state))
113 # define LEAVE          (yy_pop_state())
114 # define SET(state)     BEGIN(state)
115 #endif
116
117 /* Generic actions. */
118 #define SKIP    /*skip*/
119 #define SUCCEED        CLEANUP; return 0
120
121 #define FAIL    return fail
122 static int fail(const char*, ...);
123 const char * surfxml_parse_err_msg(void);
124
125 /* Cleanup */
126 static void cleanup(void);
127 #define CLEANUP  cleanup()
128
129 /* Text buffer stack handling. */
130 static char bufferstack[FLEXML_BUFFERSTACKSIZE];
131 static char* limit = bufferstack + FLEXML_BUFFERSTACKSIZE;
132 typedef struct BufferLast_s {
133   struct BufferLast_s *old; char* saved; char new1[1];
134 } BufferLast;
135 #ifdef FLEXML_HasMixed
136 static BufferLast* last = (BufferLast*)0;
137 #endif
138 static char* next = bufferstack;
139
140 #define BUFFERSET(P)  (P = next)
141 #define BUFFERPUTC(C) (assert(next<limit), *(next++) = (C))
142 #define BUFFERDONE    (BUFFERPUTC('\0'))
143
144 #define BUFFERLITERAL(C,P) bufferliteral(C,&(P),yytext)
145 static void bufferliteral(char c, const char** pp, char* text)
146 {
147   char *s = strchr(text,c), *e = strrchr(text,c);
148   assert(s <= e); BUFFERSET(*pp);
149   while (++s<e) {
150     if (isspace(*s)) { BUFFERPUTC(' '); while (isspace(*s)) ++s; }
151     else BUFFERPUTC(*s);
152   }
153   BUFFERDONE;
154 }
155
156 #ifdef FLEXML_HasMixed
157 static void pushbuffer(char* p)
158 {
159   BufferLast* l = (BufferLast*)next;
160   assert(next < limit);
161   l->old = last;
162   l->saved = p;
163   next = l->new1;
164   last = l;
165 }
166
167 static char* popbuffer(void)
168 {
169   BufferLast* l = last;
170   assert(last != (BufferLast*)0);
171   last = l->old;
172   next = (char*)l;
173   return l->saved;
174 }
175 #endif
176
177 /* General internal entities are `unput' back onto the input stream... */
178 #define ENTITYTEXT(T) \
179   { char *s = (T), *e = s+strlen(s);\
180     while (--e >= s) { unput(*e); }}
181 %}
182
183 /* Flex standard options. */
184 %option stack
185 %option noyy_top_state
186 %option noinput
187 %option noreject
188 %option noyymore
189 %option noyywrap
190
191 /* Flex user-requested options. */
192 %option yylineno
193 %option nounput
194
195 /* XML character classes (currently restricted to ASCII). */
196
197 /* "Common syntactic structures." */
198 S               [ \t\n\r\f]+
199 s               [ \t\n\r\f]*
200
201 /* "Names and Tokens." */
202 NameChar        [A-Za-z0-9.:_-]
203 Name            [A-Za-z_:]{NameChar}*
204 Names           {Name}({S}{Name})*
205 Nmtoken         ({NameChar})+
206 Nmtokens        {Nmtoken}({S}{Nmtoken})*
207
208 /* Miscellaneous. */
209 VersionNum      [a-zA-Z0-9_.:-]+
210 Eq              {s}"="{s}
211 Literal         \'[^'']*\'|\"[^""]*\"
212
213 /* Parser states (flex `exclusive start conditions'):
214  *
215  * PROLOG       the XML prolog of the document before <?xml...>
216  * DOCTYPE      the XML prolog of the document after <?xml...>
217  * EPILOG       after the root element
218  * INCOMMENT    inside an XML comment <!--....-->
219  * INPI         inside an XML PI <?...?>
220  * VALUE1       inside a '...'-delimited literal
221  * VALUE2       inside a "..."-delimited literal
222  * CDATA        inside a <![CDATA[...] ]> section.
223  * ROOT_<tag>   expect root element <tag>
224  * AL_<tag>     inside the attribute list for <tag>
225  * IN_<tag>     inside a <tag> with element contents (ready for end tag)
226  * IMPOSSIBLE   dummy to permit disabling rules; must be last
227  */
228 %x PROLOG DOCTYPE EPILOG INCOMMENT INPI VALUE1 VALUE2 CDATA
229 %x ROOT_surfxml_platform_description AL_surfxml_platform_description S_surfxml_platform_description S_surfxml_platform_description_1 S_surfxml_platform_description_2 E_surfxml_platform_description
230 %x ROOT_surfxml_include AL_surfxml_include S_surfxml_include S_surfxml_include_1 S_surfxml_include_2 E_surfxml_include
231 %x ROOT_surfxml_cpu AL_surfxml_cpu E_surfxml_cpu
232 %x ROOT_surfxml_network_link AL_surfxml_network_link E_surfxml_network_link
233 %x ROOT_surfxml_route AL_surfxml_route S_surfxml_route S_surfxml_route_1 S_surfxml_route_2 E_surfxml_route
234 %x ROOT_surfxml_route_element AL_surfxml_route_element E_surfxml_route_element
235 %x ROOT_surfxml_process AL_surfxml_process S_surfxml_process S_surfxml_process_1 S_surfxml_process_2 E_surfxml_process
236 %x ROOT_surfxml_argument AL_surfxml_argument E_surfxml_argument
237 %x IMPOSSIBLE
238
239 %{
240 /* State names. */
241 const char* *surfxml_statenames=NULL;
242 %}
243
244 %%
245
246  /* Bypass Flex's default INITIAL state and begin by parsing the XML prolog. */
247  SET(PROLOG);
248   /* FleXML_init */
249   next = bufferstack;
250   if(!surfxml_statenames) {surfxml_statenames= (const char **)calloc(IMPOSSIBLE,sizeof(char*));
251   surfxml_statenames[PROLOG] = NULL;
252   surfxml_statenames[DOCTYPE] = NULL;
253   surfxml_statenames[EPILOG] = NULL;
254   surfxml_statenames[INCOMMENT] = NULL;
255   surfxml_statenames[INPI] = NULL;
256   surfxml_statenames[VALUE1] = NULL;
257   surfxml_statenames[VALUE2] = NULL;
258   surfxml_statenames[CDATA] = NULL;
259   surfxml_statenames[ROOT_surfxml_platform_description] = NULL;
260   surfxml_statenames[AL_surfxml_platform_description] = NULL;
261   surfxml_statenames[S_surfxml_platform_description] = "platform_description";
262   surfxml_statenames[S_surfxml_platform_description_1] = "platform_description";
263   surfxml_statenames[S_surfxml_platform_description_2] = "platform_description";
264   surfxml_statenames[E_surfxml_platform_description] = "platform_description";
265   surfxml_statenames[ROOT_surfxml_include] = NULL;
266   surfxml_statenames[AL_surfxml_include] = NULL;
267   surfxml_statenames[S_surfxml_include] = "include";
268   surfxml_statenames[S_surfxml_include_1] = "include";
269   surfxml_statenames[S_surfxml_include_2] = "include";
270   surfxml_statenames[E_surfxml_include] = "include";
271   surfxml_statenames[ROOT_surfxml_cpu] = NULL;
272   surfxml_statenames[AL_surfxml_cpu] = NULL;
273   surfxml_statenames[E_surfxml_cpu] = "cpu";
274   surfxml_statenames[ROOT_surfxml_network_link] = NULL;
275   surfxml_statenames[AL_surfxml_network_link] = NULL;
276   surfxml_statenames[E_surfxml_network_link] = "network_link";
277   surfxml_statenames[ROOT_surfxml_route] = NULL;
278   surfxml_statenames[AL_surfxml_route] = NULL;
279   surfxml_statenames[S_surfxml_route] = "route";
280   surfxml_statenames[S_surfxml_route_1] = "route";
281   surfxml_statenames[S_surfxml_route_2] = "route";
282   surfxml_statenames[E_surfxml_route] = "route";
283   surfxml_statenames[ROOT_surfxml_route_element] = NULL;
284   surfxml_statenames[AL_surfxml_route_element] = NULL;
285   surfxml_statenames[E_surfxml_route_element] = "route_element";
286   surfxml_statenames[ROOT_surfxml_process] = NULL;
287   surfxml_statenames[AL_surfxml_process] = NULL;
288   surfxml_statenames[S_surfxml_process] = "process";
289   surfxml_statenames[S_surfxml_process_1] = "process";
290   surfxml_statenames[S_surfxml_process_2] = "process";
291   surfxml_statenames[E_surfxml_process] = "process";
292   surfxml_statenames[ROOT_surfxml_argument] = NULL;
293   surfxml_statenames[AL_surfxml_argument] = NULL;
294   surfxml_statenames[E_surfxml_argument] = "argument";
295   }
296
297  /* COMMENTS and PIs: handled uniformly for efficiency. */
298
299 <ROOT_surfxml_platform_description,AL_surfxml_platform_description,S_surfxml_platform_description,S_surfxml_platform_description_1,S_surfxml_platform_description_2,E_surfxml_platform_description,ROOT_surfxml_include,AL_surfxml_include,S_surfxml_include,S_surfxml_include_1,S_surfxml_include_2,E_surfxml_include,ROOT_surfxml_cpu,AL_surfxml_cpu,E_surfxml_cpu,ROOT_surfxml_network_link,AL_surfxml_network_link,E_surfxml_network_link,ROOT_surfxml_route,AL_surfxml_route,S_surfxml_route,S_surfxml_route_1,S_surfxml_route_2,E_surfxml_route,ROOT_surfxml_route_element,AL_surfxml_route_element,E_surfxml_route_element,ROOT_surfxml_process,AL_surfxml_process,S_surfxml_process,S_surfxml_process_1,S_surfxml_process_2,E_surfxml_process,ROOT_surfxml_argument,AL_surfxml_argument,E_surfxml_argument,PROLOG,DOCTYPE,EPILOG>{
300  "<!--" ENTER(INCOMMENT);
301  "<?" ENTER(INPI);
302 }
303 <INCOMMENT>{
304  "-->"          LEAVE;
305  "--"           |
306  .              |
307  \n             SKIP;
308  <<EOF>>        FAIL("EOF in comment.");
309 }
310 <INPI>{
311  "?>"           LEAVE;
312  .              |
313  \n             SKIP;
314  <<EOF>>        FAIL("EOF in PI (processing instruction).");
315 }
316
317  /* SPACES: skipped uniformly */
318
319 <ROOT_surfxml_platform_description,AL_surfxml_platform_description,S_surfxml_platform_description,S_surfxml_platform_description_1,S_surfxml_platform_description_2,E_surfxml_platform_description,ROOT_surfxml_include,AL_surfxml_include,S_surfxml_include,S_surfxml_include_1,S_surfxml_include_2,E_surfxml_include,ROOT_surfxml_cpu,AL_surfxml_cpu,E_surfxml_cpu,ROOT_surfxml_network_link,AL_surfxml_network_link,E_surfxml_network_link,ROOT_surfxml_route,AL_surfxml_route,S_surfxml_route,S_surfxml_route_1,S_surfxml_route_2,E_surfxml_route,ROOT_surfxml_route_element,AL_surfxml_route_element,E_surfxml_route_element,ROOT_surfxml_process,AL_surfxml_process,S_surfxml_process,S_surfxml_process_1,S_surfxml_process_2,E_surfxml_process,ROOT_surfxml_argument,AL_surfxml_argument,E_surfxml_argument,PROLOG,DOCTYPE,EPILOG>{S} SKIP;
320
321  /* PROLOG: determine root element and process it. */
322
323 <PROLOG>{
324  "<?xml"({S}version{Eq}(\'{VersionNum}\'|\"{VersionNum}\"))?({S}encoding{Eq}(\'[^']*\'|\"[^"]*\"))?"?>" SET(DOCTYPE); 
325  "<?xml"[^>]*">" FAIL("Bad declaration %s.",yytext);
326 }
327
328 <PROLOG,DOCTYPE>{
329  "<!DOCTYPE"{S}"argument"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_surfxml_argument);
330  "<!DOCTYPE"{S}"route_element"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_surfxml_route_element);
331  "<!DOCTYPE"{S}"cpu"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_surfxml_cpu);
332  "<!DOCTYPE"{S}"include"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_surfxml_include);
333  "<!DOCTYPE"{S}"route"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_surfxml_route);
334  "<!DOCTYPE"{S}"platform_description"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_surfxml_platform_description);
335  "<!DOCTYPE"{S}"network_link"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_surfxml_network_link);
336  "<!DOCTYPE"{S}"process"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_surfxml_process);
337  "<!"[^>-][^>]*">" FAIL("Bad declaration %s.",yytext);
338  .              FAIL("Unexpected character `%c' in prolog.", yytext[0]);
339  <<EOF>>        FAIL("EOF in prolog.");
340 }
341
342  /* RULES DERIVED FROM DTD. */
343
344  /* <!-- Small DTD for SURF based tools. -->  */
345
346 <ROOT_surfxml_platform_description>"<platform_description"{s} {
347   A_surfxml_platform_description_version = "0.0";
348   ENTER(AL_surfxml_platform_description);
349   }
350
351 <AL_surfxml_platform_description>{
352  "version"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_platform_description_version);
353  "version"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_platform_description_version);
354
355  ">" {
356   LEAVE; STag_surfxml_platform_description();surfxml_pcdata = NULL; ENTER(S_surfxml_platform_description);
357  }
358  "/>" {
359   LEAVE; STag_surfxml_platform_description(); surfxml_pcdata = NULL; ETag_surfxml_platform_description();
360   switch (YY_START) {
361    case ROOT_surfxml_platform_description: SET(EPILOG); break;
362   }
363  }
364  .       FAIL("Unexpected character `%c' in attribute list of platform_description element.", yytext[0]);
365  {Name} FAIL("Bad attribute `%s' in `platform_description' element start tag.",yytext);
366  <<EOF>> FAIL("EOF in attribute list of `platform_description' element.");
367 }
368
369 <E_surfxml_platform_description,S_surfxml_platform_description_2,S_surfxml_platform_description>{
370  "</platform_description"{s}">" {
371   LEAVE;
372   ETag_surfxml_platform_description();
373   switch (YY_START) {
374    case ROOT_surfxml_platform_description: SET(EPILOG); break;
375   }
376  }
377  "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</platform_description>' expected.",yytext);
378  .       FAIL("Unexpected character `%c': `</platform_description>' expected.",yytext[0]);
379  <<EOF>> FAIL("Premature EOF: `</platform_description>' expected.");
380 }
381
382 <ROOT_surfxml_include,S_surfxml_platform_description_2,S_surfxml_include,S_surfxml_include_2,S_surfxml_platform_description_1,S_surfxml_include_1,S_surfxml_platform_description>"<include"{s} {
383   A_surfxml_include_file = NULL;
384   ENTER(AL_surfxml_include);
385   }
386
387 <AL_surfxml_include>{
388  "file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_include_file);
389  "file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_include_file);
390
391  ">" {
392   if (!A_surfxml_include_file) FAIL("Required attribute `file' not set for `include' element.");
393   LEAVE; STag_surfxml_include();surfxml_pcdata = NULL; ENTER(S_surfxml_include);
394  }
395  "/>" {
396   if (!A_surfxml_include_file) FAIL("Required attribute `file' not set for `include' element.");
397   LEAVE; STag_surfxml_include(); surfxml_pcdata = NULL; ETag_surfxml_include();
398   switch (YY_START) {
399    case S_surfxml_platform_description_2: case S_surfxml_platform_description_1: case S_surfxml_platform_description: SET(S_surfxml_platform_description_2); break;
400    case ROOT_surfxml_include: SET(EPILOG); break;
401    case S_surfxml_include: case S_surfxml_include_2: case S_surfxml_include_1: SET(S_surfxml_include_2); break;
402   }
403  }
404  .       FAIL("Unexpected character `%c' in attribute list of include element.", yytext[0]);
405  {Name} FAIL("Bad attribute `%s' in `include' element start tag.",yytext);
406  <<EOF>> FAIL("EOF in attribute list of `include' element.");
407 }
408
409 <E_surfxml_include,S_surfxml_include,S_surfxml_include_2>{
410  "</include"{s}">" {
411   LEAVE;
412   ETag_surfxml_include();
413   switch (YY_START) {
414    case S_surfxml_platform_description_2: case S_surfxml_platform_description_1: case S_surfxml_platform_description: SET(S_surfxml_platform_description_2); break;
415    case ROOT_surfxml_include: SET(EPILOG); break;
416    case S_surfxml_include: case S_surfxml_include_2: case S_surfxml_include_1: SET(S_surfxml_include_2); break;
417   }
418  }
419  "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</include>' expected.",yytext);
420  .       FAIL("Unexpected character `%c': `</include>' expected.",yytext[0]);
421  <<EOF>> FAIL("Premature EOF: `</include>' expected.");
422 }
423
424 <ROOT_surfxml_cpu,S_surfxml_platform_description_2,S_surfxml_include,S_surfxml_include_2,S_surfxml_platform_description_1,S_surfxml_include_1,S_surfxml_platform_description>"<cpu"{s} {
425   A_surfxml_cpu_name = NULL;
426   A_surfxml_cpu_power = NULL;
427   A_surfxml_cpu_availability = "1.0";
428   A_surfxml_cpu_availability_file = NULL;
429   A_surfxml_cpu_state = A_surfxml_cpu_state_ON;
430   A_surfxml_cpu_state_file = NULL;
431   A_surfxml_cpu_interference_send = "1.0";
432   A_surfxml_cpu_interference_recv = "1.0";
433   A_surfxml_cpu_interference_send_recv = "1.0";
434   A_surfxml_cpu_max_outgoing_rate = "-1.0";
435   ENTER(AL_surfxml_cpu);
436   }
437
438 <AL_surfxml_cpu>{
439  "name"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_cpu_name);
440  "name"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_cpu_name);
441
442  "power"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_cpu_power);
443  "power"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_cpu_power);
444
445  "availability"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_cpu_availability);
446  "availability"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_cpu_availability);
447
448  "availability_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_cpu_availability_file);
449  "availability_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_cpu_availability_file);
450
451  "state"{Eq}"'ON'" |
452  "state"{Eq}"\"ON\"" A_surfxml_cpu_state = A_surfxml_cpu_state_ON;
453  "state"{Eq}"'OFF'" |
454  "state"{Eq}"\"OFF\"" A_surfxml_cpu_state = A_surfxml_cpu_state_OFF;
455
456  "state_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_cpu_state_file);
457  "state_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_cpu_state_file);
458
459  "interference_send"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_cpu_interference_send);
460  "interference_send"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_cpu_interference_send);
461
462  "interference_recv"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_cpu_interference_recv);
463  "interference_recv"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_cpu_interference_recv);
464
465  "interference_send_recv"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_cpu_interference_send_recv);
466  "interference_send_recv"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_cpu_interference_send_recv);
467
468  "max_outgoing_rate"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_cpu_max_outgoing_rate);
469  "max_outgoing_rate"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_cpu_max_outgoing_rate);
470
471  ">" {
472   if (!A_surfxml_cpu_name) FAIL("Required attribute `name' not set for `cpu' element.");
473   if (!A_surfxml_cpu_power) FAIL("Required attribute `power' not set for `cpu' element.");
474   LEAVE; STag_surfxml_cpu();surfxml_pcdata = NULL; ENTER(E_surfxml_cpu);
475  }
476  "/>" {
477   if (!A_surfxml_cpu_name) FAIL("Required attribute `name' not set for `cpu' element.");
478   if (!A_surfxml_cpu_power) FAIL("Required attribute `power' not set for `cpu' element.");
479   LEAVE; STag_surfxml_cpu(); surfxml_pcdata = NULL; ETag_surfxml_cpu();
480   switch (YY_START) {
481    case S_surfxml_platform_description_2: case S_surfxml_platform_description_1: case S_surfxml_platform_description: SET(S_surfxml_platform_description_2); break;
482    case ROOT_surfxml_cpu: SET(EPILOG); break;
483    case S_surfxml_include: case S_surfxml_include_2: case S_surfxml_include_1: SET(S_surfxml_include_2); break;
484   }
485  }
486  .       FAIL("Unexpected character `%c' in attribute list of cpu element.", yytext[0]);
487  {Name} FAIL("Bad attribute `%s' in `cpu' element start tag.",yytext);
488  <<EOF>> FAIL("EOF in attribute list of `cpu' element.");
489 }
490
491 <E_surfxml_cpu>{
492  "</cpu"{s}">" {
493   LEAVE;
494   ETag_surfxml_cpu();
495   switch (YY_START) {
496    case S_surfxml_platform_description_2: case S_surfxml_platform_description_1: case S_surfxml_platform_description: SET(S_surfxml_platform_description_2); break;
497    case ROOT_surfxml_cpu: SET(EPILOG); break;
498    case S_surfxml_include: case S_surfxml_include_2: case S_surfxml_include_1: SET(S_surfxml_include_2); break;
499   }
500  }
501  "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</cpu>' expected.",yytext);
502  .       FAIL("Unexpected character `%c': `</cpu>' expected.",yytext[0]);
503  <<EOF>> FAIL("Premature EOF: `</cpu>' expected.");
504 }
505
506 <ROOT_surfxml_network_link,S_surfxml_platform_description_2,S_surfxml_include,S_surfxml_include_2,S_surfxml_platform_description_1,S_surfxml_include_1,S_surfxml_platform_description>"<network_link"{s} {
507   A_surfxml_network_link_name = NULL;
508   A_surfxml_network_link_bandwidth = NULL;
509   A_surfxml_network_link_bandwidth_file = NULL;
510   A_surfxml_network_link_latency = "0.0";
511   A_surfxml_network_link_latency_file = NULL;
512   A_surfxml_network_link_state = A_surfxml_network_link_state_ON;
513   A_surfxml_network_link_state_file = NULL;
514   A_surfxml_network_link_sharing_policy = A_surfxml_network_link_sharing_policy_SHARED;
515   ENTER(AL_surfxml_network_link);
516   }
517
518 <AL_surfxml_network_link>{
519  "name"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_network_link_name);
520  "name"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_network_link_name);
521
522  "bandwidth"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_network_link_bandwidth);
523  "bandwidth"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_network_link_bandwidth);
524
525  "bandwidth_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_network_link_bandwidth_file);
526  "bandwidth_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_network_link_bandwidth_file);
527
528  "latency"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_network_link_latency);
529  "latency"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_network_link_latency);
530
531  "latency_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_network_link_latency_file);
532  "latency_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_network_link_latency_file);
533
534  "state"{Eq}"'ON'" |
535  "state"{Eq}"\"ON\"" A_surfxml_network_link_state = A_surfxml_network_link_state_ON;
536  "state"{Eq}"'OFF'" |
537  "state"{Eq}"\"OFF\"" A_surfxml_network_link_state = A_surfxml_network_link_state_OFF;
538
539  "state_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_network_link_state_file);
540  "state_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_network_link_state_file);
541
542  "sharing_policy"{Eq}"'SHARED'" |
543  "sharing_policy"{Eq}"\"SHARED\"" A_surfxml_network_link_sharing_policy = A_surfxml_network_link_sharing_policy_SHARED;
544  "sharing_policy"{Eq}"'FATPIPE'" |
545  "sharing_policy"{Eq}"\"FATPIPE\"" A_surfxml_network_link_sharing_policy = A_surfxml_network_link_sharing_policy_FATPIPE;
546
547  ">" {
548   if (!A_surfxml_network_link_name) FAIL("Required attribute `name' not set for `network_link' element.");
549   if (!A_surfxml_network_link_bandwidth) FAIL("Required attribute `bandwidth' not set for `network_link' element.");
550   LEAVE; STag_surfxml_network_link();surfxml_pcdata = NULL; ENTER(E_surfxml_network_link);
551  }
552  "/>" {
553   if (!A_surfxml_network_link_name) FAIL("Required attribute `name' not set for `network_link' element.");
554   if (!A_surfxml_network_link_bandwidth) FAIL("Required attribute `bandwidth' not set for `network_link' element.");
555   LEAVE; STag_surfxml_network_link(); surfxml_pcdata = NULL; ETag_surfxml_network_link();
556   switch (YY_START) {
557    case S_surfxml_platform_description_2: case S_surfxml_platform_description_1: case S_surfxml_platform_description: SET(S_surfxml_platform_description_2); break;
558    case ROOT_surfxml_network_link: SET(EPILOG); break;
559    case S_surfxml_include: case S_surfxml_include_2: case S_surfxml_include_1: SET(S_surfxml_include_2); break;
560   }
561  }
562  .       FAIL("Unexpected character `%c' in attribute list of network_link element.", yytext[0]);
563  {Name} FAIL("Bad attribute `%s' in `network_link' element start tag.",yytext);
564  <<EOF>> FAIL("EOF in attribute list of `network_link' element.");
565 }
566
567 <E_surfxml_network_link>{
568  "</network_link"{s}">" {
569   LEAVE;
570   ETag_surfxml_network_link();
571   switch (YY_START) {
572    case S_surfxml_platform_description_2: case S_surfxml_platform_description_1: case S_surfxml_platform_description: SET(S_surfxml_platform_description_2); break;
573    case ROOT_surfxml_network_link: SET(EPILOG); break;
574    case S_surfxml_include: case S_surfxml_include_2: case S_surfxml_include_1: SET(S_surfxml_include_2); break;
575   }
576  }
577  "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</network_link>' expected.",yytext);
578  .       FAIL("Unexpected character `%c': `</network_link>' expected.",yytext[0]);
579  <<EOF>> FAIL("Premature EOF: `</network_link>' expected.");
580 }
581
582 <ROOT_surfxml_route,S_surfxml_platform_description_2,S_surfxml_include,S_surfxml_include_2,S_surfxml_platform_description_1,S_surfxml_include_1,S_surfxml_platform_description>"<route"{s} {
583   A_surfxml_route_src = NULL;
584   A_surfxml_route_dst = NULL;
585   A_surfxml_route_impact_on_src = "0.0";
586   A_surfxml_route_impact_on_dst = "0.0";
587   A_surfxml_route_impact_on_src_with_other_recv = "0.0";
588   A_surfxml_route_impact_on_dst_with_other_send = "0.0";
589   ENTER(AL_surfxml_route);
590   }
591
592 <AL_surfxml_route>{
593  "src"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_route_src);
594  "src"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_route_src);
595
596  "dst"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_route_dst);
597  "dst"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_route_dst);
598
599  "impact_on_src"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_route_impact_on_src);
600  "impact_on_src"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_route_impact_on_src);
601
602  "impact_on_dst"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_route_impact_on_dst);
603  "impact_on_dst"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_route_impact_on_dst);
604
605  "impact_on_src_with_other_recv"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_route_impact_on_src_with_other_recv);
606  "impact_on_src_with_other_recv"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_route_impact_on_src_with_other_recv);
607
608  "impact_on_dst_with_other_send"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_route_impact_on_dst_with_other_send);
609  "impact_on_dst_with_other_send"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_route_impact_on_dst_with_other_send);
610
611  ">" {
612   if (!A_surfxml_route_src) FAIL("Required attribute `src' not set for `route' element.");
613   if (!A_surfxml_route_dst) FAIL("Required attribute `dst' not set for `route' element.");
614   LEAVE; STag_surfxml_route();surfxml_pcdata = NULL; ENTER(S_surfxml_route);
615  }
616  "/>" {
617   if (!A_surfxml_route_src) FAIL("Required attribute `src' not set for `route' element.");
618   if (!A_surfxml_route_dst) FAIL("Required attribute `dst' not set for `route' element.");
619   LEAVE; STag_surfxml_route(); surfxml_pcdata = NULL; ETag_surfxml_route();
620   switch (YY_START) {
621    case S_surfxml_platform_description_2: case S_surfxml_platform_description_1: case S_surfxml_platform_description: SET(S_surfxml_platform_description_2); break;
622    case ROOT_surfxml_route: SET(EPILOG); break;
623    case S_surfxml_include: case S_surfxml_include_2: case S_surfxml_include_1: SET(S_surfxml_include_2); break;
624   }
625  }
626  .       FAIL("Unexpected character `%c' in attribute list of route element.", yytext[0]);
627  {Name} FAIL("Bad attribute `%s' in `route' element start tag.",yytext);
628  <<EOF>> FAIL("EOF in attribute list of `route' element.");
629 }
630
631 <S_surfxml_route,S_surfxml_route_2,E_surfxml_route>{
632  "</route"{s}">" {
633   LEAVE;
634   ETag_surfxml_route();
635   switch (YY_START) {
636    case S_surfxml_platform_description_2: case S_surfxml_platform_description_1: case S_surfxml_platform_description: SET(S_surfxml_platform_description_2); break;
637    case ROOT_surfxml_route: SET(EPILOG); break;
638    case S_surfxml_include: case S_surfxml_include_2: case S_surfxml_include_1: SET(S_surfxml_include_2); break;
639   }
640  }
641  "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</route>' expected.",yytext);
642  .       FAIL("Unexpected character `%c': `</route>' expected.",yytext[0]);
643  <<EOF>> FAIL("Premature EOF: `</route>' expected.");
644 }
645
646 <ROOT_surfxml_route_element,S_surfxml_route_1,S_surfxml_route,S_surfxml_route_2>"<route_element"{s} {
647   A_surfxml_route_element_name = NULL;
648   ENTER(AL_surfxml_route_element);
649   }
650
651 <AL_surfxml_route_element>{
652  "name"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_route_element_name);
653  "name"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_route_element_name);
654
655  ">" {
656   if (!A_surfxml_route_element_name) FAIL("Required attribute `name' not set for `route_element' element.");
657   LEAVE; STag_surfxml_route_element();surfxml_pcdata = NULL; ENTER(E_surfxml_route_element);
658  }
659  "/>" {
660   if (!A_surfxml_route_element_name) FAIL("Required attribute `name' not set for `route_element' element.");
661   LEAVE; STag_surfxml_route_element(); surfxml_pcdata = NULL; ETag_surfxml_route_element();
662   switch (YY_START) {
663    case S_surfxml_route_1: case S_surfxml_route: case S_surfxml_route_2: SET(S_surfxml_route_2); break;
664    case ROOT_surfxml_route_element: SET(EPILOG); break;
665   }
666  }
667  .       FAIL("Unexpected character `%c' in attribute list of route_element element.", yytext[0]);
668  {Name} FAIL("Bad attribute `%s' in `route_element' element start tag.",yytext);
669  <<EOF>> FAIL("EOF in attribute list of `route_element' element.");
670 }
671
672 <E_surfxml_route_element>{
673  "</route_element"{s}">" {
674   LEAVE;
675   ETag_surfxml_route_element();
676   switch (YY_START) {
677    case S_surfxml_route_1: case S_surfxml_route: case S_surfxml_route_2: SET(S_surfxml_route_2); break;
678    case ROOT_surfxml_route_element: SET(EPILOG); break;
679   }
680  }
681  "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</route_element>' expected.",yytext);
682  .       FAIL("Unexpected character `%c': `</route_element>' expected.",yytext[0]);
683  <<EOF>> FAIL("Premature EOF: `</route_element>' expected.");
684 }
685
686 <ROOT_surfxml_process,S_surfxml_platform_description_2,S_surfxml_include,S_surfxml_include_2,S_surfxml_platform_description_1,S_surfxml_include_1,S_surfxml_platform_description>"<process"{s} {
687   A_surfxml_process_host = NULL;
688   A_surfxml_process_function = NULL;
689   A_surfxml_process_start_time = "-1.0";
690   A_surfxml_process_kill_time = "-1.0";
691   ENTER(AL_surfxml_process);
692   }
693
694 <AL_surfxml_process>{
695  "host"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_process_host);
696  "host"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_process_host);
697
698  "function"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_process_function);
699  "function"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_process_function);
700
701  "start_time"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_process_start_time);
702  "start_time"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_process_start_time);
703
704  "kill_time"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_process_kill_time);
705  "kill_time"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_process_kill_time);
706
707  ">" {
708   if (!A_surfxml_process_host) FAIL("Required attribute `host' not set for `process' element.");
709   if (!A_surfxml_process_function) FAIL("Required attribute `function' not set for `process' element.");
710   LEAVE; STag_surfxml_process();surfxml_pcdata = NULL; ENTER(S_surfxml_process);
711  }
712  "/>" {
713   if (!A_surfxml_process_host) FAIL("Required attribute `host' not set for `process' element.");
714   if (!A_surfxml_process_function) FAIL("Required attribute `function' not set for `process' element.");
715   LEAVE; STag_surfxml_process(); surfxml_pcdata = NULL; ETag_surfxml_process();
716   switch (YY_START) {
717    case S_surfxml_platform_description_2: case S_surfxml_platform_description_1: case S_surfxml_platform_description: SET(S_surfxml_platform_description_2); break;
718    case ROOT_surfxml_process: SET(EPILOG); break;
719    case S_surfxml_include: case S_surfxml_include_2: case S_surfxml_include_1: SET(S_surfxml_include_2); break;
720   }
721  }
722  .       FAIL("Unexpected character `%c' in attribute list of process element.", yytext[0]);
723  {Name} FAIL("Bad attribute `%s' in `process' element start tag.",yytext);
724  <<EOF>> FAIL("EOF in attribute list of `process' element.");
725 }
726
727 <S_surfxml_process,E_surfxml_process,S_surfxml_process_2>{
728  "</process"{s}">" {
729   LEAVE;
730   ETag_surfxml_process();
731   switch (YY_START) {
732    case S_surfxml_platform_description_2: case S_surfxml_platform_description_1: case S_surfxml_platform_description: SET(S_surfxml_platform_description_2); break;
733    case ROOT_surfxml_process: SET(EPILOG); break;
734    case S_surfxml_include: case S_surfxml_include_2: case S_surfxml_include_1: SET(S_surfxml_include_2); break;
735   }
736  }
737  "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</process>' expected.",yytext);
738  .       FAIL("Unexpected character `%c': `</process>' expected.",yytext[0]);
739  <<EOF>> FAIL("Premature EOF: `</process>' expected.");
740 }
741
742 <ROOT_surfxml_argument,S_surfxml_process_1,S_surfxml_process,S_surfxml_process_2>"<argument"{s} {
743   A_surfxml_argument_value = NULL;
744   ENTER(AL_surfxml_argument);
745   }
746
747 <AL_surfxml_argument>{
748  "value"{Eq}\' ENTER(VALUE1); BUFFERSET(A_surfxml_argument_value);
749  "value"{Eq}\" ENTER(VALUE2); BUFFERSET(A_surfxml_argument_value);
750
751  ">" {
752   if (!A_surfxml_argument_value) FAIL("Required attribute `value' not set for `argument' element.");
753   LEAVE; STag_surfxml_argument();surfxml_pcdata = NULL; ENTER(E_surfxml_argument);
754  }
755  "/>" {
756   if (!A_surfxml_argument_value) FAIL("Required attribute `value' not set for `argument' element.");
757   LEAVE; STag_surfxml_argument(); surfxml_pcdata = NULL; ETag_surfxml_argument();
758   switch (YY_START) {
759    case S_surfxml_process_1: case S_surfxml_process: case S_surfxml_process_2: SET(S_surfxml_process_2); break;
760    case ROOT_surfxml_argument: SET(EPILOG); break;
761   }
762  }
763  .       FAIL("Unexpected character `%c' in attribute list of argument element.", yytext[0]);
764  {Name} FAIL("Bad attribute `%s' in `argument' element start tag.",yytext);
765  <<EOF>> FAIL("EOF in attribute list of `argument' element.");
766 }
767
768 <E_surfxml_argument>{
769  "</argument"{s}">" {
770   LEAVE;
771   ETag_surfxml_argument();
772   switch (YY_START) {
773    case S_surfxml_process_1: case S_surfxml_process: case S_surfxml_process_2: SET(S_surfxml_process_2); break;
774    case ROOT_surfxml_argument: SET(EPILOG); break;
775   }
776  }
777  "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</argument>' expected.",yytext);
778  .       FAIL("Unexpected character `%c': `</argument>' expected.",yytext[0]);
779  <<EOF>> FAIL("Premature EOF: `</argument>' expected.");
780 }
781
782  /* EPILOG: after the root element. */
783
784 <EPILOG>{
785  . {SET(PROLOG); yyless(0); CLEANUP; return -1;}
786  <<EOF>>        SUCCEED;
787 }
788
789  /* CHARACTER DATA. */
790
791 <IMPOSSIBLE,VALUE1,VALUE2>{
792  /* Non-defined standard entities... */
793 "&amp;"  BUFFERPUTC('&');
794 "&lt;"   BUFFERPUTC('<');
795 "&gt;"   BUFFERPUTC('>');
796 "&apos;" BUFFERPUTC('\'');
797 "&quot;" BUFFERPUTC('"');
798
799  /* Character entities. */
800  "&#"[[:digit:]]+";"    BUFFERPUTC((unsigned char)atoi(yytext+2));
801  "&#x"[[:xdigit:]]+";"  BUFFERPUTC((unsigned char)strtol(yytext+3,NULL,16));
802 }
803
804 <IMPOSSIBLE,VALUE1,VALUE2,CDATA>{
805  "\n"           |
806  "\r"           |
807  "\r\n"         |
808  "\n\r"         BUFFERPUTC('\n');
809 }
810
811 <IMPOSSIBLE>{
812  "<![CDATA["    ENTER(CDATA);
813  "]""]>"                FAIL("Unexpected `]""]>' in character data.");
814 }
815
816 <VALUE1>{
817  \'             BUFFERDONE; LEAVE;
818  <<EOF>>        FAIL("EOF in literal (\"'\" expected).");
819 }
820
821 <VALUE2>{
822  \"             BUFFERDONE; LEAVE;
823  <<EOF>>        FAIL("EOF in literal (`\"' expected).");
824 }
825
826 <IMPOSSIBLE,VALUE1,VALUE2>{
827  [^<&]          BUFFERPUTC(yytext[0]);
828  [<&]           FAIL("Spurious `%c' in character data.",yytext[0]);
829 }
830
831 <CDATA>{
832  "]""]>"                LEAVE;
833  /* "]""]"              BUFFERPUTC(yytext[0]); BUFFERPUTC(yytext[1]); */
834  .              BUFFERPUTC(yytext[0]);
835  <<EOF>>        FAIL("EOF in CDATA section.");
836 }
837
838  /* Impossible rules to avoid warnings from flex(1). */
839  /* Ideally, this should be replaced by code in flexml.pl that
840     generates just the states not covered by other rules. */
841 <*>{
842  .|[\n] FAIL("Syntax error on character `%c'.", yytext[0]);
843 }
844
845 %%
846
847 /* Element context stack lookup. */
848 int surfxml_element_context(int i)
849 {
850   return (0<i && i<yy_start_stack_depth
851           ? yy_start_stack[yy_start_stack_ptr - i]
852           : 0);
853 }
854
855 #ifdef FLEX_DEBUG
856 void print_yy_stack(char* fmt, ...)
857 {
858   int i = 0; va_list ap; va_start(ap, fmt);
859   vfprintf(stderr, fmt, ap);
860   for (i=1; i<yy_start_stack_ptr; i++)
861     fprintf(stderr, "%s/", surfxml_statenames[yy_start_stack[i] ]);
862   fprintf(stderr,"%s\n", surfxml_statenames[YY_START]);
863   va_end(ap);
864 }
865
866 static void debug_enter(int state, const char* statename) {
867   yy_push_state(state);
868   if (yy_flex_debug) print_yy_stack("--ENTER(%s) : ",statename);
869 }
870
871 static void debug_leave(void) {
872   if (yy_flex_debug) print_yy_stack("--LEAVE : ");
873   yy_pop_state();
874 }
875
876 static void debug_set(int state, const char* statename) {
877   BEGIN(state);
878   if (yy_flex_debug) print_yy_stack("--SET(%s) : ",statename);
879 }
880 #endif
881
882 enum {flexml_max_err_msg_size = 512};
883
884 static char flexml_err_msg[flexml_max_err_msg_size];
885 const char * surfxml_parse_err_msg()
886 {
887     return flexml_err_msg;
888 }
889
890 static void reset_surfxml_parse_err_msg()
891 {
892     flexml_err_msg[0] = '\0';
893 }
894
895
896 static void cleanup(void)
897 {
898     if (surfxml_statenames) {
899         free(surfxml_statenames);
900         surfxml_statenames = NULL;
901     }
902 }
903
904
905 static int fail(const char* fmt, ...)
906 {
907     int chars_left, used;
908     va_list ap; va_start(ap, fmt);
909 #ifdef FLEXML_yylineno
910     used = sprintf(flexml_err_msg,
911                    "Invalid XML (XML input line %d, state %d): ",
912                    yylineno, YY_START);
913 #else
914     used = sprintf(flexml_err_msg,
915                    "Invalid XML (state %d): ",
916                    YY_START);
917 #endif
918     chars_left = flexml_max_err_msg_size - used - 1;
919     vsnprintf(flexml_err_msg + used, chars_left, fmt, ap);
920     va_end(ap);
921
922 #ifndef FLEXML_quiet_parser
923     /* print directly to sdterr */
924     fprintf(stderr, "%s\n", flexml_err_msg);
925     flexml_err_msg[0] = '\0';
926 #endif
927
928     cleanup();
929
930     return 1;
931 }