-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoken_entity.cpp
More file actions
64 lines (55 loc) · 1.42 KB
/
token_entity.cpp
File metadata and controls
64 lines (55 loc) · 1.42 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
#include "token_entity.h"
token_entity_t::token_entity_t(const std::string data) : token_t::token_t(data) {}
token_entity_t::token_entity_t(const int data) : token_t::token_t(data) {}
/*
token_entity_t::get_first_hash
Return token_t::hash.
*/
const size_t token_entity_t::get_first_hash() const
{
return hash;
}
/*
token_entity_t::get_rest
Indicate that top-level structure is singular.
*/
const complex_t* const token_entity_t::get_rest() const
{
return nullptr;
}
/*
token_entity_t::get_inner_rest
Indicate that structure height is singular.
*/
const complex_t* const token_entity_t::get_inner_rest() const
{
return nullptr;
}
/*
token_entity_t::find_exact
Return the token if it matches a token exactly.
*/
const complex_t* const token_entity_t::find_exact(const token_t* const token) const
{
return this == token ? this : nullptr;
}
/*
token_entity_t::replace
Return a complex if the token matches another complex.
*/
const complex_t* const token_entity_t::replace(const complex_t* const from, const complex_t* const to) const
{
return equals(this, from) ? to : this;
}
const std::string token_entity_t::to_string() const
{
return token_t::to_string();
}
/*
equals
Hash-based equality operator.
*/
const bool equals(const token_entity_t* const lhs, const token_entity_t* const rhs)
{
return equals((const token_t* const)lhs, (const token_t* const)rhs);
}