X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?a=blobdiff_plain;f=ginac%2Fparser%2Fparse_context.h;h=fe844127a35621f8030d0f7d1cab392285c350d1;hb=0b985d5336debdd396f0fbeca8df850af5f569f4;hp=3516320981c1b82191c404361d6086e4a6cd96f6;hpb=3aec0ba298693329c1194e547043fef1a78b1b0d;p=ginac.git diff --git a/ginac/parser/parse_context.h b/ginac/parser/parse_context.h index 35163209..fe844127 100644 --- a/ginac/parser/parse_context.h +++ b/ginac/parser/parse_context.h @@ -3,7 +3,7 @@ * Interface to parser context. */ /* - * GiNaC Copyright (C) 1999-2010 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2015 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -82,15 +82,39 @@ typedef ex (*reader_func)(const exvector& args); * 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; +class PrototypeLess +{ +public: + bool operator()(const prototype& p1, const prototype& p2) const + { + int s = p1.first.compare(p2.first); + if (s == 0) { + if ((p1.second == 0) || (p2.second == 0)) return false; + return p1.second < p2.second; + } + return s < 0; + } +}; +typedef std::map 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