-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTokenSource.cpp
More file actions
99 lines (80 loc) · 1.14 KB
/
TokenSource.cpp
File metadata and controls
99 lines (80 loc) · 1.14 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include "Token.h"
#include <string>
#include <algorithm>
using namespace std;
Token::Token(int inopd)
{
opd = inopd;
opr = "";
}
Token::Token(string inopr)
{
opr = inopr;
opd = NULL;
}
int Token::getopd()
{
return opd;
}
void Token::setopd(int inopd)
{
opd = inopd;
}
void Token::setopr(string inopr)
{
opr = inopr;
}
void Token::setanswer(int answer)
{
//return answer;
}
bool Token::isopd()
{
if (opd != NULL)
{
return true;
}
return false;
}
bool Token::isopr()
{
if (opr.length() != 0) {
return true;
}
return false;
}
bool Token::is_binary()
{
vector<string>::iterator it;
it = find(binary.begin(), binary.end(), opr);
if (it != binary.end())
return true;
else
return false;
}
bool Token::is_unary()
{
vector<string>::iterator it;
it = find(unary.begin(), unary.end(), opr);
if (it != unary.end())
return true;
else
return false;
}
char Token::get_type()
{
if (is_binary)
{
return 'B';
}
if (is_unary)
{
return 'U';
}
}
char Token::multiply()
{
char mult = '*';
return mult;
}
//This is a test.