]> www.ginac.de Git - ginac.git/commitdiff
parser: allow read/write access to symbol table and strictness.
authorAlexei Sheplyakov <varg@theor.jinr.ru>
Sat, 13 Sep 2008 00:40:12 +0000 (04:40 +0400)
committerAlexei Sheplyakov <varg@theor.jinr.ru>
Fri, 19 Sep 2008 09:15:49 +0000 (13:15 +0400)
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

index a87bcae0457c217d1677e1246c33af2fbccc9c9c..dbe60ee0946bf8fd668b84d485caeefe3408d1bf 100644 (file)
@@ -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