smtparser/smt-parser-defs.h
00001 #ifndef MISTRAL_SMT_PARSER_DEFS_H_
00002 #define MISTRAL_SMT_PARSER_DEFS_H_
00003 
00004 #include "cnode.h"
00005 #include "term.h"
00006 #include <string>
00007 using namespace std;
00008 
00009 union parse_res_union
00010 {
00011   CNode* c;
00012   Term* t;
00013   string* s;
00014 };
00015 
00016 enum PARSE_KIND {PARSE_CNODE, PARSE_TERM, PARSE_STRING};
00017 
00018 struct parse_result
00019 {
00020         PARSE_KIND kind;
00021         parse_res_union res;
00022 };
00023 
00024 
00025 
00026 //typedef parse_result YYSTYPE;
00027 #define YYSTYPE parse_result
00028 
00029 extern YYSTYPE yylval;
00030 
00031 #define YYINITDEPTH 100000
00032 
00033 
00034 extern CNode* smt_res_constraint;
00035 extern Term* smt_res_term;
00036 
00037 extern int smt_curr_lineno;
00038 extern void (*smt_parser_error_fn)(string);
00039 
00040 #endif /* MISTRAL_SMT_PARSER_DEFS_H_ */
00041 
00042 class ScopeTable
00043 {
00044 private:
00045         vector<map<string, Term*> > mappings;
00046 public:
00047 
00048         ScopeTable()
00049         {
00050 
00051         }
00052         void push()
00053         {
00054                 mappings.push_back(map<string, Term*>());
00055         }
00056         void pop() {
00057                 assert(mappings.size() > 0);
00058                 mappings.pop_back();
00059         }
00060         void put(const string & name, Term* t) {
00061                 (*mappings.rbegin())[name] = t;
00062         }
00063         Term* get(const string& name)
00064         {
00065                 vector<map<string, Term*> >::reverse_iterator it = mappings.rbegin();
00066                 for(; it != mappings.rend(); it++) {
00067                         const map<string, Term*> & cur = *it;
00068                         if(cur.count(name) > 0) return cur.find(name)->second;
00069                 }
00070                 return NULL;
00071         }
00072 
00073 };