Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Adding a <route> tag.
[simgrid.git] / src / surf / surfxml.l
1 /* Validating XML processor for surf/surfxml.dtd.
2  * Generated 2007/05/16 11:14: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.61 2006/09/13 16:34:33 wdowling 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.38 2006/09/12 18:05:45 wdowling Exp $";
53 const char rcs_surfxml_flexml[] =
54  "$" "Id: flexml.pl,v 1.61 2006/09/13 16:34:33 wdowling 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 #ifndef FLEXML_INDEXSTACKSIZE
65 #define FLEXML_INDEXSTACKSIZE 1000
66 #endif
67
68 /* Generated definitions. */
69 #define FLEXML_yylineno
70 #ifndef FLEXML_BUFFERSTACKSIZE
71 #define FLEXML_BUFFERSTACKSIZE 1000000
72 #endif
73 #define FLEXML_NEED_BUFFERLIT
74
75 /* XML processor api. */
76 /* FleXML-provided data. */
77 int surfxml_pcdata_ix;
78 extern char *surfxml_bufferstack;
79 #define surfxml_pcdata (surfxml_bufferstack + surfxml_pcdata_ix)
80 AT_surfxml_network_link_bandwidth AX_surfxml_network_link_bandwidth;
81 #define A_surfxml_network_link_bandwidth (surfxml_bufferstack + AX_surfxml_network_link_bandwidth)
82 AT_surfxml_router_name AX_surfxml_router_name;
83 #define A_surfxml_router_name (surfxml_bufferstack + AX_surfxml_router_name)
84 AT_surfxml_process_host AX_surfxml_process_host;
85 #define A_surfxml_process_host (surfxml_bufferstack + AX_surfxml_process_host)
86 AT_surfxml_network_link_latency_file AX_surfxml_network_link_latency_file;
87 #define A_surfxml_network_link_latency_file (surfxml_bufferstack + AX_surfxml_network_link_latency_file)
88 AT_surfxml_route_impact_on_dst_with_other_send AX_surfxml_route_impact_on_dst_with_other_send;
89 #define A_surfxml_route_impact_on_dst_with_other_send (surfxml_bufferstack + AX_surfxml_route_impact_on_dst_with_other_send)
90 AT_surfxml_cpu_interference_send_recv AX_surfxml_cpu_interference_send_recv;
91 #define A_surfxml_cpu_interference_send_recv (surfxml_bufferstack + AX_surfxml_cpu_interference_send_recv)
92 AT_surfxml_route_impact_on_dst AX_surfxml_route_impact_on_dst;
93 #define A_surfxml_route_impact_on_dst (surfxml_bufferstack + AX_surfxml_route_impact_on_dst)
94 AT_surfxml_platform_description_version AX_surfxml_platform_description_version;
95 #define A_surfxml_platform_description_version (surfxml_bufferstack + AX_surfxml_platform_description_version)
96 AT_surfxml_route_impact_on_src_with_other_recv AX_surfxml_route_impact_on_src_with_other_recv;
97 #define A_surfxml_route_impact_on_src_with_other_recv (surfxml_bufferstack + AX_surfxml_route_impact_on_src_with_other_recv)
98 AT_surfxml_route_element_name AX_surfxml_route_element_name;
99 #define A_surfxml_route_element_name (surfxml_bufferstack + AX_surfxml_route_element_name)
100 AT_surfxml_process_start_time AX_surfxml_process_start_time;
101 #define A_surfxml_process_start_time (surfxml_bufferstack + AX_surfxml_process_start_time)
102 AT_surfxml_process_function AX_surfxml_process_function;
103 #define A_surfxml_process_function (surfxml_bufferstack + AX_surfxml_process_function)
104 AT_surfxml_cpu_state AX_surfxml_cpu_state;
105 #define A_surfxml_cpu_state AX_surfxml_cpu_state
106 AT_surfxml_cpu_interference_send AX_surfxml_cpu_interference_send;
107 #define A_surfxml_cpu_interference_send (surfxml_bufferstack + AX_surfxml_cpu_interference_send)
108 AT_surfxml_network_link_bandwidth_file AX_surfxml_network_link_bandwidth_file;
109 #define A_surfxml_network_link_bandwidth_file (surfxml_bufferstack + AX_surfxml_network_link_bandwidth_file)
110 AT_surfxml_cpu_name AX_surfxml_cpu_name;
111 #define A_surfxml_cpu_name (surfxml_bufferstack + AX_surfxml_cpu_name)
112 AT_surfxml_process_kill_time AX_surfxml_process_kill_time;
113 #define A_surfxml_process_kill_time (surfxml_bufferstack + AX_surfxml_process_kill_time)
114 AT_surfxml_network_link_state AX_surfxml_network_link_state;
115 #define A_surfxml_network_link_state AX_surfxml_network_link_state
116 AT_surfxml_cpu_availability_file AX_surfxml_cpu_availability_file;
117 #define A_surfxml_cpu_availability_file (surfxml_bufferstack + AX_surfxml_cpu_availability_file)
118 AT_surfxml_argument_value AX_surfxml_argument_value;
119 #define A_surfxml_argument_value (surfxml_bufferstack + AX_surfxml_argument_value)
120 AT_surfxml_route_src AX_surfxml_route_src;
121 #define A_surfxml_route_src (surfxml_bufferstack + AX_surfxml_route_src)
122 AT_surfxml_route_impact_on_src AX_surfxml_route_impact_on_src;
123 #define A_surfxml_route_impact_on_src (surfxml_bufferstack + AX_surfxml_route_impact_on_src)
124 AT_surfxml_cpu_max_outgoing_rate AX_surfxml_cpu_max_outgoing_rate;
125 #define A_surfxml_cpu_max_outgoing_rate (surfxml_bufferstack + AX_surfxml_cpu_max_outgoing_rate)
126 AT_surfxml_cpu_availability AX_surfxml_cpu_availability;
127 #define A_surfxml_cpu_availability (surfxml_bufferstack + AX_surfxml_cpu_availability)
128 AT_surfxml_cpu_interference_recv AX_surfxml_cpu_interference_recv;
129 #define A_surfxml_cpu_interference_recv (surfxml_bufferstack + AX_surfxml_cpu_interference_recv)
130 AT_surfxml_network_link_name AX_surfxml_network_link_name;
131 #define A_surfxml_network_link_name (surfxml_bufferstack + AX_surfxml_network_link_name)
132 AT_surfxml_cpu_power AX_surfxml_cpu_power;
133 #define A_surfxml_cpu_power (surfxml_bufferstack + AX_surfxml_cpu_power)
134 AT_surfxml_include_file AX_surfxml_include_file;
135 #define A_surfxml_include_file (surfxml_bufferstack + AX_surfxml_include_file)
136 AT_surfxml_network_link_sharing_policy AX_surfxml_network_link_sharing_policy;
137 #define A_surfxml_network_link_sharing_policy AX_surfxml_network_link_sharing_policy
138 AT_surfxml_route_dst AX_surfxml_route_dst;
139 #define A_surfxml_route_dst (surfxml_bufferstack + AX_surfxml_route_dst)
140 AT_surfxml_network_link_latency AX_surfxml_network_link_latency;
141 #define A_surfxml_network_link_latency (surfxml_bufferstack + AX_surfxml_network_link_latency)
142 AT_surfxml_cpu_state_file AX_surfxml_cpu_state_file;
143 #define A_surfxml_cpu_state_file (surfxml_bufferstack + AX_surfxml_cpu_state_file)
144 AT_surfxml_network_link_state_file AX_surfxml_network_link_state_file;
145 #define A_surfxml_network_link_state_file (surfxml_bufferstack + AX_surfxml_network_link_state_file)
146
147 /* XML state. */
148 #ifdef FLEX_DEBUG
149 # define ENTER(state)   debug_enter(state,#state)
150 # define LEAVE          debug_leave()
151 # define SET(state)     debug_set(state,#state)
152   static void debug_enter(int, const char*);
153   static void debug_leave(void);
154   static void debug_set(int, const char*);
155 #else
156 # define ENTER(state)   (yy_push_state(state))
157 # define LEAVE          (yy_pop_state())
158 # define SET(state)     BEGIN(state)
159 #endif
160
161 /* Generic actions. */
162 #define SKIP    /*skip*/
163 #define SUCCEED        CLEANUP; return 0
164
165 #define FAIL    return fail
166 static int fail(const char*, ...);
167
168 enum {flexml_max_err_msg_size = 512};
169 static char flexml_err_msg[flexml_max_err_msg_size];
170 const char * surfxml_parse_err_msg()
171 {
172     return flexml_err_msg;
173 }
174 static void reset_surfxml_parse_err_msg()
175 {
176     flexml_err_msg[0] = '\0';
177 }
178
179 /* Cleanup */
180 static void cleanup(void);
181 #define CLEANUP  cleanup()
182
183 /* Text buffer stack handling. */
184 char *surfxml_bufferstack = NULL;
185 static int blimit = FLEXML_BUFFERSTACKSIZE;
186 static int bnext = 1;
187
188 static int *indexstack = NULL;
189 static int ilimit = FLEXML_INDEXSTACKSIZE;
190 static int inext = 1;
191
192 #define BUFFERSET(P)  (P = bnext)
193 #define BUFFERPUTC(C) (ck_blimit(), surfxml_bufferstack[bnext++] = (C))
194 #define BUFFERDONE    (BUFFERPUTC('\0'))
195
196 #define BUFFERLITERAL(C, P) surfxml_bufferliteral(C, &(P), yytext)
197
198 /* after this is called, there are at least 2 slots left in the stack */
199 static int ck_blimit()
200 {
201      if (bnext >= blimit) {
202          blimit += FLEXML_BUFFERSTACKSIZE + 2;
203          {
204              char *temp = (char *) realloc(surfxml_bufferstack, blimit);
205              assert(temp);
206              surfxml_bufferstack = temp;
207          }
208      }
209      return 0;
210 }
211
212 /* after this is called, there are at least 2 slots left in the stack */
213 static int ck_ilimit()
214 {
215      if (inext >= ilimit) {
216          ilimit += FLEXML_INDEXSTACKSIZE + 2;
217          {
218              int *temp = (int *) realloc(indexstack, ilimit);
219              assert(temp);
220              indexstack = temp;
221          }
222      }
223      return 0;
224 }
225
226 #ifdef FLEXML_NEED_BUFFERLIT
227 static void surfxml_bufferliteral(char c, int* pp, const char* text)
228 {
229   const char *s = (c ? strchr(text,c) : text-1), *e = strrchr(text,c);
230   assert(s <= e); BUFFERSET(*pp);
231   while (++s<e) {
232     if (isspace(*s) && c) { BUFFERPUTC(' '); while (isspace(*s)) ++s; }
233     else BUFFERPUTC(*s);
234   }
235   BUFFERDONE;
236 }
237 #endif
238
239 static void pushbuffer(int p)
240 {
241     ck_ilimit();
242     indexstack[inext++] = p;
243     indexstack[inext++] = bnext;    
244 }
245
246 static int popbuffer(void)
247 {
248     assert(inext >= 2);
249     bnext = indexstack[--inext];
250     return indexstack[--inext];
251 }
252
253 /* General internal entities are `unput' back onto the input stream... */
254 #define ENTITYTEXT(T) \
255   { char *s = (T), *e = s+strlen(s);\
256     while (--e >= s) { unput(*e); }}
257
258
259 %}
260
261 /* Flex standard options. */
262 %option stack
263 %option noyy_top_state
264 %option noinput
265 %option noreject
266 %option noyymore
267 %option noyywrap
268
269 /* Flex user-requested options. */
270 %option yylineno
271 %option nounput
272
273 /* XML character classes (currently restricted to ASCII). */
274
275 /* "Common syntactic structures." */
276 S               [ \t\n\r\f]+
277 s               [ \t\n\r\f]*
278
279 /* "Names and Tokens." */
280 NameChar        [A-Za-z0-9.:_-]
281 Name            [A-Za-z_:]{NameChar}*
282 Names           {Name}({S}{Name})*
283 Nmtoken         ({NameChar})+
284 Nmtokens        {Nmtoken}({S}{Nmtoken})*
285
286 /* Miscellaneous. */
287 VersionNum      [a-zA-Z0-9_.:-]+
288 Eq              {s}"="{s}
289 Literal         \'[^'']*\'|\"[^""]*\"
290
291 /* Parser states (flex `exclusive start conditions'):
292  *
293  * PROLOG       the XML prolog of the document before <?xml...>
294  * DOCTYPE      the XML prolog of the document after <?xml...>
295  * EPILOG       after the root element
296  * INCOMMENT    inside an XML comment <!--....-->
297  * INPI         inside an XML PI <?...?>
298  * VALUE1       inside a '...'-delimited literal
299  * VALUE2       inside a "..."-delimited literal
300  * CDATA        inside a <![CDATA[...] ]> section.
301  * ROOT_<tag>   expect root element <tag>
302  * AL_<tag>     inside the attribute list for <tag>
303  * IN_<tag>     inside a <tag> with element contents (ready for end tag)
304  * IMPOSSIBLE   dummy to permit disabling rules; must be last
305  */
306 %x PROLOG DOCTYPE EPILOG INCOMMENT INPI VALUE1 VALUE2 CDATA
307 %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
308 %x ROOT_surfxml_include AL_surfxml_include S_surfxml_include S_surfxml_include_1 S_surfxml_include_2 E_surfxml_include
309 %x ROOT_surfxml_cpu AL_surfxml_cpu E_surfxml_cpu
310 %x ROOT_surfxml_router AL_surfxml_router E_surfxml_router
311 %x ROOT_surfxml_network_link AL_surfxml_network_link E_surfxml_network_link
312 %x ROOT_surfxml_route AL_surfxml_route S_surfxml_route S_surfxml_route_1 S_surfxml_route_2 E_surfxml_route
313 %x ROOT_surfxml_route_element AL_surfxml_route_element E_surfxml_route_element
314 %x ROOT_surfxml_process AL_surfxml_process S_surfxml_process S_surfxml_process_1 S_surfxml_process_2 E_surfxml_process
315 %x ROOT_surfxml_argument AL_surfxml_argument E_surfxml_argument
316 %x IMPOSSIBLE
317
318 %{
319 /* State names. */
320 const char* *surfxml_statenames=NULL;
321 %}
322
323 %%
324
325  /* Bypass Flex's default INITIAL state and begin by parsing the XML prolog. */
326  SET(PROLOG);
327  reset_surfxml_parse_err_msg();
328  surfxml_bufferstack = (char *) malloc(FLEXML_BUFFERSTACKSIZE);
329  assert(surfxml_bufferstack);
330  #ifdef FLEX_DEBUG
331  {
332      int i;
333      for (i = 0; i < blimit; i++) {
334          surfxml_bufferstack[i] = '\377';
335      }
336  }
337  #endif
338  surfxml_bufferstack[0] = '\0';
339  indexstack = (int *) malloc(FLEXML_INDEXSTACKSIZE * sizeof(int));
340  assert(indexstack);
341  indexstack[0] = 0;
342
343   /* FleXML_init */
344   bnext = inext = 1;
345   surfxml_bufferliteral('\0', &bnext, "0.0");
346   surfxml_bufferliteral('\0', &bnext, "1.0");
347   surfxml_bufferliteral('\0', &bnext, "1.0");
348   surfxml_bufferliteral('\0', &bnext, "1.0");
349   surfxml_bufferliteral('\0', &bnext, "1.0");
350   surfxml_bufferliteral('\0', &bnext, "-1.0");
351   surfxml_bufferliteral('\0', &bnext, "0.0");
352   surfxml_bufferliteral('\0', &bnext, "0.0");
353   surfxml_bufferliteral('\0', &bnext, "0.0");
354   surfxml_bufferliteral('\0', &bnext, "0.0");
355   surfxml_bufferliteral('\0', &bnext, "0.0");
356   surfxml_bufferliteral('\0', &bnext, "-1.0");
357   surfxml_bufferliteral('\0', &bnext, "-1.0");
358   if(!surfxml_statenames) {surfxml_statenames= (const char **)calloc(IMPOSSIBLE,sizeof(char*));
359   surfxml_statenames[PROLOG] = NULL;
360   surfxml_statenames[DOCTYPE] = NULL;
361   surfxml_statenames[EPILOG] = NULL;
362   surfxml_statenames[INCOMMENT] = NULL;
363   surfxml_statenames[INPI] = NULL;
364   surfxml_statenames[VALUE1] = NULL;
365   surfxml_statenames[VALUE2] = NULL;
366   surfxml_statenames[CDATA] = NULL;
367   surfxml_statenames[ROOT_surfxml_platform_description] = NULL;
368   surfxml_statenames[AL_surfxml_platform_description] = NULL;
369   surfxml_statenames[S_surfxml_platform_description] = "platform_description";
370   surfxml_statenames[S_surfxml_platform_description_1] = "platform_description";
371   surfxml_statenames[S_surfxml_platform_description_2] = "platform_description";
372   surfxml_statenames[E_surfxml_platform_description] = "platform_description";
373   surfxml_statenames[ROOT_surfxml_include] = NULL;
374   surfxml_statenames[AL_surfxml_include] = NULL;
375   surfxml_statenames[S_surfxml_include] = "include";
376   surfxml_statenames[S_surfxml_include_1] = "include";
377   surfxml_statenames[S_surfxml_include_2] = "include";
378   surfxml_statenames[E_surfxml_include] = "include";
379   surfxml_statenames[ROOT_surfxml_cpu] = NULL;
380   surfxml_statenames[AL_surfxml_cpu] = NULL;
381   surfxml_statenames[E_surfxml_cpu] = "cpu";
382   surfxml_statenames[ROOT_surfxml_router] = NULL;
383   surfxml_statenames[AL_surfxml_router] = NULL;
384   surfxml_statenames[E_surfxml_router] = "router";
385   surfxml_statenames[ROOT_surfxml_network_link] = NULL;
386   surfxml_statenames[AL_surfxml_network_link] = NULL;
387   surfxml_statenames[E_surfxml_network_link] = "network_link";
388   surfxml_statenames[ROOT_surfxml_route] = NULL;
389   surfxml_statenames[AL_surfxml_route] = NULL;
390   surfxml_statenames[S_surfxml_route] = "route";
391   surfxml_statenames[S_surfxml_route_1] = "route";
392   surfxml_statenames[S_surfxml_route_2] = "route";
393   surfxml_statenames[E_surfxml_route] = "route";
394   surfxml_statenames[ROOT_surfxml_route_element] = NULL;
395   surfxml_statenames[AL_surfxml_route_element] = NULL;
396   surfxml_statenames[E_surfxml_route_element] = "route_element";
397   surfxml_statenames[ROOT_surfxml_process] = NULL;
398   surfxml_statenames[AL_surfxml_process] = NULL;
399   surfxml_statenames[S_surfxml_process] = "process";
400   surfxml_statenames[S_surfxml_process_1] = "process";
401   surfxml_statenames[S_surfxml_process_2] = "process";
402   surfxml_statenames[E_surfxml_process] = "process";
403   surfxml_statenames[ROOT_surfxml_argument] = NULL;
404   surfxml_statenames[AL_surfxml_argument] = NULL;
405   surfxml_statenames[E_surfxml_argument] = "argument";
406   }
407
408  /* COMMENTS and PIs: handled uniformly for efficiency. */
409
410 <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_router,AL_surfxml_router,E_surfxml_router,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>{
411  "<!--" ENTER(INCOMMENT);
412  "<?" ENTER(INPI);
413 }
414 <INCOMMENT>{
415  "-->"          LEAVE;
416  "--"           |
417  .              |
418  \n             SKIP;
419  <<EOF>>        FAIL("EOF in comment.");
420 }
421 <INPI>{
422  "?>"           LEAVE;
423  .              |
424  \n             SKIP;
425  <<EOF>>        FAIL("EOF in PI (processing instruction).");
426 }
427
428  /* SPACES: skipped uniformly */
429
430 <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_router,AL_surfxml_router,E_surfxml_router,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;
431
432  /* PROLOG: determine root element and process it. */
433
434 <PROLOG>{
435  "<?xml"({S}version{Eq}(\'{VersionNum}\'|\"{VersionNum}\"))?({S}encoding{Eq}(\'[^']*\'|\"[^"]*\"))?"?>" SET(DOCTYPE); 
436  "<?xml"[^>]*">" FAIL("Bad declaration %s.",yytext);
437 }
438
439 <PROLOG,DOCTYPE>{
440  "<!DOCTYPE"{S}"cpu"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_surfxml_cpu);
441  "<!DOCTYPE"{S}"include"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_surfxml_include);
442  "<!DOCTYPE"{S}"route"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_surfxml_route);
443  "<!DOCTYPE"{S}"network_link"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_surfxml_network_link);
444  "<!DOCTYPE"{S}"process"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_surfxml_process);
445  "<!DOCTYPE"{S}"router"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_surfxml_router);
446  "<!DOCTYPE"{S}"argument"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_surfxml_argument);
447  "<!DOCTYPE"{S}"route_element"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_surfxml_route_element);
448  "<!DOCTYPE"{S}"platform_description"{S}SYSTEM{S}("'surfxml.dtd'"|"\"surfxml.dtd\""){s}">" SET(ROOT_surfxml_platform_description);
449  "<!"[^>-][^>]*">" FAIL("Bad declaration %s.",yytext);
450  .              FAIL("Unexpected character `%c' in prolog.", yytext[0]);
451  <<EOF>>        FAIL("EOF in prolog.");
452 }
453
454  /* RULES DERIVED FROM DTD. */
455
456  /* <!-- Small DTD for SURF based tools. -->  */
457
458 <ROOT_surfxml_platform_description>"<platform_description"{s} {
459   AX_surfxml_platform_description_version = 1;
460   ENTER(AL_surfxml_platform_description); pushbuffer(0);
461   }
462
463 <AL_surfxml_platform_description>{
464  "version"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_surfxml_platform_description_version);
465  "version"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_surfxml_platform_description_version);
466
467  ">" {
468   LEAVE; STag_surfxml_platform_description();surfxml_pcdata_ix = 0; ENTER(S_surfxml_platform_description);
469  }
470  "/>" {
471   LEAVE; STag_surfxml_platform_description(); surfxml_pcdata_ix = 0; ETag_surfxml_platform_description(); popbuffer(); /* attribute */
472   switch (YY_START) {
473    case ROOT_surfxml_platform_description: SET(EPILOG); break;
474   }
475  }
476  .       FAIL("Unexpected character `%c' in attribute list of platform_description element.", yytext[0]);
477  {Name} FAIL("Bad attribute `%s' in `platform_description' element start tag.",yytext);
478  <<EOF>> FAIL("EOF in attribute list of `platform_description' element.");
479 }
480
481 <E_surfxml_platform_description,S_surfxml_platform_description_2,S_surfxml_platform_description>{
482  "</platform_description"{s}">" {
483   LEAVE;
484   ETag_surfxml_platform_description();
485   popbuffer(); /* attribute */
486   switch (YY_START) {
487    case ROOT_surfxml_platform_description: SET(EPILOG); break;
488   }
489  }
490  "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</platform_description>' expected.",yytext);
491  .       FAIL("Unexpected character `%c': `</platform_description>' expected.",yytext[0]);
492  <<EOF>> FAIL("Premature EOF: `</platform_description>' expected.");
493 }
494
495 <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} {
496   AX_surfxml_include_file = 0;
497   ENTER(AL_surfxml_include); pushbuffer(0);
498   }
499
500 <AL_surfxml_include>{
501  "file"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_surfxml_include_file);
502  "file"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_surfxml_include_file);
503
504  ">" {
505   if (!AX_surfxml_include_file) FAIL("Required attribute `file' not set for `include' element.");
506   LEAVE; STag_surfxml_include();surfxml_pcdata_ix = 0; ENTER(S_surfxml_include);
507  }
508  "/>" {
509   if (!AX_surfxml_include_file) FAIL("Required attribute `file' not set for `include' element.");
510   LEAVE; STag_surfxml_include(); surfxml_pcdata_ix = 0; ETag_surfxml_include(); popbuffer(); /* attribute */
511   switch (YY_START) {
512    case S_surfxml_platform_description_2: case S_surfxml_platform_description_1: case S_surfxml_platform_description: SET(S_surfxml_platform_description_2); break;
513    case ROOT_surfxml_include: SET(EPILOG); break;
514    case S_surfxml_include: case S_surfxml_include_2: case S_surfxml_include_1: SET(S_surfxml_include_2); break;
515   }
516  }
517  .       FAIL("Unexpected character `%c' in attribute list of include element.", yytext[0]);
518  {Name} FAIL("Bad attribute `%s' in `include' element start tag.",yytext);
519  <<EOF>> FAIL("EOF in attribute list of `include' element.");
520 }
521
522 <E_surfxml_include,S_surfxml_include,S_surfxml_include_2>{
523  "</include"{s}">" {
524   LEAVE;
525   ETag_surfxml_include();
526   popbuffer(); /* attribute */
527   switch (YY_START) {
528    case S_surfxml_platform_description_2: case S_surfxml_platform_description_1: case S_surfxml_platform_description: SET(S_surfxml_platform_description_2); break;
529    case ROOT_surfxml_include: SET(EPILOG); break;
530    case S_surfxml_include: case S_surfxml_include_2: case S_surfxml_include_1: SET(S_surfxml_include_2); break;
531   }
532  }
533  "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</include>' expected.",yytext);
534  .       FAIL("Unexpected character `%c': `</include>' expected.",yytext[0]);
535  <<EOF>> FAIL("Premature EOF: `</include>' expected.");
536 }
537
538 <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} {
539   AX_surfxml_cpu_name = 0;
540   AX_surfxml_cpu_power = 0;
541   AX_surfxml_cpu_availability = 5;
542   AX_surfxml_cpu_availability_file = 0;
543   AX_surfxml_cpu_state = A_surfxml_cpu_state_ON;
544   AX_surfxml_cpu_state_file = 0;
545   AX_surfxml_cpu_interference_send = 9;
546   AX_surfxml_cpu_interference_recv = 13;
547   AX_surfxml_cpu_interference_send_recv = 17;
548   AX_surfxml_cpu_max_outgoing_rate = 21;
549   ENTER(AL_surfxml_cpu); pushbuffer(0);
550   }
551
552 <AL_surfxml_cpu>{
553  "name"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_surfxml_cpu_name);
554  "name"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_surfxml_cpu_name);
555
556  "power"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_surfxml_cpu_power);
557  "power"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_surfxml_cpu_power);
558
559  "availability"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_surfxml_cpu_availability);
560  "availability"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_surfxml_cpu_availability);
561
562  "availability_file"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_surfxml_cpu_availability_file);
563  "availability_file"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_surfxml_cpu_availability_file);
564
565  "state"{Eq}"'ON'" |
566  "state"{Eq}"\"ON\"" A_surfxml_cpu_state = A_surfxml_cpu_state_ON;
567  "state"{Eq}"'OFF'" |
568  "state"{Eq}"\"OFF\"" A_surfxml_cpu_state = A_surfxml_cpu_state_OFF;
569
570  "state_file"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_surfxml_cpu_state_file);
571  "state_file"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_surfxml_cpu_state_file);
572
573  "interference_send"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_surfxml_cpu_interference_send);
574  "interference_send"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_surfxml_cpu_interference_send);
575
576  "interference_recv"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_surfxml_cpu_interference_recv);
577  "interference_recv"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_surfxml_cpu_interference_recv);
578
579  "interference_send_recv"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_surfxml_cpu_interference_send_recv);
580  "interference_send_recv"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_surfxml_cpu_interference_send_recv);
581
582  "max_outgoing_rate"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_surfxml_cpu_max_outgoing_rate);
583  "max_outgoing_rate"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_surfxml_cpu_max_outgoing_rate);
584
585  ">" {
586   if (!AX_surfxml_cpu_name) FAIL("Required attribute `name' not set for `cpu' element.");
587   if (!AX_surfxml_cpu_power) FAIL("Required attribute `power' not set for `cpu' element.");
588   LEAVE; STag_surfxml_cpu();surfxml_pcdata_ix = 0; ENTER(E_surfxml_cpu);
589  }
590  "/>" {
591   if (!AX_surfxml_cpu_name) FAIL("Required attribute `name' not set for `cpu' element.");
592   if (!AX_surfxml_cpu_power) FAIL("Required attribute `power' not set for `cpu' element.");
593   LEAVE; STag_surfxml_cpu(); surfxml_pcdata_ix = 0; ETag_surfxml_cpu(); popbuffer(); /* attribute */
594   switch (YY_START) {
595    case S_surfxml_platform_description_2: case S_surfxml_platform_description_1: case S_surfxml_platform_description: SET(S_surfxml_platform_description_2); break;
596    case ROOT_surfxml_cpu: SET(EPILOG); break;
597    case S_surfxml_include: case S_surfxml_include_2: case S_surfxml_include_1: SET(S_surfxml_include_2); break;
598   }
599  }
600  .       FAIL("Unexpected character `%c' in attribute list of cpu element.", yytext[0]);
601  {Name} FAIL("Bad attribute `%s' in `cpu' element start tag.",yytext);
602  <<EOF>> FAIL("EOF in attribute list of `cpu' element.");
603 }
604
605 <E_surfxml_cpu>{
606  "</cpu"{s}">" {
607   LEAVE;
608   ETag_surfxml_cpu();
609   popbuffer(); /* attribute */
610   switch (YY_START) {
611    case S_surfxml_platform_description_2: case S_surfxml_platform_description_1: case S_surfxml_platform_description: SET(S_surfxml_platform_description_2); break;
612    case ROOT_surfxml_cpu: SET(EPILOG); break;
613    case S_surfxml_include: case S_surfxml_include_2: case S_surfxml_include_1: SET(S_surfxml_include_2); break;
614   }
615  }
616  "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</cpu>' expected.",yytext);
617  .       FAIL("Unexpected character `%c': `</cpu>' expected.",yytext[0]);
618  <<EOF>> FAIL("Premature EOF: `</cpu>' expected.");
619 }
620
621 <ROOT_surfxml_router,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>"<router"{s} {
622   AX_surfxml_router_name = 0;
623   ENTER(AL_surfxml_router); pushbuffer(0);
624   }
625
626 <AL_surfxml_router>{
627  "name"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_surfxml_router_name);
628  "name"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_surfxml_router_name);
629
630  ">" {
631   if (!AX_surfxml_router_name) FAIL("Required attribute `name' not set for `router' element.");
632   LEAVE; STag_surfxml_router();surfxml_pcdata_ix = 0; ENTER(E_surfxml_router);
633  }
634  "/>" {
635   if (!AX_surfxml_router_name) FAIL("Required attribute `name' not set for `router' element.");
636   LEAVE; STag_surfxml_router(); surfxml_pcdata_ix = 0; ETag_surfxml_router(); popbuffer(); /* attribute */
637   switch (YY_START) {
638    case S_surfxml_platform_description_2: case S_surfxml_platform_description_1: case S_surfxml_platform_description: SET(S_surfxml_platform_description_2); break;
639    case ROOT_surfxml_router: SET(EPILOG); break;
640    case S_surfxml_include: case S_surfxml_include_2: case S_surfxml_include_1: SET(S_surfxml_include_2); break;
641   }
642  }
643  .       FAIL("Unexpected character `%c' in attribute list of router element.", yytext[0]);
644  {Name} FAIL("Bad attribute `%s' in `router' element start tag.",yytext);
645  <<EOF>> FAIL("EOF in attribute list of `router' element.");
646 }
647
648 <E_surfxml_router>{
649  "</router"{s}">" {
650   LEAVE;
651   ETag_surfxml_router();
652   popbuffer(); /* attribute */
653   switch (YY_START) {
654    case S_surfxml_platform_description_2: case S_surfxml_platform_description_1: case S_surfxml_platform_description: SET(S_surfxml_platform_description_2); break;
655    case ROOT_surfxml_router: SET(EPILOG); break;
656    case S_surfxml_include: case S_surfxml_include_2: case S_surfxml_include_1: SET(S_surfxml_include_2); break;
657   }
658  }
659  "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</router>' expected.",yytext);
660  .       FAIL("Unexpected character `%c': `</router>' expected.",yytext[0]);
661  <<EOF>> FAIL("Premature EOF: `</router>' expected.");
662 }
663
664 <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} {
665   AX_surfxml_network_link_name = 0;
666   AX_surfxml_network_link_bandwidth = 0;
667   AX_surfxml_network_link_bandwidth_file = 0;
668   AX_surfxml_network_link_latency = 26;
669   AX_surfxml_network_link_latency_file = 0;
670   AX_surfxml_network_link_state = A_surfxml_network_link_state_ON;
671   AX_surfxml_network_link_state_file = 0;
672   AX_surfxml_network_link_sharing_policy = A_surfxml_network_link_sharing_policy_SHARED;
673   ENTER(AL_surfxml_network_link); pushbuffer(0);
674   }
675
676 <AL_surfxml_network_link>{
677  "name"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_surfxml_network_link_name);
678  "name"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_surfxml_network_link_name);
679
680  "bandwidth"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_surfxml_network_link_bandwidth);
681  "bandwidth"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_surfxml_network_link_bandwidth);
682
683  "bandwidth_file"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_surfxml_network_link_bandwidth_file);
684  "bandwidth_file"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_surfxml_network_link_bandwidth_file);
685
686  "latency"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_surfxml_network_link_latency);
687  "latency"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_surfxml_network_link_latency);
688
689  "latency_file"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_surfxml_network_link_latency_file);
690  "latency_file"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_surfxml_network_link_latency_file);
691
692  "state"{Eq}"'ON'" |
693  "state"{Eq}"\"ON\"" A_surfxml_network_link_state = A_surfxml_network_link_state_ON;
694  "state"{Eq}"'OFF'" |
695  "state"{Eq}"\"OFF\"" A_surfxml_network_link_state = A_surfxml_network_link_state_OFF;
696
697  "state_file"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_surfxml_network_link_state_file);
698  "state_file"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_surfxml_network_link_state_file);
699
700  "sharing_policy"{Eq}"'SHARED'" |
701  "sharing_policy"{Eq}"\"SHARED\"" A_surfxml_network_link_sharing_policy = A_surfxml_network_link_sharing_policy_SHARED;
702  "sharing_policy"{Eq}"'FATPIPE'" |
703  "sharing_policy"{Eq}"\"FATPIPE\"" A_surfxml_network_link_sharing_policy = A_surfxml_network_link_sharing_policy_FATPIPE;
704
705  ">" {
706   if (!AX_surfxml_network_link_name) FAIL("Required attribute `name' not set for `network_link' element.");
707   if (!AX_surfxml_network_link_bandwidth) FAIL("Required attribute `bandwidth' not set for `network_link' element.");
708   LEAVE; STag_surfxml_network_link();surfxml_pcdata_ix = 0; ENTER(E_surfxml_network_link);
709  }
710  "/>" {
711   if (!AX_surfxml_network_link_name) FAIL("Required attribute `name' not set for `network_link' element.");
712   if (!AX_surfxml_network_link_bandwidth) FAIL("Required attribute `bandwidth' not set for `network_link' element.");
713   LEAVE; STag_surfxml_network_link(); surfxml_pcdata_ix = 0; ETag_surfxml_network_link(); popbuffer(); /* attribute */
714   switch (YY_START) {
715    case S_surfxml_platform_description_2: case S_surfxml_platform_description_1: case S_surfxml_platform_description: SET(S_surfxml_platform_description_2); break;
716    case ROOT_surfxml_network_link: SET(EPILOG); break;
717    case S_surfxml_include: case S_surfxml_include_2: case S_surfxml_include_1: SET(S_surfxml_include_2); break;
718   }
719  }
720  .       FAIL("Unexpected character `%c' in attribute list of network_link element.", yytext[0]);
721  {Name} FAIL("Bad attribute `%s' in `network_link' element start tag.",yytext);
722  <<EOF>> FAIL("EOF in attribute list of `network_link' element.");
723 }
724
725 <E_surfxml_network_link>{
726  "</network_link"{s}">" {
727   LEAVE;
728   ETag_surfxml_network_link();
729   popbuffer(); /* attribute */
730   switch (YY_START) {
731    case S_surfxml_platform_description_2: case S_surfxml_platform_description_1: case S_surfxml_platform_description: SET(S_surfxml_platform_description_2); break;
732    case ROOT_surfxml_network_link: SET(EPILOG); break;
733    case S_surfxml_include: case S_surfxml_include_2: case S_surfxml_include_1: SET(S_surfxml_include_2); break;
734   }
735  }
736  "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</network_link>' expected.",yytext);
737  .       FAIL("Unexpected character `%c': `</network_link>' expected.",yytext[0]);
738  <<EOF>> FAIL("Premature EOF: `</network_link>' expected.");
739 }
740
741 <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} {
742   AX_surfxml_route_src = 0;
743   AX_surfxml_route_dst = 0;
744   AX_surfxml_route_impact_on_src = 30;
745   AX_surfxml_route_impact_on_dst = 34;
746   AX_surfxml_route_impact_on_src_with_other_recv = 38;
747   AX_surfxml_route_impact_on_dst_with_other_send = 42;
748   ENTER(AL_surfxml_route); pushbuffer(0);
749   }
750
751 <AL_surfxml_route>{
752  "src"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_surfxml_route_src);
753  "src"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_surfxml_route_src);
754
755  "dst"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_surfxml_route_dst);
756  "dst"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_surfxml_route_dst);
757
758  "impact_on_src"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_surfxml_route_impact_on_src);
759  "impact_on_src"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_surfxml_route_impact_on_src);
760
761  "impact_on_dst"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_surfxml_route_impact_on_dst);
762  "impact_on_dst"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_surfxml_route_impact_on_dst);
763
764  "impact_on_src_with_other_recv"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_surfxml_route_impact_on_src_with_other_recv);
765  "impact_on_src_with_other_recv"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_surfxml_route_impact_on_src_with_other_recv);
766
767  "impact_on_dst_with_other_send"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_surfxml_route_impact_on_dst_with_other_send);
768  "impact_on_dst_with_other_send"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_surfxml_route_impact_on_dst_with_other_send);
769
770  ">" {
771   if (!AX_surfxml_route_src) FAIL("Required attribute `src' not set for `route' element.");
772   if (!AX_surfxml_route_dst) FAIL("Required attribute `dst' not set for `route' element.");
773   LEAVE; STag_surfxml_route();surfxml_pcdata_ix = 0; ENTER(S_surfxml_route);
774  }
775  "/>" {
776   if (!AX_surfxml_route_src) FAIL("Required attribute `src' not set for `route' element.");
777   if (!AX_surfxml_route_dst) FAIL("Required attribute `dst' not set for `route' element.");
778   LEAVE; STag_surfxml_route(); surfxml_pcdata_ix = 0; ETag_surfxml_route(); popbuffer(); /* attribute */
779   switch (YY_START) {
780    case S_surfxml_platform_description_2: case S_surfxml_platform_description_1: case S_surfxml_platform_description: SET(S_surfxml_platform_description_2); break;
781    case ROOT_surfxml_route: SET(EPILOG); break;
782    case S_surfxml_include: case S_surfxml_include_2: case S_surfxml_include_1: SET(S_surfxml_include_2); break;
783   }
784  }
785  .       FAIL("Unexpected character `%c' in attribute list of route element.", yytext[0]);
786  {Name} FAIL("Bad attribute `%s' in `route' element start tag.",yytext);
787  <<EOF>> FAIL("EOF in attribute list of `route' element.");
788 }
789
790 <S_surfxml_route,S_surfxml_route_2,E_surfxml_route>{
791  "</route"{s}">" {
792   LEAVE;
793   ETag_surfxml_route();
794   popbuffer(); /* attribute */
795   switch (YY_START) {
796    case S_surfxml_platform_description_2: case S_surfxml_platform_description_1: case S_surfxml_platform_description: SET(S_surfxml_platform_description_2); break;
797    case ROOT_surfxml_route: SET(EPILOG); break;
798    case S_surfxml_include: case S_surfxml_include_2: case S_surfxml_include_1: SET(S_surfxml_include_2); break;
799   }
800  }
801  "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</route>' expected.",yytext);
802  .       FAIL("Unexpected character `%c': `</route>' expected.",yytext[0]);
803  <<EOF>> FAIL("Premature EOF: `</route>' expected.");
804 }
805
806 <ROOT_surfxml_route_element,S_surfxml_route_1,S_surfxml_route,S_surfxml_route_2>"<route_element"{s} {
807   AX_surfxml_route_element_name = 0;
808   ENTER(AL_surfxml_route_element); pushbuffer(0);
809   }
810
811 <AL_surfxml_route_element>{
812  "name"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_surfxml_route_element_name);
813  "name"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_surfxml_route_element_name);
814
815  ">" {
816   if (!AX_surfxml_route_element_name) FAIL("Required attribute `name' not set for `route_element' element.");
817   LEAVE; STag_surfxml_route_element();surfxml_pcdata_ix = 0; ENTER(E_surfxml_route_element);
818  }
819  "/>" {
820   if (!AX_surfxml_route_element_name) FAIL("Required attribute `name' not set for `route_element' element.");
821   LEAVE; STag_surfxml_route_element(); surfxml_pcdata_ix = 0; ETag_surfxml_route_element(); popbuffer(); /* attribute */
822   switch (YY_START) {
823    case S_surfxml_route_1: case S_surfxml_route: case S_surfxml_route_2: SET(S_surfxml_route_2); break;
824    case ROOT_surfxml_route_element: SET(EPILOG); break;
825   }
826  }
827  .       FAIL("Unexpected character `%c' in attribute list of route_element element.", yytext[0]);
828  {Name} FAIL("Bad attribute `%s' in `route_element' element start tag.",yytext);
829  <<EOF>> FAIL("EOF in attribute list of `route_element' element.");
830 }
831
832 <E_surfxml_route_element>{
833  "</route_element"{s}">" {
834   LEAVE;
835   ETag_surfxml_route_element();
836   popbuffer(); /* attribute */
837   switch (YY_START) {
838    case S_surfxml_route_1: case S_surfxml_route: case S_surfxml_route_2: SET(S_surfxml_route_2); break;
839    case ROOT_surfxml_route_element: SET(EPILOG); break;
840   }
841  }
842  "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</route_element>' expected.",yytext);
843  .       FAIL("Unexpected character `%c': `</route_element>' expected.",yytext[0]);
844  <<EOF>> FAIL("Premature EOF: `</route_element>' expected.");
845 }
846
847 <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} {
848   AX_surfxml_process_host = 0;
849   AX_surfxml_process_function = 0;
850   AX_surfxml_process_start_time = 46;
851   AX_surfxml_process_kill_time = 51;
852   ENTER(AL_surfxml_process); pushbuffer(0);
853   }
854
855 <AL_surfxml_process>{
856  "host"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_surfxml_process_host);
857  "host"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_surfxml_process_host);
858
859  "function"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_surfxml_process_function);
860  "function"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_surfxml_process_function);
861
862  "start_time"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_surfxml_process_start_time);
863  "start_time"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_surfxml_process_start_time);
864
865  "kill_time"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_surfxml_process_kill_time);
866  "kill_time"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_surfxml_process_kill_time);
867
868  ">" {
869   if (!AX_surfxml_process_host) FAIL("Required attribute `host' not set for `process' element.");
870   if (!AX_surfxml_process_function) FAIL("Required attribute `function' not set for `process' element.");
871   LEAVE; STag_surfxml_process();surfxml_pcdata_ix = 0; ENTER(S_surfxml_process);
872  }
873  "/>" {
874   if (!AX_surfxml_process_host) FAIL("Required attribute `host' not set for `process' element.");
875   if (!AX_surfxml_process_function) FAIL("Required attribute `function' not set for `process' element.");
876   LEAVE; STag_surfxml_process(); surfxml_pcdata_ix = 0; ETag_surfxml_process(); popbuffer(); /* attribute */
877   switch (YY_START) {
878    case S_surfxml_platform_description_2: case S_surfxml_platform_description_1: case S_surfxml_platform_description: SET(S_surfxml_platform_description_2); break;
879    case ROOT_surfxml_process: SET(EPILOG); break;
880    case S_surfxml_include: case S_surfxml_include_2: case S_surfxml_include_1: SET(S_surfxml_include_2); break;
881   }
882  }
883  .       FAIL("Unexpected character `%c' in attribute list of process element.", yytext[0]);
884  {Name} FAIL("Bad attribute `%s' in `process' element start tag.",yytext);
885  <<EOF>> FAIL("EOF in attribute list of `process' element.");
886 }
887
888 <S_surfxml_process,E_surfxml_process,S_surfxml_process_2>{
889  "</process"{s}">" {
890   LEAVE;
891   ETag_surfxml_process();
892   popbuffer(); /* attribute */
893   switch (YY_START) {
894    case S_surfxml_platform_description_2: case S_surfxml_platform_description_1: case S_surfxml_platform_description: SET(S_surfxml_platform_description_2); break;
895    case ROOT_surfxml_process: SET(EPILOG); break;
896    case S_surfxml_include: case S_surfxml_include_2: case S_surfxml_include_1: SET(S_surfxml_include_2); break;
897   }
898  }
899  "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</process>' expected.",yytext);
900  .       FAIL("Unexpected character `%c': `</process>' expected.",yytext[0]);
901  <<EOF>> FAIL("Premature EOF: `</process>' expected.");
902 }
903
904 <ROOT_surfxml_argument,S_surfxml_process_1,S_surfxml_process,S_surfxml_process_2>"<argument"{s} {
905   AX_surfxml_argument_value = 0;
906   ENTER(AL_surfxml_argument); pushbuffer(0);
907   }
908
909 <AL_surfxml_argument>{
910  "value"{Eq}\' ENTER(VALUE1); BUFFERSET(AX_surfxml_argument_value);
911  "value"{Eq}\" ENTER(VALUE2); BUFFERSET(AX_surfxml_argument_value);
912
913  ">" {
914   if (!AX_surfxml_argument_value) FAIL("Required attribute `value' not set for `argument' element.");
915   LEAVE; STag_surfxml_argument();surfxml_pcdata_ix = 0; ENTER(E_surfxml_argument);
916  }
917  "/>" {
918   if (!AX_surfxml_argument_value) FAIL("Required attribute `value' not set for `argument' element.");
919   LEAVE; STag_surfxml_argument(); surfxml_pcdata_ix = 0; ETag_surfxml_argument(); popbuffer(); /* attribute */
920   switch (YY_START) {
921    case S_surfxml_process_1: case S_surfxml_process: case S_surfxml_process_2: SET(S_surfxml_process_2); break;
922    case ROOT_surfxml_argument: SET(EPILOG); break;
923   }
924  }
925  .       FAIL("Unexpected character `%c' in attribute list of argument element.", yytext[0]);
926  {Name} FAIL("Bad attribute `%s' in `argument' element start tag.",yytext);
927  <<EOF>> FAIL("EOF in attribute list of `argument' element.");
928 }
929
930 <E_surfxml_argument>{
931  "</argument"{s}">" {
932   LEAVE;
933   ETag_surfxml_argument();
934   popbuffer(); /* attribute */
935   switch (YY_START) {
936    case S_surfxml_process_1: case S_surfxml_process: case S_surfxml_process_2: SET(S_surfxml_process_2); break;
937    case ROOT_surfxml_argument: SET(EPILOG); break;
938   }
939  }
940  "</"{Name}{s}">" FAIL("Unexpected end-tag `%s': `</argument>' expected.",yytext);
941  .       FAIL("Unexpected character `%c': `</argument>' expected.",yytext[0]);
942  <<EOF>> FAIL("Premature EOF: `</argument>' expected.");
943 }
944
945  /* EPILOG: after the root element. */
946
947 <EPILOG>{
948  . {SET(PROLOG); yyless(0); CLEANUP; return -1;}
949  <<EOF>>        SUCCEED;
950 }
951
952  /* CHARACTER DATA. */
953
954 <IMPOSSIBLE,VALUE1,VALUE2>{
955  /* Non-defined standard entities... */
956 "&amp;"  BUFFERPUTC('&');
957 "&lt;"   BUFFERPUTC('<');
958 "&gt;"   BUFFERPUTC('>');
959 "&apos;" BUFFERPUTC('\'');
960 "&quot;" BUFFERPUTC('"');
961
962  /* Character entities. */
963  "&#"[[:digit:]]+";"    BUFFERPUTC((unsigned char)atoi(yytext+2));
964  "&#x"[[:xdigit:]]+";"  BUFFERPUTC((unsigned char)strtol(yytext+3,NULL,16));
965 }
966
967 <IMPOSSIBLE,VALUE1,VALUE2,CDATA>{
968  "\n"           |
969  "\r"           |
970  "\r\n"         |
971  "\n\r"         BUFFERPUTC('\n');
972 }
973
974 <IMPOSSIBLE>{
975  "<![CDATA["    ENTER(CDATA);
976  "]""]>"                FAIL("Unexpected `]""]>' in character data.");
977 }
978
979 <VALUE1>{
980  \'             BUFFERDONE; LEAVE;
981  <<EOF>>        FAIL("EOF in literal (\"'\" expected).");
982 }
983
984 <VALUE2>{
985  \"             BUFFERDONE; LEAVE;
986  <<EOF>>        FAIL("EOF in literal (`\"' expected).");
987 }
988
989 <IMPOSSIBLE,VALUE1,VALUE2>{
990  [^<&]          BUFFERPUTC(yytext[0]);
991  [<&]           FAIL("Spurious `%c' in character data.",yytext[0]);
992 }
993
994 <CDATA>{
995  "]""]>"                LEAVE;
996  /* "]""]"              BUFFERPUTC(yytext[0]); BUFFERPUTC(yytext[1]); */
997  .              BUFFERPUTC(yytext[0]);
998  <<EOF>>        FAIL("EOF in CDATA section.");
999 }
1000
1001  /* Impossible rules to avoid warnings from flex(1). */
1002  /* Ideally, this should be replaced by code in flexml.pl that
1003     generates just the states not covered by other rules. */
1004 <*>{
1005  .|[\n] FAIL("Syntax error on character `%c'.", yytext[0]);
1006 }
1007
1008 %%
1009
1010 /* Element context stack lookup. */
1011 int surfxml_element_context(int i)
1012 {
1013   return (0<i && i<yy_start_stack_depth
1014           ? yy_start_stack[yy_start_stack_ptr - i]
1015           : 0);
1016 }
1017
1018 #ifdef FLEX_DEBUG
1019 void print_yy_stack(char* fmt, ...)
1020 {
1021   int i = 0; va_list ap; va_start(ap, fmt);
1022   vfprintf(stderr, fmt, ap);
1023   if (surfxml_statenames) {
1024       for (i=1; i<yy_start_stack_ptr; i++) {
1025           fprintf(stderr, "%s/", surfxml_statenames[yy_start_stack[i] ]);
1026       }
1027       fprintf(stderr,"%s\n", surfxml_statenames[YY_START]);
1028   }
1029   va_end(ap);
1030 }
1031
1032 void print_surfxml_bufferstack()
1033 {
1034     int i;
1035     fputs("Buffer: ", stderr);
1036     for (i = 0; i < blimit; i++) {
1037        if ( surfxml_bufferstack[i] == '\377' ) break;
1038          putc(surfxml_bufferstack[i], stderr);
1039     }
1040     putc('\n', stderr);
1041 }
1042
1043 static void debug_enter(int state, const char* statename) {
1044   yy_push_state(state);
1045   if (yy_flex_debug) {
1046        print_yy_stack("--ENTER(%s) : ",statename);
1047        print_surfxml_bufferstack();
1048   }
1049 }
1050
1051 static void debug_leave(void) {
1052     if (yy_flex_debug) {
1053         print_yy_stack("--LEAVE : ");
1054         print_surfxml_bufferstack();
1055     }
1056   yy_pop_state();
1057 }
1058
1059 static void debug_set(int state, const char* statename) {
1060   BEGIN(state);
1061   if (yy_flex_debug) print_yy_stack("--SET(%s) : ",statename);
1062 }
1063 #endif
1064
1065
1066 static void cleanup(void)
1067 {
1068     if (surfxml_statenames) {
1069         free(surfxml_statenames);
1070         surfxml_statenames = NULL;
1071     }
1072     free(surfxml_bufferstack);
1073     surfxml_bufferstack = NULL;
1074
1075     free(indexstack);
1076     indexstack = NULL;
1077 }
1078
1079
1080 static int fail(const char* fmt, ...)
1081 {
1082     int chars_left, used;
1083     va_list ap; va_start(ap, fmt);
1084 #ifdef FLEXML_yylineno
1085     used = sprintf(flexml_err_msg,
1086                    "Invalid XML (XML input line %d, state %d): ",
1087                    yylineno, YY_START);
1088 #else
1089     used = sprintf(flexml_err_msg,
1090                    "Invalid XML (state %d): ",
1091                    YY_START);
1092 #endif
1093     chars_left = flexml_max_err_msg_size - used - 1;
1094     vsnprintf(flexml_err_msg + used, chars_left, fmt, ap);
1095     va_end(ap);
1096
1097 #ifndef FLEXML_quiet_parser
1098     /* print directly to sdterr */
1099     fprintf(stderr, "%s\n", flexml_err_msg);
1100     flexml_err_msg[0] = '\0';
1101 #endif
1102
1103     cleanup();
1104
1105     return 1;
1106 }