Logo AND Algorithmique Numérique Distribuée

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