X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fparser%2Fparse_context.h;h=1145a871cb4b2da67a95373d44ea0812ab2567a5;hp=b227c6654fb40d4e917e39e0067b859f5865ef60;hb=866b3eb23253a272788d8791b1ed023e63674d50;hpb=95ede03f00106be5fb087d76c86ca5c27edb9122 diff --git a/ginac/parser/parse_context.h b/ginac/parser/parse_context.h index b227c665..1145a871 100644 --- a/ginac/parser/parse_context.h +++ b/ginac/parser/parse_context.h @@ -41,12 +41,12 @@ namespace GiNaC { typedef std::map symtab; /** - * Find the symbol with the @a name in the symbol table @a syms. + * Find the symbol (or abbreviation) with the @a name in the symbol table @a syms. * * If symbol is missing and @a strict = false, insert it, otherwise * throw an exception. */ -extern symbol +extern ex find_or_insert_symbol(const std::string& name, symtab& syms, const bool strict); @@ -72,18 +72,36 @@ typedef ex (*reader_func)(const exvector& args); * foo(x+y, z^2, t)), it looks up such a table to find out which * function (or class) corresponds to the given name and has the given * number of the arguments. + * + * N.B. + * + * 1. The function don't have to return a (GiNaC) function or class, it + * can return any expression. + * 2. Overloaded functions/ctors are paritally supported, i.e. there might + * be several functions with the same name, but they should take different + * number of arguments. + * 3. User can extend the parser via custom prototype tables. It's possible + * to read user defined classes, create abbreviations, etc. + * + * NOTE: due to a hack that allows user defined functions to be parsed, the map + * value of type reader_func is internally treated as an unsigned and not as a + * function pointer!! The unsigned has to correspond to the serial number of + * the defined GiNaC function. */ -typedef std::map prototype_table; +typedef std::map prototype_table; /** - * Creates a default prototype table containing all defined GiNaC functions. + * Default prototype table. + * + * It supports all defined GiNaC functions and "pow", "sqrt", and "power". + */ +extern const prototype_table& get_default_reader(); +/** + * Builtin prototype table. * - * The data referenced by the return value is only created once when this - * function is called for the first time. This might cause problems in very - * rare stituations (i.e. if functions are added after this first call). In - * that case, a new initialization can be forced with an "true" argument. + * It supports only the builtin GiNaC functions and "pow", "sqrt", and "power". */ -extern const prototype_table& get_default_reader(bool force_init = false); +extern const prototype_table& get_builtin_reader(); } // namespace GiNaC