Logo AND Algorithmique Numérique Distribuée

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