This repository was archived by the owner on Nov 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtoken.hpp
More file actions
59 lines (48 loc) · 1.38 KB
/
token.hpp
File metadata and controls
59 lines (48 loc) · 1.38 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
#ifndef LIB_RUBY_PARSER_TOKEN_HPP
#define LIB_RUBY_PARSER_TOKEN_HPP
#include <string>
#include "bytes.hpp"
#include "loc.hpp"
#include "token_ids.hpp"
namespace lib_ruby_parser
{
/// Equivalent of `lib_ruby_parser::Token`
class Token
{
public:
int32_t token_type;
Bytes token_value;
Loc loc;
int32_t lex_state_before;
int32_t lex_state_after;
Token() = delete;
Token(
int32_t token_type,
Bytes token_value,
Loc loc,
int32_t lex_state_before,
int32_t lex_state_after);
Token(const Token &) = delete;
Token &operator=(Token const &) = delete;
Token(Token &&) = default;
Token &operator=(Token &&) = default;
/// Returns token name (like "kDEF") for a given token.
std::string token_name() const;
};
/// Equivalent of `Vec<lib_ruby_parser::Token>`
class TokenList
{
public:
Token *ptr;
size_t capacity;
size_t len;
TokenList() = delete;
TokenList(Token *ptr, size_t len, size_t capacity);
~TokenList();
TokenList(const TokenList &) = delete;
TokenList &operator=(TokenList const &) = delete;
TokenList(TokenList &&);
TokenList &operator=(TokenList &&);
};
} // namespace lib_ruby_parser
#endif // LIB_RUBY_PARSER_TOKEN_HPP