MimIR 0.1
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
autogen.h
Go to the documentation of this file.
1#pragma once
2
3#include <mim/axm.h>
4#include <mim/plugin.h>
5
6/// @namespace mim::plug::regex @ref regex
7namespace mim {
8namespace plug::regex {
9
10static constexpr plugin_t Plugin_Id = 0x4c62066400000000;
11
12/// @name %%regex.conj
13///@{
14enum class conj : flags_t {
15};
16
17const Def* normalize_conj(const Def*, const Def*, const Def*);
18///@}
19
20/// @name %%regex.disj
21///@{
22enum class disj : flags_t {
23};
24
25const Def* normalize_disj(const Def*, const Def*, const Def*);
26///@}
27
28/// @name %%regex.range
29///@{
30enum class range : flags_t {
31};
32
33const Def* normalize_range(const Def*, const Def*, const Def*);
34///@}
35
36/// @name %%regex.lit
37///@{
38enum class lit : flags_t {
39};
40
41///@}
42
43/// @name %%regex.not_
44///@{
45enum class not_ : flags_t {
46};
47
48const Def* normalize_not(const Def*, const Def*, const Def*);
49///@}
50
51/// @name %%regex.neg_lookahead
52///@{
53enum class neg_lookahead : flags_t {
54};
55
56///@}
57
58/// @name %%regex.cls
59///@{
60enum class cls : flags_t {
61 d = 0x4c62066400000600,
62 D = 0x4c62066400000601,
63 w = 0x4c62066400000602,
64 W = 0x4c62066400000603,
65 s = 0x4c62066400000604,
66 S = 0x4c62066400000605,
67};
68
69///@}
70
71/// @name %%regex.any
72///@{
73enum class any : flags_t {
74};
75
76///@}
77
78/// @name %%regex.empty
79///@{
80enum class empty : flags_t {
81};
82
83///@}
84
85/// @name %%regex.quant
86///@{
87enum class quant : flags_t {
88 optional = 0x4c62066400000900,
89 star = 0x4c62066400000901,
90 plus = 0x4c62066400000902,
91};
92
93template<quant>
94const Def* normalize_quant(const Def*, const Def*, const Def*);
95
96///@}
97
98/// @name %%regex.lower_regex
99///@{
100enum class lower_regex : flags_t {
101};
102
103///@}
104
106
107#define MIM_regex_NORMALIZER_IMPL \
108 void register_normalizers(Normalizers& normalizers) {\
109 normalizers[flags_t(Annex::Base<conj>)] = &normalize_conj; \
110 normalizers[flags_t(Annex::Base<disj>)] = &normalize_disj; \
111 normalizers[flags_t(Annex::Base<range>)] = &normalize_range; \
112 normalizers[flags_t(Annex::Base<not_>)] = &normalize_not; \
113 normalizers[flags_t(quant::optional)] = &normalize_quant<quant::optional>; \
114 normalizers[flags_t(quant::star)] = &normalize_quant<quant::star>; \
115 normalizers[flags_t(quant::plus)] = &normalize_quant<quant::plus>; \
116 }
117} // namespace plug::regex
118
119#ifndef DOXYGEN // don't include in Doxygen documentation
120
121template<> constexpr flags_t Annex::Base<plug::regex::conj> = 0x4c62066400000000;
122template<> constexpr size_t Annex::Num<plug::regex::conj> = 0;
123template<> constexpr flags_t Annex::Base<plug::regex::disj> = 0x4c62066400000100;
124template<> constexpr size_t Annex::Num<plug::regex::disj> = 0;
125template<> constexpr flags_t Annex::Base<plug::regex::range> = 0x4c62066400000200;
126template<> constexpr size_t Annex::Num<plug::regex::range> = 0;
127template<> constexpr flags_t Annex::Base<plug::regex::lit> = 0x4c62066400000300;
128template<> constexpr size_t Annex::Num<plug::regex::lit> = 0;
129template<> constexpr flags_t Annex::Base<plug::regex::not_> = 0x4c62066400000400;
130template<> constexpr size_t Annex::Num<plug::regex::not_> = 0;
131template<> constexpr flags_t Annex::Base<plug::regex::neg_lookahead> = 0x4c62066400000500;
132template<> constexpr size_t Annex::Num<plug::regex::neg_lookahead> = 0;
133template<> constexpr flags_t Annex::Base<plug::regex::cls> = 0x4c62066400000600;
134template<> constexpr size_t Annex::Num<plug::regex::cls> = 6;
135template<> constexpr flags_t Annex::Base<plug::regex::any> = 0x4c62066400000700;
136template<> constexpr size_t Annex::Num<plug::regex::any> = 0;
137template<> constexpr flags_t Annex::Base<plug::regex::empty> = 0x4c62066400000800;
138template<> constexpr size_t Annex::Num<plug::regex::empty> = 0;
139template<> constexpr flags_t Annex::Base<plug::regex::quant> = 0x4c62066400000900;
140template<> constexpr size_t Annex::Num<plug::regex::quant> = 3;
141template<> constexpr flags_t Annex::Base<plug::regex::lower_regex> = 0x4c62066400000a00;
142template<> constexpr size_t Annex::Num<plug::regex::lower_regex> = 0;
143
144template<> struct Axm::IsANode<plug::regex::lit> { using type = Axm; };
145template<> struct Axm::IsANode<plug::regex::cls> { using type = Axm; };
146template<> struct Axm::IsANode<plug::regex::any> { using type = Axm; };
147template<> struct Axm::IsANode<plug::regex::empty> { using type = Axm; };
148template<> struct Axm::IsANode<plug::regex::lower_regex> { using type = Axm; };
149
150#endif
151} // namespace mim
152
153#ifndef DOXYGEN // don't include in Doxygen documentation
154
155template<> struct fe::is_bit_enum<mim::plug::regex::cls> : std::true_type {};
156template<> struct fe::is_bit_enum<mim::plug::regex::quant> : std::true_type {};
157
158#endif
Base class for all Defs.
Definition def.h:251
The regex Plugin
Definition lower_regex.h:5
const Def * normalize_conj(const Def *type, const Def *callee, const Def *arg)
static constexpr plugin_t Plugin_Id
Definition autogen.h:10
const Def * normalize_range(const Def *type, const Def *callee, const Def *arg)
void register_normalizers(Normalizers &normalizers)
const Def * normalize_disj(const Def *type, const Def *, const Def *arg)
const Def * normalize_quant(const Def *type, const Def *callee, const Def *arg)
const Def * normalize_not(const Def *, const Def *callee, const Def *arg)
Definition ast.h:14
u64 flags_t
Definition types.h:45
absl::flat_hash_map< flags_t, NormalizeFn > Normalizers
Definition plugin.h:19
u64 plugin_t
Definition types.h:46
@ Axm
Definition def.h:114
static constexpr size_t Num
Number of Axm::subtags.
Definition plugin.h:116
static constexpr flags_t Base
Definition plugin.h:117