Logo AND Algorithmique Numérique Distribuée

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