-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsymbols.h
73 lines (59 loc) · 2.09 KB
/
symbols.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/**********************************************************************
This file is part of the Quantum Computation Language QCL.
(c) Copyright by Bernhard Oemer <[email protected]>, 1998
This program comes without any warranty; without even the implied
warranty of merchantability or fitness for any particular purpose.
This program is free software under the terms of the
GNU General Public Licence (GPL) version 2 or higher
************************************************************************/
#ifndef SYMBOLS_H
#define SYMBOLS_H 1
#pragma interface
#include "types.h"
class SymTable {
public:
struct entry {
sDef *pdef;
tValue *pval;
entry *pred;
entry *succ;
};
SymTable() { }
virtual ~SymTable() { }
virtual int put(sDef *d,const tValue& v=tValue()) = 0;
virtual tValue getVal(const tId& id,ObjType *o=0) const = 0;
virtual sDef *getDef(const tId& id) const = 0;
virtual tValue *getRef(const tId& id,ObjType *o=0) const = 0;
virtual string prtstr(int ind=NOINDENT) = 0;
void print(ostream& o) { o << prtstr(); }
};
class SymTab : public SymTable {
entry *root;
void deltree(entry *t);
int putentry(entry *t,entry *e);
entry *getentry(entry *t,const tId& id) const;
string recstr(entry *e,int ind=NOINDENT);
int global;
public:
SymTab(int g=0) : SymTable() { root=0; global=g; }
virtual ~SymTab() { if(root) deltree(root); }
virtual int put(sDef *d,const tValue& v=tValue());
virtual tValue getVal(const tId& id,ObjType *o=0) const;
virtual sDef *getDef(const tId& id) const;
virtual tValue *getRef(const tId& id,ObjType *o=0) const;
virtual string prtstr(int ind=NOINDENT);
};
class SymTabComb : public SymTable {
SymTable *tab1;
SymTable *tab2;
public:
SymTabComb(SymTable *t1,SymTable *t2) : SymTable() {
tab1=t1; tab2=t2; }
virtual ~SymTabComb() { };
virtual int put(sDef *d,const tValue& v=tValue());
virtual tValue getVal(const tId& id,ObjType *o=0) const;
virtual sDef *getDef(const tId& id) const;
virtual tValue *getRef(const tId& id,ObjType *o=0) const;
virtual string prtstr(int ind=NOINDENT);
};
#endif