This repository has been archived by the owner on Jan 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils_Token.cpp
81 lines (67 loc) · 1.48 KB
/
utils_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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//
// Created by JacquesdeH on 2020/10/1.
//
#include "utils_Token.h"
Token::Token()
{
this->tkcode = config::EMPTY;
this->tkvalue = "";
this->row = config::ROW_INIT;
this->column = config::COLUMN_INIT;
}
Token::Token(const config::TokenCode &_tkcode, const string &_tkvalue, const int& _row, const int& _column)
{
this->tkcode = _tkcode;
this->tkvalue = _tkvalue;
this->row = _row;
this->column = _column;
}
config::TokenCode Token::getTkcode() const
{
return tkcode;
}
const string &Token::getTkvalue() const
{
return tkvalue;
}
bool Token::isToken(const config::TokenCode &_tkcode) const
{
return _tkcode == this->tkcode;
}
int Token::getRow() const
{
return row;
}
int Token::getColumn() const
{
return column;
}
bool Token::isValuedType() const
{
return tkcode == config::INTTK || tkcode == config::CHARTK;
}
bool Token::isTokens(std::initializer_list<config::TokenCode> _tkcodes) const
{
for (const config::TokenCode _tkcode : _tkcodes)
{
if (this->isToken(_tkcode))
return true;
}
return false;
}
bool Token::isPlusMinusOp() const
{
return isTokens({config::PLUS, config::MINU});
}
bool Token::isMultDivOp() const
{
return isTokens({config::MULT, config::DIV});
}
bool Token::isCmpOp() const
{
return isTokens({config::LSS, config::LEQ, config::GRE, config::GEQ, config::NEQ, config::EQL});
}
bool Token::isLoopKeyword() const
{
return isTokens({config::FORTK, config::WHILETK});
}