From ef06261c6354bea6d35e8bcdb89806056d4cccb9 Mon Sep 17 00:00:00 2001 From: Alexei Sheplyakov Date: Sat, 13 Sep 2008 04:40:12 +0400 Subject: [PATCH] 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(); } --- ginac/parser/parser.hpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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 -- 2.44.0