forked from rperlste/UniversalCompiler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathToken.cpp
59 lines (43 loc) · 1.03 KB
/
Token.cpp
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
/*
* Author: Robbie Perlstein
* Student ID: 101130094
* Assignment: Ad Hoc Compiler
*/
#include "Token.h"
Token::Token(){}
Token::Token( TokenEnums tokenType ){
this->tokenType = tokenType;
this->tokenValue = tokenEnumsValues[ tokenType ];
}
Token::Token( TokenEnums tokenType, std::string tokenValue ){
this->tokenType = tokenType;
this->tokenValue = tokenValue;
}
void Token::setTokenType( TokenEnums tokenType ){
this->tokenType = tokenType;
}
TokenEnums Token::getTokenType(){
return tokenType;
}
std::string Token::getTokenTypeString(){
return tokenEnumsStrings[ tokenType ];
}
std::string Token::getTokenValue() {
return tokenValue;
}
void Token::setTokenValue(std::string tokenValue) {
this->tokenValue = tokenValue;
}
bool Token::isTokenType( TokenEnums tokenEnum ){
if( this->tokenType == tokenEnum )
return true;
else
return false;
}
bool Token::operator== ( const Token &other) const{
if( this->tokenType == other.tokenType
&& this->tokenValue == other.tokenValue )
return true;
else
return false;
}