From: Alexei Sheplyakov Date: Sat, 13 Sep 2008 00:40:12 +0000 (+0400) Subject: parser: allow read/write access to symbol table and strictness. X-Git-Tag: release_1-5-0~59^2~11 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=commitdiff_plain;h=ef06261c6354bea6d35e8bcdb89806056d4cccb9 parser: allow read/write access to symbol table and strictness. Intended usage: parser reader; ifstream input_file1, input_file2; // read the first file... ex e1 = reader(input_file1); // ... add extra entry into the symbol table used by parser symbol x; parser.get_syms()["x"] = x; // Disable the parser to introduce new symbols, e.g. to ensure the expression // in input_file2 contains the same symbols as e1 (read from input_file1). parser.strict = true; ex e2; try { e2 = reader(input_file2); } catch (...) { abort(); } --- diff --git a/ginac/parser/parser.hpp b/ginac/parser/parser.hpp index a87bcae0..dbe60ee0 100644 --- a/ginac/parser/parser.hpp +++ b/ginac/parser/parser.hpp @@ -76,10 +76,15 @@ public: { return syms; } + /// read/write access to the symbol table + symtab& get_syms() + { + return syms; + } -private: /// If true, throw an exception if an unknown symbol is encountered. - const bool strict; + bool strict; +private: /** * Function/ctor table, maps a prototype (which is a name and number * arguments) to a C++ function. Used for parsing identifier_expr's