Logo AND Algorithmique Numérique Distribuée

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