/
Symbol.h
50 lines (48 loc) · 962 Bytes
/
Symbol.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
/*
**
** Symbol.h
** Copyright by Jan Poeschko
**
*/
#include "Atom.h"
#include "Input.h"
#include "Definition.h"
#include "Calculator.h"
#include <string>
using std::cout;
class Symbol : public Atom
{
private:
string name;
Calculator *calculator;
public:
Symbol();
Symbol(string itsName);
virtual ~Symbol();
virtual string Name() const { return name; }
virtual void Name(string theName)
{
name = theName;
}
virtual ExprPtr Clone()
{
return ExprPtr(new Symbol(name));
}
virtual string AtomName()
{
return "Symbol";
}
virtual Definition *GetDefinition(Calculator *calculator)
{
return calculator->Defs().GetDefinition(name);
}
virtual void Print(Calculator *calculator, PrintMode mode);
virtual bool SameExpression(Expression *expression)
{
Symbol *exprSymbol = dynamic_cast<Symbol*>(expression);
if(exprSymbol)
return name == exprSymbol->name;
else
return false;
}
};