Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
enable surfxml to live with an other xml parser in the same C code
[simgrid.git] / src / surf / surfxml.l
index e82f061..a766e00 100644 (file)
@@ -1,12 +1,21 @@
 /* Validating XML processor for surfxml.dtd.
- * Generated 2005/02/13 20:04:21.
+ * Generated 2006/03/20 15:32:38.
  *
- * This program was generated with the FleXML XML processor generator,
- * (Id: flexml.pl,v 1.39 2005/02/13 18:12:19 legranda Exp).
- * Copyright © 1999 Kristoffer Rose.  All rights reserved.
+ * This program was generated with the FleXML XML processor generator.
+ * FleXML is Copyright © 1999-2005 Kristoffer Rose.  All rights reserved.
+ * (Id: flexml.pl,v 1.45 2006/03/03 19:25:46 wdowling Exp).
+ * 
+ * There are two, intertwined parts to this program, part A and part B.
  *
- * You can redistribute and/or modify this program provided the following
- * two conditions hold:
+ * Part A
+ * ------
+ * 
+ * Some parts, here collectively called "Part A", are found in the 
+ * FleXML package.  They are Copyright © 1999-2005 Kristoffer Rose. 
+ * All rights reserved.
+ *
+ * You can redistribute, use, perform, display and/or modify "Part A"
+ * provided the following two conditions hold:
  *
  * 1. The program is distributed WITHOUT ANY WARRANTY from the author of
  *    FleXML; without even the implied warranty of MERCHANTABILITY or
  * Notice that these are explicit rights granted to you for files
  * generated by the FleXML system.  For your rights in connection with
  * the FleXML system itself please consult the GNU General Public License.
+ * 
+ * Part B
+ * ------
+ * 
+ * The other parts, here collectively called "Part B", and which came 
+ * from the DTD used by FleXML to generate this program, can be 
+ * distributed (or not, as the case may be) under the terms of whoever
+ * wrote them, provided these terms respect and obey the two conditions 
+ * above under the heading "Part A".
+ *
+ * The author of and contributors to FleXML specifically disclaim
+ * any copyright interest in "Part B", unless "Part B" was written 
+ * by the author of or contributors to FleXML.
+ * 
  */
 
 %{
 
 /* Version strings. */
-const char rcs_flexml_skeleton[] =
- "$" "Id: skel,v 1.24 2005/02/10 11:42:39 mquinson Exp $";
-const char rcs_flexml[] =
- "$" "Id: flexml.pl,v 1.39 2005/02/13 18:12:19 legranda Exp $";
+const char rcs_surfxml_flexml_skeleton[] =
+ "$" "Id: skel,v 1.26 2005/02/23 22:22:20 wdowling Exp $";
+const char rcs_surfxml_flexml[] =
+ "$" "Id: flexml.pl,v 1.45 2006/03/03 19:25:46 wdowling Exp $";
 
 /* ANSI headers. */
 #include <unistd.h>
@@ -39,15 +62,14 @@ const char rcs_flexml[] =
 
 /* Generated definitions. */
 #define FLEXML_yylineno
-#define FLEXML_BUFFERSTACKSIZE 10000000
+#define FLEXML_BUFFERSTACKSIZE 1000000
 
 /* XML processor api. */
-#include "surf/surfxml.h"
-
 /* FleXML-provided data. */
 const char* pcdata;
 AT_network_link_bandwidth A_network_link_bandwidth;
 AT_cpu_name A_cpu_name;
+AT_process_kill_time A_process_kill_time;
 AT_network_link_state A_network_link_state;
 AT_argument_value A_argument_value;
 AT_cpu_availability_file A_cpu_availability_file;
@@ -65,8 +87,10 @@ AT_route_impact_on_src_with_other_recv A_route_impact_on_src_with_other_recv;
 AT_network_link_name A_network_link_name;
 AT_route_element_name A_route_element_name;
 AT_cpu_power A_cpu_power;
+AT_process_start_time A_process_start_time;
 AT_include_file A_include_file;
 AT_process_function A_process_function;
+AT_network_link_sharing_policy A_network_link_sharing_policy;
 AT_route_dst A_route_dst;
 AT_cpu_state A_cpu_state;
 AT_network_link_latency A_network_link_latency;
@@ -91,20 +115,26 @@ AT_network_link_bandwidth_file A_network_link_bandwidth_file;
 
 /* Generic actions. */
 #define SKIP   /*skip*/
-#define SUCCEED        return 0
+#define SUCCEED        CLEANUP; return 0
 
 #define FAIL   return fail
 static int fail(const char*, ...);
-const char * parse_err_msg(void);
+const char * surfxml_parse_err_msg(void);
+
+/* Cleanup */
+static void cleanup(void);
+#define CLEANUP  cleanup()
 
 /* Text buffer stack handling. */
 char bufferstack[FLEXML_BUFFERSTACKSIZE];
-char* limit = bufferstack + FLEXML_BUFFERSTACKSIZE;
+static char* limit = bufferstack + FLEXML_BUFFERSTACKSIZE;
 typedef struct BufferLast_s {
   struct BufferLast_s *old; char* saved; char new1[1];
 } BufferLast;
-BufferLast* last = (BufferLast*)0;
-char* next = bufferstack;
+#ifdef FLEXML_HasMixed
+static BufferLast* last = (BufferLast*)0;
+#endif
+static char* next = bufferstack;
 
 #define BUFFERSET(P)  (P = next)
 #define BUFFERPUTC(C) (assert(next<limit), *(next++) = (C))
@@ -207,7 +237,7 @@ Literal             \'[^'']*\'|\"[^""]*\"
 
 %{
 /* State names. */
-const char* *statenames=NULL;
+const char* *surfxml_statenames=NULL;
 %}
 
 %%
@@ -215,51 +245,53 @@ const char* *statenames=NULL;
  /* Bypass Flex's default INITIAL state and begin by parsing the XML prolog. */
  SET(PROLOG);
   /* FleXML_init */
-  if(!statenames) statenames= (const char **)calloc(IMPOSSIBLE,sizeof(char*));
-  statenames[PROLOG] = NULL;
-  statenames[DOCTYPE] = NULL;
-  statenames[EPILOG] = NULL;
-  statenames[INCOMMENT] = NULL;
-  statenames[INPI] = NULL;
-  statenames[VALUE1] = NULL;
-  statenames[VALUE2] = NULL;
-  statenames[CDATA] = NULL;
-  statenames[ROOT_platform_description] = NULL;
-  statenames[AL_platform_description] = NULL;
-  statenames[S_platform_description] = "platform_description";
-  statenames[S_platform_description_1] = "platform_description";
-  statenames[S_platform_description_2] = "platform_description";
-  statenames[E_platform_description] = "platform_description";
-  statenames[ROOT_include] = NULL;
-  statenames[AL_include] = NULL;
-  statenames[S_include] = "include";
-  statenames[S_include_1] = "include";
-  statenames[S_include_2] = "include";
-  statenames[E_include] = "include";
-  statenames[ROOT_cpu] = NULL;
-  statenames[AL_cpu] = NULL;
-  statenames[E_cpu] = "cpu";
-  statenames[ROOT_network_link] = NULL;
-  statenames[AL_network_link] = NULL;
-  statenames[E_network_link] = "network_link";
-  statenames[ROOT_route] = NULL;
-  statenames[AL_route] = NULL;
-  statenames[S_route] = "route";
-  statenames[S_route_1] = "route";
-  statenames[S_route_2] = "route";
-  statenames[E_route] = "route";
-  statenames[ROOT_route_element] = NULL;
-  statenames[AL_route_element] = NULL;
-  statenames[E_route_element] = "route_element";
-  statenames[ROOT_process] = NULL;
-  statenames[AL_process] = NULL;
-  statenames[S_process] = "process";
-  statenames[S_process_1] = "process";
-  statenames[S_process_2] = "process";
-  statenames[E_process] = "process";
-  statenames[ROOT_argument] = NULL;
-  statenames[AL_argument] = NULL;
-  statenames[E_argument] = "argument";
+  next = bufferstack;
+  if(!surfxml_statenames) {surfxml_statenames= (const char **)calloc(IMPOSSIBLE,sizeof(char*));
+  surfxml_statenames[PROLOG] = NULL;
+  surfxml_statenames[DOCTYPE] = NULL;
+  surfxml_statenames[EPILOG] = NULL;
+  surfxml_statenames[INCOMMENT] = NULL;
+  surfxml_statenames[INPI] = NULL;
+  surfxml_statenames[VALUE1] = NULL;
+  surfxml_statenames[VALUE2] = NULL;
+  surfxml_statenames[CDATA] = NULL;
+  surfxml_statenames[ROOT_platform_description] = NULL;
+  surfxml_statenames[AL_platform_description] = NULL;
+  surfxml_statenames[S_platform_description] = "platform_description";
+  surfxml_statenames[S_platform_description_1] = "platform_description";
+  surfxml_statenames[S_platform_description_2] = "platform_description";
+  surfxml_statenames[E_platform_description] = "platform_description";
+  surfxml_statenames[ROOT_include] = NULL;
+  surfxml_statenames[AL_include] = NULL;
+  surfxml_statenames[S_include] = "include";
+  surfxml_statenames[S_include_1] = "include";
+  surfxml_statenames[S_include_2] = "include";
+  surfxml_statenames[E_include] = "include";
+  surfxml_statenames[ROOT_cpu] = NULL;
+  surfxml_statenames[AL_cpu] = NULL;
+  surfxml_statenames[E_cpu] = "cpu";
+  surfxml_statenames[ROOT_network_link] = NULL;
+  surfxml_statenames[AL_network_link] = NULL;
+  surfxml_statenames[E_network_link] = "network_link";
+  surfxml_statenames[ROOT_route] = NULL;
+  surfxml_statenames[AL_route] = NULL;
+  surfxml_statenames[S_route] = "route";
+  surfxml_statenames[S_route_1] = "route";
+  surfxml_statenames[S_route_2] = "route";
+  surfxml_statenames[E_route] = "route";
+  surfxml_statenames[ROOT_route_element] = NULL;
+  surfxml_statenames[AL_route_element] = NULL;
+  surfxml_statenames[E_route_element] = "route_element";
+  surfxml_statenames[ROOT_process] = NULL;
+  surfxml_statenames[AL_process] = NULL;
+  surfxml_statenames[S_process] = "process";
+  surfxml_statenames[S_process_1] = "process";
+  surfxml_statenames[S_process_2] = "process";
+  surfxml_statenames[E_process] = "process";
+  surfxml_statenames[ROOT_argument] = NULL;
+  surfxml_statenames[AL_argument] = NULL;
+  surfxml_statenames[E_argument] = "argument";
+  }
 
  /* COMMENTS and PIs: handled uniformly for efficiency. */
 
@@ -474,6 +506,7 @@ const char* *statenames=NULL;
   A_network_link_latency_file = NULL;
   A_network_link_state = A_network_link_state_ON;
   A_network_link_state_file = NULL;
+  A_network_link_sharing_policy = A_network_link_sharing_policy_SHARED;
   ENTER(AL_network_link);
   }
 
