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_rewriter.hpp
More file actions
73 lines (58 loc) · 1.47 KB
/
token_rewriter.hpp
File metadata and controls
73 lines (58 loc) · 1.47 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
65
66
67
68
69
70
71
72
73
#ifndef LIB_RUBY_PARSER_TOKEN_REWRITER_HPP
#define LIB_RUBY_PARSER_TOKEN_REWRITER_HPP
#include <cstdint>
#include <cstdbool>
#include "token.hpp"
#include "shared_byte_list.hpp"
namespace lib_ruby_parser
{
enum class RewriteAction
{
DROP,
KEEP
};
class LexStateAction
{
public:
enum class Tag
{
SET,
KEEP
};
union Value
{
int32_t set;
};
Tag tag;
Value as;
};
class TokenRewriterResult
{
public:
Token *rewritten_token;
RewriteAction token_action;
LexStateAction lex_state_action;
TokenRewriterResult(const TokenRewriterResult &) = default;
TokenRewriterResult &operator=(TokenRewriterResult const &) = default;
~TokenRewriterResult();
};
class TokenRewriter;
typedef TokenRewriterResult (*TokenRewriterFunction)(Token *, SharedByteList);
class TokenRewriter
{
public:
TokenRewriterFunction f;
explicit TokenRewriter(TokenRewriterFunction f);
};
class MaybeTokenRewriter
{
public:
TokenRewriter token_rewriter;
explicit MaybeTokenRewriter(TokenRewriter token_rewriter);
bool is_some() const;
bool is_none() const;
static MaybeTokenRewriter Some(TokenRewriter decoder);
static MaybeTokenRewriter None();
};
} // namespace lib_ruby_parser
#endif // LIB_RUBY_PARSER_TOKEN_REWRITER_HPP