-
Notifications
You must be signed in to change notification settings - Fork 0
/
PreToken.h
56 lines (50 loc) · 951 Bytes
/
PreToken.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
#pragma once
#include "PreTokenType.h"
#include "Position.h"
#include <string>
class PreToken
{
public:
PreToken(PreTokenType type, const Position& position, const std::string& value)
: type(type), position(position), value(value)
{
}
PreTokenType GetType() const
{
return type;
}
const Position& GetPosition() const
{
return position;
}
const std::string& GetValue() const
{
return value;
}
void SetValue(const std::string& value)
{
this->value = value;
}
bool operator==(const PreToken& rhs) const
{
return type == rhs.type && value == rhs.value;
}
bool operator!=(const PreToken& rhs) const
{
return !operator==(rhs);
}
static PreToken EndOfFile()
{
return{ PreTokenType::EndOfFile, { "", 0, 0 }, "" };
}
protected:
void ReplaceToken(PreTokenType type, const std::string& value)
{
this->type = type;
this->value = value;
}
private:
PreTokenType type;
Position position;
std::string value;
};