Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
greatly improve an error message
[simgrid.git] / src / surf / xml / surfxml_sax_cb.cpp
1 /* Copyright (c) 2006-2017. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #include "simgrid/s4u/Engine.hpp"
7 #include "simgrid/sg_config.h"
8 #include "src/kernel/routing/NetPoint.hpp"
9 #include "src/surf/network_interface.hpp"
10 #include "xbt/file.h"
11
12 #include "src/surf/xml/platf_private.hpp"
13 #include <boost/algorithm/string.hpp>
14 #include <boost/algorithm/string/classification.hpp>
15 #include <boost/algorithm/string/split.hpp>
16 #include <string>
17
18 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_parse, surf, "Logging specific to the SURF parsing module");
19
20 SG_BEGIN_DECL()
21
22 int ETag_surfxml_include_state();
23
24 #include "simgrid_dtd.c"
25
26 char* surf_parsed_filename = nullptr; // to locate parse error messages
27
28 std::vector<simgrid::surf::LinkImpl*> parsed_link_list; /* temporary store of current list link of a route */
29
30 /*
31  * Helping functions
32  */
33 void surf_parse_assert(bool cond, const char *fmt, ...) {
34   if (not cond) {
35     va_list va;
36     va_start(va,fmt);
37     int lineno = surf_parse_lineno;
38     char *msg = bvprintf(fmt,va);
39     va_end(va);
40     cleanup();
41     XBT_ERROR("Parse error at %s:%d: %s", surf_parsed_filename, lineno, msg);
42     surf_exit();
43     xbt_die("Exiting now");
44   }
45 }
46 void surf_parse_error(const char *fmt, ...) {
47   va_list va;
48   va_start(va,fmt);
49   int lineno = surf_parse_lineno;
50   char *msg = bvprintf(fmt,va);
51   va_end(va);
52   cleanup();
53   XBT_ERROR("Parse error at %s:%d: %s", surf_parsed_filename, lineno, msg);
54   surf_exit();
55   xbt_die("Exiting now");
56 }
57 void surf_parse_assert_netpoint(char* hostname, const char* pre, const char* post)
58 {
59   if (sg_netpoint_by_name_or_null(hostname) != nullptr) // found
60     return;
61
62   std::string msg = std::string(pre);
63   msg += hostname;
64   msg += post;
65   msg += " Existing netpoints: \n";
66
67   std::vector<simgrid::kernel::routing::NetPoint*> list;
68   simgrid::s4u::Engine::instance()->netpointList(&list);
69   bool first = true;
70   for (auto np : list) {
71     if (np->isNetZone())
72       continue;
73
74     if (not first)
75       msg += ",";
76     first = false;
77     msg += "'" + np->name() + "'";
78     if (msg.length() > 4096) {
79       msg.pop_back(); // remove trailing quote
80       msg += "...(list truncated)......";
81       break;
82     }
83   }
84   surf_parse_error("%s", msg.c_str());
85 }
86
87 void surf_parse_warn(const char *fmt, ...) {
88   va_list va;
89   va_start(va,fmt);
90   char *msg = bvprintf(fmt,va);
91   va_end(va);
92     XBT_WARN("%s:%d: %s", surf_parsed_filename, surf_parse_lineno, msg);
93     free(msg);
94 }
95
96 double surf_parse_get_double(const char *string) {
97   double res;
98   int ret = sscanf(string, "%lg", &res);
99   if (ret != 1)
100     surf_parse_error("%s is not a double", string);
101   return res;
102 }
103
104 int surf_parse_get_int(const char *string) {
105   int res;
106   int ret = sscanf(string, "%d", &res);
107   if (ret != 1)
108     surf_parse_error("%s is not an integer", string);
109   return res;
110 }
111
112 /* Turn something like "1-4,6,9-11" into the vector {1,2,3,4,6,9,10,11} */
113 static std::vector<int>* explodesRadical(const char* radicals)
114 {
115   std::vector<int>* exploded = new std::vector<int>();
116
117   // Make all hosts
118   std::vector<std::string> radical_elements;
119   boost::split(radical_elements, radicals, boost::is_any_of(","));
120   for (auto group : radical_elements) {
121     std::vector<std::string> radical_ends;
122     boost::split(radical_ends, group, boost::is_any_of("-"));
123     int start                = surf_parse_get_int((radical_ends.front()).c_str());
124     int end                  = 0;
125
126     switch (radical_ends.size()) {
127       case 1:
128         end = start;
129         break;
130       case 2:
131         end = surf_parse_get_int((radical_ends.back()).c_str());
132         break;
133       default:
134         surf_parse_error("Malformed radical: %s", group.c_str());
135         break;
136     }
137     for (int i = start; i <= end; i++)
138       exploded->push_back(i);
139   }
140
141   return exploded;
142 }
143
144 struct unit_scale {
145   const char *unit;
146   double scale;
147 };
148
149 /* Note: field `unit' for the last element of parameter `units' should be nullptr. */
150 static double surf_parse_get_value_with_unit(const char *string, const struct unit_scale *units,
151     const char *entity_kind, const char *name, const char *error_msg, const char *default_unit)
152 {
153   char* ptr;
154   int i;
155   errno = 0;
156   double res   = strtod(string, &ptr);
157   if (errno == ERANGE)
158     surf_parse_error("value out of range: %s", string);
159   if (ptr == string)
160     surf_parse_error("cannot parse number: %s", string);
161   if (ptr[0] == '\0') {
162     if (res == 0)
163       return res; // Ok, 0 can be unit-less
164
165     XBT_WARN("Deprecated unit-less value '%s' for %s %s. %s",string, entity_kind, name, error_msg);
166     ptr = (char*)default_unit;
167   }
168   for (i = 0; units[i].unit != nullptr && strcmp(ptr, units[i].unit) != 0; i++);
169
170   if (units[i].unit != nullptr)
171     res *= units[i].scale;
172   else
173     surf_parse_error("unknown unit: %s", ptr);
174   return res;
175 }
176
177 double surf_parse_get_time(const char *string, const char *entity_kind, const char *name)
178 {
179   const struct unit_scale units[] = {
180     { "w",  7 * 24 * 60 * 60 },
181     { "d",  24 * 60 * 60 },
182     { "h",  60 * 60 },
183     { "m",  60 },
184     { "s",  1.0 },
185     { "ms", 1e-3 },
186     { "us", 1e-6 },
187     { "ns", 1e-9 },
188     { "ps", 1e-12 },
189     { nullptr, 0 }
190   };
191   return surf_parse_get_value_with_unit(string, units, entity_kind, name,
192       "Append 's' to your time to get seconds", "s");
193 }
194
195 double surf_parse_get_size(const char *string, const char *entity_kind, const char *name)
196 {
197   const struct unit_scale units[] = {
198     { "EiB", pow(1024, 6) },
199     { "PiB", pow(1024, 5) },
200     { "TiB", pow(1024, 4) },
201     { "GiB", pow(1024, 3) },
202     { "MiB", pow(1024, 2) },
203     { "KiB", 1024 },
204     { "EB",  1e18 },
205     { "PB",  1e15 },
206     { "TB",  1e12 },
207     { "GB",  1e9 },
208     { "MB",  1e6 },
209     { "kB",  1e3 },
210     { "B",   1.0 },
211     { "Eib", 0.125 * pow(1024, 6) },
212     { "Pib", 0.125 * pow(1024, 5) },
213     { "Tib", 0.125 * pow(1024, 4) },
214     { "Gib", 0.125 * pow(1024, 3) },
215     { "Mib", 0.125 * pow(1024, 2) },
216     { "Kib", 0.125 * 1024 },
217     { "Eb",  0.125 * 1e18 },
218     { "Pb",  0.125 * 1e15 },
219     { "Tb",  0.125 * 1e12 },
220     { "Gb",  0.125 * 1e9 },
221     { "Mb",  0.125 * 1e6 },
222     { "kb",  0.125 * 1e3 },
223     { "b",   0.125 },
224     { nullptr,    0 }
225   };
226   return surf_parse_get_value_with_unit(string, units, entity_kind, name,
227       "Append 'B' to get bytes (or 'b' for bits but 1B = 8b).", "B");
228 }
229
230 double surf_parse_get_bandwidth(const char *string, const char *entity_kind, const char *name)
231 {
232   const struct unit_scale units[] = {
233     { "EiBps", pow(1024, 6) },
234     { "PiBps", pow(1024, 5) },
235     { "TiBps", pow(1024, 4) },
236     { "GiBps", pow(1024, 3) },
237     { "MiBps", pow(1024, 2) },
238     { "KiBps", 1024 },
239     { "EBps",  1e18 },
240     { "PBps",  1e15 },
241     { "TBps",  1e12 },
242     { "GBps",  1e9 },
243     { "MBps",  1e6 },
244     { "kBps",  1e3 },
245     { "Bps",   1.0 },
246     { "Eibps", 0.125 * pow(1024, 6) },
247     { "Pibps", 0.125 * pow(1024, 5) },
248     { "Tibps", 0.125 * pow(1024, 4) },
249     { "Gibps", 0.125 * pow(1024, 3) },
250     { "Mibps", 0.125 * pow(1024, 2) },
251     { "Kibps", 0.125 * 1024 },
252     { "Tbps",  0.125 * 1e12 },
253     { "Gbps",  0.125 * 1e9 },
254     { "Mbps",  0.125 * 1e6 },
255     { "kbps",  0.125 * 1e3 },
256     { "bps",   0.125 },
257     { nullptr,    0 }
258   };
259   return surf_parse_get_value_with_unit(string, units, entity_kind, name,
260       "Append 'Bps' to get bytes per second (or 'bps' for bits but 1Bps = 8bps)", "Bps");
261 }
262
263 double surf_parse_get_speed(const char *string, const char *entity_kind, const char *name)
264 {
265   const struct unit_scale units[] = {
266     { "yottaflops", 1e24 },
267     { "Yf",         1e24 },
268     { "zettaflops", 1e21 },
269     { "Zf",         1e21 },
270     { "exaflops",   1e18 },
271     { "Ef",         1e18 },
272     { "petaflops",  1e15 },
273     { "Pf",         1e15 },
274     { "teraflops",  1e12 },
275     { "Tf",         1e12 },
276     { "gigaflops",  1e9 },
277     { "Gf",         1e9 },
278     { "megaflops",  1e6 },
279     { "Mf",         1e6 },
280     { "kiloflops",  1e3 },
281     { "kf",         1e3 },
282     { "flops",      1.0 },
283     { "f",          1.0 },
284     { nullptr,         0 }
285   };
286   return surf_parse_get_value_with_unit(string, units, entity_kind, name,
287       "Append 'f' or 'flops' to your speed to get flop per second", "f");
288 }
289
290 static std::vector<double> surf_parse_get_all_speeds(char* speeds, const char* entity_kind, const char* id){
291
292   std::vector<double> speed_per_pstate;
293
294   if (strchr(speeds, ',') == nullptr){
295     double speed = surf_parse_get_speed(speeds, entity_kind, id);
296     speed_per_pstate.push_back(speed);
297   } else {
298     std::vector<std::string> pstate_list;
299     boost::split(pstate_list, speeds, boost::is_any_of(","));
300     for (auto speed_str : pstate_list) {
301       boost::trim(speed_str);
302       double speed = surf_parse_get_speed(speed_str.c_str(), entity_kind, id);
303       speed_per_pstate.push_back(speed);
304       XBT_DEBUG("Speed value: %f", speed);
305     }
306   }
307   return speed_per_pstate;
308 }
309
310 /*
311  * All the callback lists that can be overridden anywhere.
312  * (this list should probably be reduced to the bare minimum to allow the models to work)
313  */
314
315 /* make sure these symbols are defined as strong ones in this file so that the linker can resolve them */
316
317 /* The default current property receiver. Setup in the corresponding opening callbacks. */
318 xbt_dict_t current_property_set = nullptr;
319 std::map<std::string, std::string>* current_model_property_set = nullptr;
320 int ZONE_TAG                            = 0; // Whether we just opened a zone tag (to see what to do with the properties)
321
322 /* dictionary of random generator data */
323 xbt_dict_t random_data_list = nullptr;
324
325 YY_BUFFER_STATE surf_input_buffer;
326 FILE *surf_file_to_parse = nullptr;
327
328 /*
329  * Stuff relative to storage
330  */
331 void STag_surfxml_storage()
332 {
333   ZONE_TAG = 0;
334   XBT_DEBUG("STag_surfxml_storage");
335   xbt_assert(current_property_set == nullptr, "Someone forgot to reset the property set to nullptr in its closing tag (or XML malformed)");
336 }
337 void ETag_surfxml_storage()
338 {
339   s_sg_platf_storage_cbarg_t storage;
340   memset(&storage,0,sizeof(storage));
341
342   storage.properties   = current_property_set;
343   current_property_set = nullptr;
344
345   storage.id           = A_surfxml_storage_id;
346   storage.type_id      = A_surfxml_storage_typeId;
347   storage.content      = A_surfxml_storage_content;
348
349   storage.attach       = A_surfxml_storage_attach;
350   sg_platf_new_storage(&storage);
351 }
352 void STag_surfxml_storage___type()
353 {
354   ZONE_TAG = 0;
355   XBT_DEBUG("STag_surfxml_storage___type");
356   xbt_assert(current_property_set == nullptr, "Someone forgot to reset the property set to nullptr in its closing tag (or XML malformed)");
357   xbt_assert(current_model_property_set == nullptr, "Someone forgot to reset the model property set to nullptr in its closing tag (or XML malformed)");
358 }
359 void ETag_surfxml_storage___type()
360 {
361   s_sg_platf_storage_type_cbarg_t storage_type;
362   memset(&storage_type,0,sizeof(storage_type));
363
364   storage_type.properties = current_property_set;
365   current_property_set    = nullptr;
366
367   storage_type.model_properties = current_model_property_set;
368   current_model_property_set    = nullptr;
369
370   storage_type.content          = A_surfxml_storage___type_content;
371   storage_type.id               = A_surfxml_storage___type_id;
372   storage_type.model            = A_surfxml_storage___type_model;
373   storage_type.size             = surf_parse_get_size(A_surfxml_storage___type_size,
374         "size of storage type", storage_type.id);
375   sg_platf_new_storage_type(&storage_type);
376 }
377 void STag_surfxml_mount()
378 {
379   XBT_DEBUG("STag_surfxml_mount");
380 }
381 void ETag_surfxml_mount()
382 {
383   s_sg_platf_mount_cbarg_t mount;
384   memset(&mount,0,sizeof(mount));
385
386   mount.name      = A_surfxml_mount_name;
387   mount.storageId = A_surfxml_mount_storageId;
388   sg_platf_new_mount(&mount);
389 }
390
391 /*
392  * Stuff relative to the <include> tag
393  */
394 static std::vector<YY_BUFFER_STATE> surf_input_buffer_stack;
395 static std::vector<FILE*> surf_file_to_parse_stack;
396 static std::vector<char*> surf_parsed_filename_stack;
397
398 void STag_surfxml_include()
399 {
400   parse_after_config();
401   XBT_DEBUG("STag_surfxml_include '%s'",A_surfxml_include_file);
402   surf_parsed_filename_stack.push_back(surf_parsed_filename); // save old file name
403   surf_parsed_filename = xbt_strdup(A_surfxml_include_file);
404
405   surf_file_to_parse_stack.push_back(surf_file_to_parse); // save old file descriptor
406
407   surf_file_to_parse = surf_fopen(A_surfxml_include_file, "r"); // read new file descriptor
408   xbt_assert((surf_file_to_parse), "Unable to open \"%s\"\n", A_surfxml_include_file);
409
410   surf_input_buffer_stack.push_back(surf_input_buffer);
411   surf_input_buffer = surf_parse__create_buffer(surf_file_to_parse, YY_BUF_SIZE);
412   surf_parse_push_buffer_state(surf_input_buffer);
413
414   fflush(nullptr);
415 }
416
417 void ETag_surfxml_include() {
418 /* Nothing to do when done with reading the include tag.
419  * Instead, the handling should be deferred until the EOF of current buffer -- see below */
420 }
421
422 /** @brief When reaching EOF, check whether we are in an include tag, and behave accordingly if yes
423  *
424  * This function is called automatically by sedding the parser in tools/cmake/MaintainerMode.cmake
425  * Every FAIL on "Premature EOF" is preceded by a call to this function, which role is to restore the
426  * previous buffer if we reached the EOF /of an include file/. Its return code is used to avoid the
427  * error message in that case.
428  *
429  * Yeah, that's terribly hackish, but it works. A better solution should be dealed with in flexml
430  * directly: a command line flag could instruct it to do the correct thing when the include directive is encountered
431  * on a line. One day maybe, if the maya allow it.
432  */
433 int ETag_surfxml_include_state()
434 {
435   fflush(nullptr);
436   XBT_DEBUG("ETag_surfxml_include_state '%s'",A_surfxml_include_file);
437
438   if (surf_input_buffer_stack.empty()) // nope, that's a true premature EOF. Let the parser die verbosely.
439     return 0;
440
441   // Yeah, we were in an <include> Restore state and proceed.
442   fclose(surf_file_to_parse);
443   surf_file_to_parse_stack.pop_back();
444   surf_parse_pop_buffer_state();
445   surf_input_buffer_stack.pop_back();
446
447   // Restore the filename for error messages
448   free(surf_parsed_filename);
449   surf_parsed_filename_stack.pop_back();
450
451   return 1;
452 }
453
454 /* Stag and Etag parse functions */
455
456 void STag_surfxml_platform() {
457   XBT_ATTRIB_UNUSED double version = surf_parse_get_double(A_surfxml_platform_version);
458
459   xbt_assert((version >= 1.0), "******* BIG FAT WARNING *********\n "
460       "You're using an ancient XML file.\n"
461       "Since SimGrid 3.1, units are Bytes, Flops, and seconds "
462       "instead of MBytes, MFlops and seconds.\n"
463
464       "Use simgrid_update_xml to update your file automatically. "
465       "This program is installed automatically with SimGrid, or "
466       "available in the tools/ directory of the source archive.\n"
467
468       "Please check also out the SURF section of the ChangeLog for "
469       "the 3.1 version for more information. \n"
470
471       "Last, do not forget to also update your values for "
472       "the calls to MSG_task_create (if any).");
473   xbt_assert((version >= 3.0), "******* BIG FAT WARNING *********\n "
474       "You're using an old XML file.\n"
475       "Use simgrid_update_xml to update your file automatically. "
476       "This program is installed automatically with SimGrid, or "
477       "available in the tools/ directory of the source archive.");
478   xbt_assert((version >= 4.0),
479              "******* FILE %s IS TOO OLD (v:%.1f) *********\n "
480              "Changes introduced in SimGrid 3.13:\n"
481              "  - 'power' attribute of hosts (and others) got renamed to 'speed'.\n"
482              "  - In <trace_connect>, attribute kind=\"POWER\" is now kind=\"SPEED\".\n"
483              "  - DOCTYPE now point to the rignt URL: http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd\n"
484              "  - speed, bandwidth and latency attributes now MUST have an explicit unit (f, Bps, s by default)"
485              "\n\n"
486              "Use simgrid_update_xml to update your file automatically. "
487              "This program is installed automatically with SimGrid, or "
488              "available in the tools/ directory of the source archive.",
489              surf_parsed_filename, version);
490   if (version < 4.1) {
491     XBT_INFO("You're using a v%.1f XML file (%s) while the current standard is v4.1 "
492              "That's fine, the new version is backward compatible. \n\n"
493              "Use simgrid_update_xml to update your file automatically. "
494              "This program is installed automatically with SimGrid, or "
495              "available in the tools/ directory of the source archive.",
496              version, surf_parsed_filename);
497   }
498   xbt_assert(version <= 4.1, "******* FILE %s COMES FROM THE FUTURE (v:%.1f) *********\n "
499                              "The most recent formalism that this version of SimGrid understands is v4.1.\n"
500                              "Please update your code, or use another, more adapted, file.",
501              surf_parsed_filename, version);
502
503   sg_platf_begin();
504 }
505 void ETag_surfxml_platform(){
506   sg_platf_end();
507 }
508
509 void STag_surfxml_host(){
510   ZONE_TAG = 0;
511   xbt_assert(current_property_set == nullptr, "Someone forgot to reset the property set to nullptr in its closing tag (or XML malformed)");
512 }
513
514 void STag_surfxml_prop()
515 {
516   if (ZONE_TAG) { // We need to retrieve the most recently opened zone
517     XBT_DEBUG("Set zone property %s -> %s", A_surfxml_prop_id, A_surfxml_prop_value);
518     simgrid::s4u::NetZone* netzone = simgrid::s4u::Engine::instance()->netzoneByNameOrNull(A_surfxml_zone_id);
519
520     netzone->setProperty(A_surfxml_prop_id, A_surfxml_prop_value);
521   }
522   else{
523     if (not current_property_set)
524       current_property_set = xbt_dict_new_homogeneous(&xbt_free_f); // Maybe, it should raise an error
525     xbt_dict_set(current_property_set, A_surfxml_prop_id, xbt_strdup(A_surfxml_prop_value), nullptr);
526     XBT_DEBUG("add prop %s=%s into current property set %p", A_surfxml_prop_id, A_surfxml_prop_value,
527               current_property_set);
528   }
529 }
530
531 void ETag_surfxml_host()    {
532   s_sg_platf_host_cbarg_t host;
533   memset(&host,0,sizeof(host));
534
535   host.properties = current_property_set;
536   current_property_set = nullptr;
537
538   host.id = A_surfxml_host_id;
539
540   host.speed_per_pstate = surf_parse_get_all_speeds(A_surfxml_host_speed, "speed of host", host.id);
541
542   XBT_DEBUG("pstate: %s", A_surfxml_host_pstate);
543   host.core_amount = surf_parse_get_int(A_surfxml_host_core);
544   host.speed_trace = A_surfxml_host_availability___file[0] ? tmgr_trace_new_from_file(A_surfxml_host_availability___file) : nullptr;
545   host.state_trace = A_surfxml_host_state___file[0] ? tmgr_trace_new_from_file(A_surfxml_host_state___file) : nullptr;
546   host.pstate      = surf_parse_get_int(A_surfxml_host_pstate);
547   host.coord       = A_surfxml_host_coordinates;
548
549   sg_platf_new_host(&host);
550 }
551
552 void STag_surfxml_host___link(){
553   XBT_DEBUG("Create a Host_link for %s",A_surfxml_host___link_id);
554   s_sg_platf_host_link_cbarg_t host_link;
555   memset(&host_link,0,sizeof(host_link));
556
557   host_link.id        = A_surfxml_host___link_id;
558   host_link.link_up   = A_surfxml_host___link_up;
559   host_link.link_down = A_surfxml_host___link_down;
560   sg_platf_new_hostlink(&host_link);
561 }
562
563 void STag_surfxml_router(){
564   sg_platf_new_router(A_surfxml_router_id, A_surfxml_router_coordinates);
565 }
566
567 void ETag_surfxml_cluster(){
568   s_sg_platf_cluster_cbarg_t cluster;
569   memset(&cluster,0,sizeof(cluster));
570   cluster.properties = current_property_set;
571   current_property_set = nullptr;
572
573   cluster.id          = A_surfxml_cluster_id;
574   cluster.prefix      = A_surfxml_cluster_prefix;
575   cluster.suffix      = A_surfxml_cluster_suffix;
576   cluster.radicals    = explodesRadical(A_surfxml_cluster_radical);
577   cluster.speeds      = surf_parse_get_all_speeds(A_surfxml_cluster_speed, "speed of cluster", cluster.id);
578   cluster.core_amount = surf_parse_get_int(A_surfxml_cluster_core);
579   cluster.bw          = surf_parse_get_bandwidth(A_surfxml_cluster_bw, "bw of cluster", cluster.id);
580   cluster.lat         = surf_parse_get_time(A_surfxml_cluster_lat, "lat of cluster", cluster.id);
581   if(strcmp(A_surfxml_cluster_bb___bw,""))
582     cluster.bb_bw = surf_parse_get_bandwidth(A_surfxml_cluster_bb___bw, "bb_bw of cluster", cluster.id);
583   if(strcmp(A_surfxml_cluster_bb___lat,""))
584     cluster.bb_lat = surf_parse_get_time(A_surfxml_cluster_bb___lat, "bb_lat of cluster", cluster.id);
585   if(strcmp(A_surfxml_cluster_limiter___link,""))
586     cluster.limiter_link = surf_parse_get_bandwidth(A_surfxml_cluster_limiter___link, "limiter_link of cluster", cluster.id);
587   if(strcmp(A_surfxml_cluster_loopback___bw,""))
588     cluster.loopback_bw = surf_parse_get_bandwidth(A_surfxml_cluster_loopback___bw, "loopback_bw of cluster", cluster.id);
589   if(strcmp(A_surfxml_cluster_loopback___lat,""))
590     cluster.loopback_lat = surf_parse_get_time(A_surfxml_cluster_loopback___lat, "loopback_lat of cluster", cluster.id);
591
592   switch(AX_surfxml_cluster_topology){
593   case A_surfxml_cluster_topology_FLAT:
594     cluster.topology= SURF_CLUSTER_FLAT ;
595     break;
596   case A_surfxml_cluster_topology_TORUS:
597     cluster.topology= SURF_CLUSTER_TORUS ;
598     break;
599   case A_surfxml_cluster_topology_FAT___TREE:
600     cluster.topology = SURF_CLUSTER_FAT_TREE;
601     break;
602   case A_surfxml_cluster_topology_DRAGONFLY:
603     cluster.topology= SURF_CLUSTER_DRAGONFLY ;
604     break;
605   default:
606     surf_parse_error("Invalid cluster topology for cluster %s",
607                      cluster.id);
608     break;
609   }
610   cluster.topo_parameters = A_surfxml_cluster_topo___parameters;
611   cluster.router_id = A_surfxml_cluster_router___id;
612
613   switch (AX_surfxml_cluster_sharing___policy) {
614   case A_surfxml_cluster_sharing___policy_SHARED:
615     cluster.sharing_policy = SURF_LINK_SHARED;
616     break;
617   case A_surfxml_cluster_sharing___policy_FULLDUPLEX:
618     cluster.sharing_policy = SURF_LINK_FULLDUPLEX;
619     break;
620   case A_surfxml_cluster_sharing___policy_FATPIPE:
621     cluster.sharing_policy = SURF_LINK_FATPIPE;
622     break;
623   default:
624     surf_parse_error("Invalid cluster sharing policy for cluster %s", cluster.id);
625     break;
626   }
627   switch (AX_surfxml_cluster_bb___sharing___policy) {
628   case A_surfxml_cluster_bb___sharing___policy_FATPIPE:
629     cluster.bb_sharing_policy = SURF_LINK_FATPIPE;
630     break;
631   case A_surfxml_cluster_bb___sharing___policy_SHARED:
632     cluster.bb_sharing_policy = SURF_LINK_SHARED;
633     break;
634   default:
635     surf_parse_error("Invalid bb sharing policy in cluster %s", cluster.id);
636     break;
637   }
638
639   sg_platf_new_cluster(&cluster);
640 }
641
642 void STag_surfxml_cluster(){
643   ZONE_TAG = 0;
644   parse_after_config();
645   xbt_assert(current_property_set == nullptr, "Someone forgot to reset the property set to nullptr in its closing tag (or XML malformed)");
646 }
647
648 void STag_surfxml_cabinet(){
649   parse_after_config();
650   s_sg_platf_cabinet_cbarg_t cabinet;
651   memset(&cabinet,0,sizeof(cabinet));
652   cabinet.id      = A_surfxml_cabinet_id;
653   cabinet.prefix  = A_surfxml_cabinet_prefix;
654   cabinet.suffix  = A_surfxml_cabinet_suffix;
655   cabinet.speed   = surf_parse_get_speed(A_surfxml_cabinet_speed, "speed of cabinet", cabinet.id);
656   cabinet.bw      = surf_parse_get_bandwidth(A_surfxml_cabinet_bw, "bw of cabinet", cabinet.id);
657   cabinet.lat     = surf_parse_get_time(A_surfxml_cabinet_lat, "lat of cabinet", cabinet.id);
658   cabinet.radicals = explodesRadical(A_surfxml_cabinet_radical);
659
660   sg_platf_new_cabinet(&cabinet);
661 }
662
663 void STag_surfxml_peer(){
664   parse_after_config();
665   s_sg_platf_peer_cbarg_t peer;
666   memset(&peer,0,sizeof(peer));
667   peer.id          = A_surfxml_peer_id;
668   peer.speed       = surf_parse_get_speed(A_surfxml_peer_speed, "speed of peer", peer.id);
669   peer.bw_in       = surf_parse_get_bandwidth(A_surfxml_peer_bw___in, "bw_in of peer", peer.id);
670   peer.bw_out      = surf_parse_get_bandwidth(A_surfxml_peer_bw___out, "bw_out of peer", peer.id);
671   peer.coord       = A_surfxml_peer_coordinates;
672   peer.speed_trace = A_surfxml_peer_availability___file[0] ? tmgr_trace_new_from_file(A_surfxml_peer_availability___file) : nullptr;
673   peer.state_trace = A_surfxml_peer_state___file[0] ? tmgr_trace_new_from_file(A_surfxml_peer_state___file) : nullptr;
674
675   if (A_surfxml_peer_lat[0] != '\0')
676     XBT_WARN("The latency parameter in <peer> is now deprecated. Use the z coordinate instead of '%s'.",
677              A_surfxml_peer_lat);
678
679   sg_platf_new_peer(&peer);
680 }
681
682 void STag_surfxml_link(){
683   ZONE_TAG = 0;
684   xbt_assert(current_property_set == nullptr, "Someone forgot to reset the property set to nullptr in its closing tag (or XML malformed)");
685 }
686
687 void ETag_surfxml_link(){
688   LinkCreationArgs link;
689
690   link.properties          = current_property_set;
691   current_property_set     = nullptr;
692
693   link.id                  = std::string(A_surfxml_link_id);
694   link.bandwidth           = surf_parse_get_bandwidth(A_surfxml_link_bandwidth, "bandwidth of link", link.id.c_str());
695   link.bandwidth_trace     = A_surfxml_link_bandwidth___file[0] ? tmgr_trace_new_from_file(A_surfxml_link_bandwidth___file) : nullptr;
696   link.latency             = surf_parse_get_time(A_surfxml_link_latency, "latency of link", link.id.c_str());
697   link.latency_trace       = A_surfxml_link_latency___file[0] ? tmgr_trace_new_from_file(A_surfxml_link_latency___file) : nullptr;
698   link.state_trace         = A_surfxml_link_state___file[0] ? tmgr_trace_new_from_file(A_surfxml_link_state___file):nullptr;
699
700   switch (A_surfxml_link_sharing___policy) {
701   case A_surfxml_link_sharing___policy_SHARED:
702     link.policy = SURF_LINK_SHARED;
703     break;
704   case A_surfxml_link_sharing___policy_FATPIPE:
705      link.policy = SURF_LINK_FATPIPE;
706      break;
707   case A_surfxml_link_sharing___policy_FULLDUPLEX:
708      link.policy = SURF_LINK_FULLDUPLEX;
709      break;
710   default:
711     surf_parse_error("Invalid sharing policy in link %s", link.id.c_str());
712     break;
713   }
714
715   sg_platf_new_link(&link);
716 }
717
718 void STag_surfxml_link___ctn(){
719
720   simgrid::surf::LinkImpl* link = nullptr;
721   char *link_name=nullptr;
722   switch (A_surfxml_link___ctn_direction) {
723   case AU_surfxml_link___ctn_direction:
724   case A_surfxml_link___ctn_direction_NONE:
725     link = simgrid::surf::LinkImpl::byName(A_surfxml_link___ctn_id);
726     break;
727   case A_surfxml_link___ctn_direction_UP:
728     link_name = bprintf("%s_UP", A_surfxml_link___ctn_id);
729     link      = simgrid::surf::LinkImpl::byName(link_name);
730     break;
731   case A_surfxml_link___ctn_direction_DOWN:
732     link_name = bprintf("%s_DOWN", A_surfxml_link___ctn_id);
733     link      = simgrid::surf::LinkImpl::byName(link_name);
734     break;
735   default:
736     surf_parse_error("Invalid direction for link %s", link_name);
737     break;
738   }
739   xbt_free(link_name); // no-op if it's already nullptr
740
741   const char* dirname = "";
742   switch (A_surfxml_link___ctn_direction) {
743     case A_surfxml_link___ctn_direction_UP:
744       dirname = " (upward)";
745       break;
746     case A_surfxml_link___ctn_direction_DOWN:
747       dirname = " (downward)";
748       break;
749     default:
750       dirname = "";
751   }
752   surf_parse_assert(link != nullptr, "No such link: '%s'%s", A_surfxml_link___ctn_id, dirname);
753   parsed_link_list.push_back(link);
754 }
755
756 void ETag_surfxml_backbone(){
757   LinkCreationArgs link;
758
759   link.properties = nullptr;
760   link.id = std::string(A_surfxml_backbone_id);
761   link.bandwidth = surf_parse_get_bandwidth(A_surfxml_backbone_bandwidth, "bandwidth of backbone", link.id.c_str());
762   link.latency = surf_parse_get_time(A_surfxml_backbone_latency, "latency of backbone", link.id.c_str());
763   link.policy = SURF_LINK_SHARED;
764
765   sg_platf_new_link(&link);
766   routing_cluster_add_backbone(simgrid::surf::LinkImpl::byName(A_surfxml_backbone_id));
767 }
768
769 void STag_surfxml_route(){
770   surf_parse_assert_netpoint(A_surfxml_route_src, "Route src='", "' does name a node.");
771   surf_parse_assert_netpoint(A_surfxml_route_dst, "Route dst='", "' does name a node.");
772 }
773
774 void STag_surfxml_ASroute(){
775   surf_parse_assert_netpoint(A_surfxml_ASroute_src, "ASroute src='", "' does name a node.");
776   surf_parse_assert_netpoint(A_surfxml_ASroute_dst, "ASroute dst='", "' does name a node.");
777
778   surf_parse_assert_netpoint(A_surfxml_ASroute_gw___src, "ASroute gw_src='", "' does name a node.");
779   surf_parse_assert_netpoint(A_surfxml_ASroute_gw___dst, "ASroute gw_dst='", "' does name a node.");
780 }
781 void STag_surfxml_zoneRoute(){
782   surf_parse_assert_netpoint(A_surfxml_zoneRoute_src, "zoneRoute src='", "' does name a node.");
783   surf_parse_assert_netpoint(A_surfxml_zoneRoute_dst, "zoneRoute dst='", "' does name a node.");
784   surf_parse_assert_netpoint(A_surfxml_zoneRoute_gw___src, "zoneRoute gw_src='", "' does name a node.");
785   surf_parse_assert_netpoint(A_surfxml_zoneRoute_gw___dst, "zoneRoute gw_dst='", "' does name a node.");
786 }
787
788 void STag_surfxml_bypassRoute(){
789   surf_parse_assert_netpoint(A_surfxml_bypassRoute_src, "bypassRoute src='", "' does name a node.");
790   surf_parse_assert_netpoint(A_surfxml_bypassRoute_dst, "bypassRoute dst='", "' does name a node.");
791 }
792
793 void STag_surfxml_bypassASroute(){
794   surf_parse_assert_netpoint(A_surfxml_bypassASroute_src, "bypassASroute src='", "' does name a node.");
795   surf_parse_assert_netpoint(A_surfxml_bypassASroute_dst, "bypassASroute dst='", "' does name a node.");
796   surf_parse_assert_netpoint(A_surfxml_bypassASroute_gw___src, "bypassASroute gw_src='", "' does name a node.");
797   surf_parse_assert_netpoint(A_surfxml_bypassASroute_gw___dst, "bypassASroute gw_dst='", "' does name a node.");
798 }
799 void STag_surfxml_bypassZoneRoute(){
800   surf_parse_assert_netpoint(A_surfxml_bypassZoneRoute_src, "bypassZoneRoute src='", "' does name a node.");
801   surf_parse_assert_netpoint(A_surfxml_bypassZoneRoute_dst, "bypassZoneRoute dst='", "' does name a node.");
802   surf_parse_assert_netpoint(A_surfxml_bypassZoneRoute_gw___src, "bypassZoneRoute gw_src='", "' does name a node.");
803   surf_parse_assert_netpoint(A_surfxml_bypassZoneRoute_gw___dst, "bypassZoneRoute gw_dst='", "' does name a node.");
804 }
805
806 void ETag_surfxml_route(){
807   s_sg_platf_route_cbarg_t route;
808   memset(&route,0,sizeof(route));
809
810   route.src         = sg_netpoint_by_name_or_null(A_surfxml_route_src); // tested to not be nullptr in start tag
811   route.dst         = sg_netpoint_by_name_or_null(A_surfxml_route_dst); // tested to not be nullptr in start tag
812   route.gw_src    = nullptr;
813   route.gw_dst    = nullptr;
814   route.link_list   = new std::vector<simgrid::surf::LinkImpl*>();
815   route.symmetrical = (A_surfxml_route_symmetrical == A_surfxml_route_symmetrical_YES);
816
817   for (auto link: parsed_link_list)
818     route.link_list->push_back(link);
819   parsed_link_list.clear();
820
821   sg_platf_new_route(&route);
822   delete route.link_list;
823 }
824
825 void ETag_surfxml_ASroute()
826 {
827   AX_surfxml_zoneRoute_src = AX_surfxml_ASroute_src;
828   AX_surfxml_zoneRoute_dst = AX_surfxml_ASroute_dst;
829   AX_surfxml_zoneRoute_gw___src = AX_surfxml_ASroute_gw___src;
830   AX_surfxml_zoneRoute_gw___dst = AX_surfxml_ASroute_gw___dst;
831   AX_surfxml_zoneRoute_symmetrical = (AT_surfxml_zoneRoute_symmetrical)AX_surfxml_ASroute_symmetrical;
832   ETag_surfxml_zoneRoute();
833 }
834 void ETag_surfxml_zoneRoute()
835 {
836   s_sg_platf_route_cbarg_t ASroute;
837   memset(&ASroute,0,sizeof(ASroute));
838
839   ASroute.src = sg_netpoint_by_name_or_null(A_surfxml_zoneRoute_src); // tested to not be nullptr in start tag
840   ASroute.dst = sg_netpoint_by_name_or_null(A_surfxml_zoneRoute_dst); // tested to not be nullptr in start tag
841
842   ASroute.gw_src = sg_netpoint_by_name_or_null(A_surfxml_zoneRoute_gw___src); // tested to not be nullptr in start tag
843   ASroute.gw_dst = sg_netpoint_by_name_or_null(A_surfxml_zoneRoute_gw___dst); // tested to not be nullptr in start tag
844
845   ASroute.link_list = new std::vector<simgrid::surf::LinkImpl*>();
846
847   for (auto link: parsed_link_list)
848     ASroute.link_list->push_back(link);
849   parsed_link_list.clear();
850
851   switch (A_surfxml_zoneRoute_symmetrical) {
852   case AU_surfxml_zoneRoute_symmetrical:
853   case A_surfxml_zoneRoute_symmetrical_YES:
854     ASroute.symmetrical = true;
855     break;
856   case A_surfxml_zoneRoute_symmetrical_NO:
857     ASroute.symmetrical = false;
858     break;
859   }
860
861   sg_platf_new_route(&ASroute);
862   delete ASroute.link_list;
863 }
864
865 void ETag_surfxml_bypassRoute(){
866   s_sg_platf_route_cbarg_t route;
867   memset(&route,0,sizeof(route));
868
869   route.src         = sg_netpoint_by_name_or_null(A_surfxml_bypassRoute_src); // tested to not be nullptr in start tag
870   route.dst         = sg_netpoint_by_name_or_null(A_surfxml_bypassRoute_dst); // tested to not be nullptr in start tag
871   route.gw_src = nullptr;
872   route.gw_dst = nullptr;
873   route.symmetrical = false;
874   route.link_list   = new std::vector<simgrid::surf::LinkImpl*>();
875
876   for (auto link: parsed_link_list)
877     route.link_list->push_back(link);
878   parsed_link_list.clear();
879
880   sg_platf_new_bypassRoute(&route);
881   delete route.link_list;
882 }
883
884 void ETag_surfxml_bypassASroute()
885 {
886   AX_surfxml_bypassZoneRoute_src = AX_surfxml_bypassASroute_src;
887   AX_surfxml_bypassZoneRoute_dst = AX_surfxml_bypassASroute_dst;
888   AX_surfxml_bypassZoneRoute_gw___src = AX_surfxml_bypassASroute_gw___src;
889   AX_surfxml_bypassZoneRoute_gw___dst = AX_surfxml_bypassASroute_gw___dst;
890   ETag_surfxml_bypassZoneRoute();
891 }
892 void ETag_surfxml_bypassZoneRoute()
893 {
894   s_sg_platf_route_cbarg_t ASroute;
895   memset(&ASroute,0,sizeof(ASroute));
896
897   ASroute.src         = sg_netpoint_by_name_or_null(A_surfxml_bypassZoneRoute_src);
898   ASroute.dst         = sg_netpoint_by_name_or_null(A_surfxml_bypassZoneRoute_dst);
899   ASroute.link_list   = new std::vector<simgrid::surf::LinkImpl*>();
900   for (auto link: parsed_link_list)
901     ASroute.link_list->push_back(link);
902   parsed_link_list.clear();
903
904   ASroute.symmetrical = false;
905
906   ASroute.gw_src = sg_netpoint_by_name_or_null(A_surfxml_bypassZoneRoute_gw___src);
907   ASroute.gw_dst = sg_netpoint_by_name_or_null(A_surfxml_bypassZoneRoute_gw___dst);
908
909   sg_platf_new_bypassRoute(&ASroute);
910   delete ASroute.link_list;
911 }
912
913 void ETag_surfxml_trace(){
914   s_sg_platf_trace_cbarg_t trace;
915   memset(&trace,0,sizeof(trace));
916
917   trace.id = A_surfxml_trace_id;
918   trace.file = A_surfxml_trace_file;
919   trace.periodicity = surf_parse_get_double(A_surfxml_trace_periodicity);
920   trace.pc_data = surfxml_pcdata;
921
922   sg_platf_new_trace(&trace);
923 }
924
925 void STag_surfxml_trace___connect()
926 {
927   parse_after_config();
928   s_sg_platf_trace_connect_cbarg_t trace_connect;
929   memset(&trace_connect,0,sizeof(trace_connect));
930
931   trace_connect.element = A_surfxml_trace___connect_element;
932   trace_connect.trace = A_surfxml_trace___connect_trace;
933
934   switch (A_surfxml_trace___connect_kind) {
935   case AU_surfxml_trace___connect_kind:
936   case A_surfxml_trace___connect_kind_SPEED:
937     trace_connect.kind =  SURF_TRACE_CONNECT_KIND_SPEED;
938     break;
939   case A_surfxml_trace___connect_kind_BANDWIDTH:
940     trace_connect.kind =  SURF_TRACE_CONNECT_KIND_BANDWIDTH;
941     break;
942   case A_surfxml_trace___connect_kind_HOST___AVAIL:
943     trace_connect.kind =  SURF_TRACE_CONNECT_KIND_HOST_AVAIL;
944     break;
945   case A_surfxml_trace___connect_kind_LATENCY:
946     trace_connect.kind =  SURF_TRACE_CONNECT_KIND_LATENCY;
947     break;
948   case A_surfxml_trace___connect_kind_LINK___AVAIL:
949     trace_connect.kind =  SURF_TRACE_CONNECT_KIND_LINK_AVAIL;
950     break;
951   default:
952     surf_parse_error("Invalid trace kind");
953     break;
954   }
955   sg_platf_trace_connect(&trace_connect);
956 }
957
958 void STag_surfxml_AS()
959 {
960   AX_surfxml_zone_id = AX_surfxml_AS_id;
961   AX_surfxml_zone_routing = (AT_surfxml_zone_routing)AX_surfxml_AS_routing;
962   STag_surfxml_zone();
963 }
964
965 void ETag_surfxml_AS()
966 {
967   ETag_surfxml_zone();
968 }
969
970 void STag_surfxml_zone()
971 {
972   parse_after_config();
973   ZONE_TAG                 = 1;
974   s_sg_platf_AS_cbarg_t AS = {A_surfxml_zone_id, (int)A_surfxml_zone_routing};
975
976   sg_platf_new_AS_begin(&AS);
977 }
978
979 void ETag_surfxml_zone()
980 {
981   sg_platf_new_AS_seal();
982 }
983
984 void STag_surfxml_config()
985 {
986   ZONE_TAG = 0;
987   xbt_assert(current_property_set == nullptr, "Someone forgot to reset the property set to nullptr in its closing tag (or XML malformed)");
988   XBT_DEBUG("START configuration name = %s",A_surfxml_config_id);
989   if (_sg_cfg_init_status == 2) {
990     surf_parse_error("All <config> tags must be given before any platform elements (such as <zone>, <host>, <cluster>, "
991                      "<link>, etc).");
992   }
993 }
994
995 void ETag_surfxml_config()
996 {
997   xbt_dict_cursor_t cursor = nullptr;
998   char *key;
999   char *elem;
1000   xbt_dict_foreach(current_property_set, cursor, key, elem) {
1001     if (xbt_cfg_is_default_value(key)) {
1002       std::string cfg = std::string(key) + ":" + elem;
1003       xbt_cfg_set_parse(cfg.c_str());
1004     } else
1005       XBT_INFO("The custom configuration '%s' is already defined by user!",key);
1006   }
1007   XBT_DEBUG("End configuration name = %s",A_surfxml_config_id);
1008
1009   xbt_dict_free(&current_property_set);
1010   current_property_set = nullptr;
1011 }
1012
1013 static int argc;
1014 static char **argv;
1015
1016 void STag_surfxml_process()
1017 {
1018   AX_surfxml_actor_function = AX_surfxml_process_function;
1019   STag_surfxml_actor();
1020 }
1021 void STag_surfxml_actor()
1022 {
1023   ZONE_TAG  = 0;
1024   argc    = 1;
1025   argv    = xbt_new(char *, 1);
1026   argv[0] = xbt_strdup(A_surfxml_actor_function);
1027   xbt_assert(current_property_set == nullptr, "Someone forgot to reset the property set to nullptr in its closing tag (or XML malformed)");
1028 }
1029
1030 void ETag_surfxml_process()
1031 {
1032   AX_surfxml_actor_host = AX_surfxml_process_host;
1033   AX_surfxml_actor_function = AX_surfxml_process_function;
1034   AX_surfxml_actor_start___time = AX_surfxml_process_start___time;
1035   AX_surfxml_actor_kill___time = AX_surfxml_process_kill___time;
1036   AX_surfxml_actor_on___failure = (AT_surfxml_actor_on___failure)AX_surfxml_process_on___failure;
1037   ETag_surfxml_actor();
1038 }
1039 void ETag_surfxml_actor()
1040 {
1041   s_sg_platf_process_cbarg_t actor;
1042   memset(&actor,0,sizeof(actor));
1043
1044   actor.argc       = argc;
1045   actor.argv       = (const char **)argv;
1046   actor.properties = current_property_set;
1047   actor.host       = A_surfxml_actor_host;
1048   actor.function   = A_surfxml_actor_function;
1049   actor.start_time = surf_parse_get_double(A_surfxml_actor_start___time);
1050   actor.kill_time  = surf_parse_get_double(A_surfxml_actor_kill___time);
1051
1052   switch (A_surfxml_actor_on___failure) {
1053   case AU_surfxml_actor_on___failure:
1054   case A_surfxml_actor_on___failure_DIE:
1055     actor.on_failure =  SURF_ACTOR_ON_FAILURE_DIE;
1056     break;
1057   case A_surfxml_actor_on___failure_RESTART:
1058     actor.on_failure =  SURF_ACTOR_ON_FAILURE_RESTART;
1059     break;
1060   default:
1061     surf_parse_error("Invalid on failure behavior");
1062     break;
1063   }
1064
1065   sg_platf_new_process(&actor);
1066
1067   for (int i = 0; i != argc; ++i)
1068     xbt_free(argv[i]);
1069   xbt_free(argv);
1070   argv = nullptr;
1071
1072   current_property_set = nullptr;
1073 }
1074
1075 void STag_surfxml_argument(){
1076   argc++;
1077   argv = (char**)xbt_realloc(argv, (argc) * sizeof(char **));
1078   argv[(argc) - 1] = xbt_strdup(A_surfxml_argument_value);
1079 }
1080
1081 void STag_surfxml_model___prop(){
1082   if (not current_model_property_set)
1083     current_model_property_set = new std::map<std::string, std::string>();
1084
1085   current_model_property_set->insert(
1086       {std::string(A_surfxml_model___prop_id), std::string(A_surfxml_model___prop_value)});
1087 }
1088
1089 void ETag_surfxml_prop(){/* Nothing to do */}
1090 void STag_surfxml_random(){/* Nothing to do */}
1091 void ETag_surfxml_random(){/* Nothing to do */}
1092 void ETag_surfxml_trace___connect(){/* Nothing to do */}
1093 void STag_surfxml_trace(){parse_after_config();}
1094 void ETag_surfxml_router(){/*Nothing to do*/}
1095 void ETag_surfxml_host___link(){/* Nothing to do */}
1096 void ETag_surfxml_cabinet(){/* Nothing to do */}
1097 void ETag_surfxml_peer(){/* Nothing to do */}
1098 void STag_surfxml_backbone(){/* Nothing to do */}
1099 void ETag_surfxml_link___ctn(){/* Nothing to do */}
1100 void ETag_surfxml_argument(){/* Nothing to do */}
1101 void ETag_surfxml_model___prop(){/* Nothing to do */}
1102
1103 /* Open and Close parse file */
1104 void surf_parse_open(const char *file)
1105 {
1106   xbt_assert(file, "Cannot parse the nullptr file. Bypassing the parser is strongly deprecated nowadays.");
1107
1108   surf_parsed_filename = xbt_strdup(file);
1109   char* dir            = xbt_dirname(file);
1110   surf_path.push_back(std::string(dir));
1111   xbt_free(dir);
1112
1113   surf_file_to_parse = surf_fopen(file, "r");
1114   xbt_assert(surf_file_to_parse != nullptr, "Unable to open '%s'\n", file);
1115   surf_input_buffer = surf_parse__create_buffer(surf_file_to_parse, YY_BUF_SIZE);
1116   surf_parse__switch_to_buffer(surf_input_buffer);
1117   surf_parse_lineno = 1;
1118 }
1119
1120 void surf_parse_close()
1121 {
1122   if (surf_parsed_filename) {
1123     surf_path.pop_back();
1124   }
1125
1126   free(surf_parsed_filename);
1127   surf_parsed_filename = nullptr;
1128
1129   if (surf_file_to_parse) {
1130     surf_parse__delete_buffer(surf_input_buffer);
1131     fclose(surf_file_to_parse);
1132     surf_file_to_parse = nullptr; //Must be reset for Bypass
1133   }
1134 }
1135
1136 /* Call the lexer to parse the currently opened file. This pointer to function enables bypassing of the parser */
1137 static int _surf_parse() {
1138   return surf_parse_lex();
1139 }
1140
1141 int_f_void_t surf_parse = &_surf_parse;
1142
1143 SG_END_DECL()