X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?a=blobdiff_plain;f=ginac%2Fparser%2Fparse_context.h;h=015ca13517dbce52410fa67a8317030e5a3ce30f;hb=HEAD;hp=e82f8aef2c8ac0eb1ccda16be6ae3854448f0413;hpb=47ecb72dce5ea9c917d1e1e77863c45a8b2b1bba;p=ginac.git diff --git a/ginac/parser/parse_context.h b/ginac/parser/parse_context.h index e82f8aef..015ca135 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-2016 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2024 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 @@ -63,7 +63,21 @@ typedef std::pair prototype; * The parser uses (an associative array of) such functions to construct * (GiNaC) classes and functions from a sequence of characters. */ -typedef ex (*reader_func)(const exvector& args); +class reader_func { + enum { FUNCTION_PTR, GINAC_FUNCTION }; +public: + reader_func(ex (*func_)(const exvector& args)) + : type(FUNCTION_PTR), serial(0), func(func_) {} + reader_func(unsigned serial_) + : type(GINAC_FUNCTION), serial(serial_), func(nullptr) {} + ex operator()(const exvector& args) const; +private: + unsigned type; + unsigned serial; + ex (*func)(const exvector& args); +}; + + /** * Prototype table.