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 9e8c1a0..e65802a 100644 (file)
@@ -82,4 +82,57 @@ const prototype_table& get_default_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
index 37e08aa..55e07d1 100644 (file)
@@ -99,9 +99,15 @@ typedef std::map<prototype, reader_func> 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();
+/**
+ * Builtin prototype table.
+ *
+ * It supports only the builtin GiNaC functions and "pow", "sqrt", and "power".
+ */
+extern const prototype_table& get_builtin_reader();
 
 } // namespace GiNaC