]> www.ginac.de Git - ginac.git/commitdiff
Added get_builtin_reader() that parses only the builtin GiNaC functions
authorJens Vollinga <jensv@nikhef.nl>
Sun, 9 Aug 2009 21:38:48 +0000 (23:38 +0200)
committerJens Vollinga <jensv@nikhef.nl>
Sun, 9 Aug 2009 21:38:48 +0000 (23:38 +0200)
and pow, sqrt, and power.

ginac/parser/default_reader.tpl
ginac/parser/parse_context.h

index 9e8c1a04e24646716597cff890efdcc4c53e10cc..e65802a439c6b866a79103c3e6dfd77e398da512 100644 (file)
@@ -82,4 +82,57 @@ const prototype_table& get_default_reader()
        return reader;
 }
 
        return reader;
 }
 
+const prototype_table& get_builtin_reader()
+{
+       using std::make_pair;
+       static bool initialized = false;
+       static prototype_table reader;
+       if (!initialized) {
+               [+ FOR function +]
+               reader[make_pair("[+ (get "name") +]", [+ 
+                       (if (exist? "args") (get "args") "1")
+                       +])] = [+ (get "name") +]_reader;[+
+               ENDFOR +]
+               enum {
+                       log,
+                       exp,
+                       sin,
+                       cos,
+                       tan,
+                       asin,
+                       acos,
+                       atan,
+                       sinh,
+                       cosh,
+                       tanh,
+                       asinh,
+                       acosh,
+                       atanh,
+                       atan2,
+                       Li2,
+                       Li3,
+                       zetaderiv,
+                       Li,
+                       S,
+                       H,
+                       lgamma,
+                       tgamma,
+                       beta,
+                       factorial,
+                       binomial,
+                       Order,
+                       NFUNCTIONS
+               };
+               std::vector<function_options>::const_iterator it =
+                       registered_functions_hack::get_registered_functions().begin();
+               unsigned serial = 0;
+               for ( ; serial<NFUNCTIONS; ++it, ++serial ) {
+                       prototype proto = make_pair(it->get_name(), it->get_nparams());
+                       reader[proto] = encode_serial_as_reader_func(serial);
+               }
+               initialized = true;
+       }
+       return reader;
+}
+
 } // namespace GiNaC
 } // namespace GiNaC
index 37e08aa0d0030163ee9d61dc77f7aac00454ae90..55e07d113f00b12e349afe9c6804f304b61f32db 100644 (file)
@@ -99,9 +99,15 @@ typedef std::map<prototype, reader_func> prototype_table;
 /**
  * Default prototype table.
  *
 /**
  * Default prototype table.
  *
- * It supports most of builtin GiNaC functions.
+ * It supports all defined GiNaC functions and "pow", "sqrt", and "power".
  */
 extern const prototype_table& get_default_reader();
  */
 extern const prototype_table& get_default_reader();
+/**
+ * Builtin prototype table.
+ *
+ * It supports only the builtin GiNaC functions and "pow", "sqrt", and "power".
+ */
+extern const prototype_table& get_builtin_reader();
 
 } // namespace GiNaC
 
 
 } // namespace GiNaC