@@ -501,6 +534,11 @@ const char* *statenames=NULL;
  "state_file"{Eq}\' ENTER(VALUE1); BUFFERSET(A_network_link_state_file);
  "state_file"{Eq}\" ENTER(VALUE2); BUFFERSET(A_network_link_state_file);
 
+ "sharing_policy"{Eq}"'SHARED'" |
+ "sharing_policy"{Eq}"\"SHARED\"" A_network_link_sharing_policy = A_network_link_sharing_policy_SHARED;
+ "sharing_policy"{Eq}"'FATPIPE'" |
+ "sharing_policy"{Eq}"\"FATPIPE\"" A_network_link_sharing_policy = A_network_link_sharing_policy_FATPIPE;
+
  ">" {
   if (!A_network_link_name) FAIL("Required attribute `name' not set for `network_link' element.");
   if (!A_network_link_bandwidth) FAIL("Required attribute `bandwidth' not set for `network_link' element.");
@@ -643,6 +681,8 @@ const char* *statenames=NULL;
 <ROOT_process,S_platform_description_2,S_include,S_include_2,S_platform_description_1,S_include_1,S_platform_description>"<process"{s} {
   A_process_host = NULL;
   A_process_function = NULL;
+  A_process_start_time = "-1.0";
+  A_process_kill_time = "-1.0";
   ENTER(AL_process);
   }
 
@@ -653,6 +693,12 @@ const char* *statenames=NULL;
  "function"{Eq}\' ENTER(VALUE1); BUFFERSET(A_process_function);
  "function"{Eq}\" ENTER(VALUE2); BUFFERSET(A_process_function);
 
+ "start_time"{Eq}\' ENTER(VALUE1); BUFFERSET(A_process_start_time);
+ "start_time"{Eq}\" ENTER(VALUE2); BUFFERSET(A_process_start_time);
+
+ "kill_time"{Eq}\' ENTER(VALUE1); BUFFERSET(A_process_kill_time);
+ "kill_time"{Eq}\" ENTER(VALUE2); BUFFERSET(A_process_kill_time);
+
  ">" {
   if (!A_process_host) FAIL("Required attribute `host' not set for `process' element.");
   if (!A_process_function) FAIL("Required attribute `function' not set for `process' element.");
@@ -731,7 +777,7 @@ const char* *statenames=NULL;
  /* EPILOG: after the root element. */
 
 <EPILOG>{
- . {SET(PROLOG); yyless(0); return -1;}
+ . {SET(PROLOG); yyless(0); CLEANUP; return -1;}
  <<EOF>>       SUCCEED;
 }
 
@@ -794,7 +840,7 @@ const char* *statenames=NULL;
 %%
 
 /* Element context stack lookup. */
-int element_context(int i)
+int surfxml_element_context(int i)
 {
   return (0<i && i<yy_start_stack_depth
          ? yy_start_stack[yy_start_stack_ptr - i]
@@ -807,8 +853,8 @@ void print_yy_stack(char* fmt, ...)
   int i = 0; va_list ap; va_start(ap, fmt);
   vfprintf(stderr, fmt, ap);
   for (i=1; i<yy_start_stack_ptr; i++)
-    fprintf(stderr, "%s/", statenames[yy_start_stack[i] ]);
-  fprintf(stderr,"%s\n", statenames[YY_START]);
+    fprintf(stderr, "%s/", surfxml_statenames[yy_start_stack[i] ]);
+  fprintf(stderr,"%s\n", surfxml_statenames[YY_START]);
   va_end(ap);
 }
 
@@ -831,17 +877,26 @@ static void debug_set(int state, const char* statename) {
 enum {flexml_max_err_msg_size = 512};
 
 static char flexml_err_msg[flexml_max_err_msg_size];
-const char * parse_err_msg()
+const char * surfxml_parse_err_msg()
 {
     return flexml_err_msg;
 }
 
-static void reset_parse_err_msg()
+static void reset_surfxml_parse_err_msg()
 {
     flexml_err_msg[0] = '\0';
 }
 
 
+static void cleanup(void)
+{
+    if (surfxml_statenames) {
+        free(surfxml_statenames);
+       surfxml_statenames = NULL;
+    }
+}
+
+
 static int fail(const char* fmt, ...)
 {
     int chars_left, used;
@@ -864,6 +919,8 @@ static int fail(const char* fmt, ...)
     fprintf(stderr, "%s\n", flexml_err_msg);
     flexml_err_msg[0] = '\0';
 #endif
-   
+
+    cleanup();
+
     return 1;
 }