]> www.ginac.de Git - ginac.git/blobdiff - ginac/parser/parse_context.h
[BUGFIX] Fix crash in parser.
[ginac.git] / ginac / parser / parse_context.h
index f24adbd62b00e5d091780c541e58ac00b9e29132..015ca13517dbce52410fa67a8317030e5a3ce30f 100644 (file)
@@ -63,7 +63,21 @@ typedef std::pair<std::string, std::size_t> prototype;
  * The parser uses (an associative array of) such functions to construct
  * (GiNaC) classes and functions from a sequence of characters.
  */
-typedef ex (*reader_func)(const exvector& args);
+class reader_func {
+       enum { FUNCTION_PTR, GINAC_FUNCTION };
+public:
+       reader_func(ex (*func_)(const exvector& args))
+               : type(FUNCTION_PTR), serial(0), func(func_) {}
+       reader_func(unsigned serial_)
+               : type(GINAC_FUNCTION), serial(serial_), func(nullptr) {}
+       ex operator()(const exvector& args) const;
+private:
+       unsigned type;
+       unsigned serial;
+       ex (*func)(const exvector& args);
+};
+
+
 
 /**
  * Prototype table.