Logo AND Algorithmique Numérique Distribuée

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