1 #ifndef _GINAC_PARSE_CONTEXT_HPP
2 #define _GINAC_PARSE_CONTEXT_HPP
4 #include <cstddef> // size_t
14 * Establishes correspondence between the strings and symbols.
15 * The parser will create missing symbols (if not instructed otherwise,
16 * in which case it fails if the expression contains unknown symbols).
17 * The .second element of pair helps to distinguish between the user
18 * supplied symbols and parser generated ones. The .first is the symbol
21 typedef std::map<std::string, std::pair<symbol, bool> > symtab;
24 * Find the symbol with the @a name in the symbol table @a syms.
26 * If symbol is missing and @a strict = false, insert it, otherwise
30 find_or_insert_symbol(const std::string& name, symtab& syms,
34 * Function (or class ctor) prototype
35 * .first is the name of function(or ctor),
36 * .second is the number of arguments (each of type ex)
38 typedef std::pair<std::string, std::size_t> prototype;
41 * A (C++) function for reading functions and classes from the stream.
43 * The parser uses (an associative array of) such functions to construct
44 * (GiNaC) classes and functions from a sequence of characters.
46 typedef ex (*reader_func)(const exvector& args);
51 * If parser sees an expression which looks like a function call (e.g.
52 * foo(x+y, z^2, t)), it looks up such a table to find out which
53 * function (or class) corresponds to the given name and has the given
54 * number of the arguments.
58 * 1. The function don't have to return a (GiNaC) function or class, it
59 * can return any expression.
60 * 2. Overloaded functions/ctors are paritally supported, i.e. there might
61 * be several functions with the same name, but they should take different
62 * number of arguments.
63 * 3. User can extend the parser via custom prototype tables. It's possible
64 * to read user defined classes, create abbreviations, etc.
66 typedef std::map<prototype, reader_func> prototype_table;
69 * Default prototype table.
71 * It supports most of builtin GiNaC functions.
73 extern const prototype_table& get_default_reader();
77 #endif // _GINAC_PARSE_CONTEXT_HPP