Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
handle flexer errors within the parsing module
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Mon, 18 Nov 2019 05:13:09 +0000 (06:13 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Mon, 18 Nov 2019 05:13:13 +0000 (06:13 +0100)
Raise the exception ourselves instead of leaking an error code that
must be converted into an exception by our caller.

src/kernel/EngineImpl.cpp
src/surf/xml/platf.hpp
src/surf/xml/surfxml_parseplatf.cpp
src/surf/xml/surfxml_sax_cb.cpp

index ab8ce33..d22046d 100644 (file)
@@ -47,9 +47,8 @@ void EngineImpl::load_deployment(const std::string& file)
   sg_platf_init();
 
   surf_parse_open(file);
-  int parse_status = surf_parse();
+  surf_parse();
   surf_parse_close();
-  surf_parse_assert(not parse_status, std::string("Parse error in file ") + file);
 }
 void EngineImpl::register_function(const std::string& name, xbt_main_func_t code)
 {
index 2e83473..f046293 100644 (file)
@@ -28,6 +28,6 @@ XBT_PUBLIC std::vector<double> surf_parse_get_bandwidths(const char* string, con
                                                          const std::string& name);
 XBT_PUBLIC double surf_parse_get_speed(const char* string, const char* entity_kind, const std::string& name);
 
-XBT_PUBLIC int surf_parse(); /* Entry-point to the parser */
+XBT_PUBLIC void surf_parse(); /* Entry-point to the parser */
 
 #endif
index 810b4f5..88029c7 100644 (file)
@@ -92,13 +92,11 @@ void parse_platform_file(const std::string& file)
 
   // Use XML parser
 
-  int parse_status;
-
   /* init the flex parser */
   surf_parse_open(file);
 
   /* Do the actual parsing */
-  parse_status = surf_parse();
+  surf_parse();
 
   /* connect all profiles relative to hosts */
   for (auto const& elm : trace_connect_list_host_avail) {
@@ -145,7 +143,4 @@ void parse_platform_file(const std::string& file)
   }
 
   surf_parse_close();
-
-  if (parse_status)
-    surf_parse_error(std::string("Parse error in ") + file);
 }
index 9e4a03f..d46e18a 100644 (file)
@@ -1024,7 +1024,8 @@ void surf_parse_close()
 }
 
 /* Call the lexer to parse the currently opened file */
-int surf_parse()
+void surf_parse()
 {
-  return surf_parse_lex();
+  bool err = surf_parse_lex();
+  surf_parse_assert(not err, "Flex returned an error code");
 }