MimIR
0.4-dev
MimIR is my Intermediate Representation
Toggle main menu visibility
Loading...
Searching...
No Matches
family.h
Go to the documentation of this file.
1
#pragma once
2
3
/// @file
4
/// Families of Tok::Tag as reusable `case` labels; include this in `*.cpp` files only.
5
/// A family expands to `first: case Tag::second: ...` and hence must be used as `case Tag::C_FAMILY:`.
6
/// Families compose: a family may name another one.
7
/// The including file must provide `using Tag = Tok::Tag;`.
8
9
// clang-format off
10
#define C_PRIMARY \
11
K_Univ: \
12
case Tag::K_Nat: \
13
case Tag::K_Idx: \
14
case Tag::K_Bool: \
15
case Tag::K_ff: \
16
case Tag::K_tt: \
17
case Tag::K_i1: \
18
case Tag::K_i8: \
19
case Tag::K_i16: \
20
case Tag::K_i32: \
21
case Tag::K_i64: \
22
case Tag::K_I1: \
23
case Tag::K_I8: \
24
case Tag::K_I16: \
25
case Tag::K_I32: \
26
case Tag::K_I64: \
27
case Tag::T_star: \
28
case Tag::T_box
29
30
#define C_ID M_id
31
32
#define C_LIT \
33
T_bot: \
34
case Tag::T_top: \
35
case Tag::L_str: \
36
case Tag::L_c: \
37
case Tag::L_s: \
38
case Tag::L_u: \
39
case Tag::L_f: \
40
case Tag::L_i
41
42
/// Numeric literals that a leading sign may be applied to.
43
#define C_LIT_NUM \
44
L_s: \
45
case Tag::L_u: \
46
case Tag::L_f: \
47
case Tag::L_i
48
49
/// Leading sign of a numeric literal.
50
#define C_SIGN \
51
T_add: \
52
case Tag::T_sub
53
54
/// Literals that already determine their type and hence must not be ascribed one.
55
#define C_LIT_TYPED \
56
L_str: \
57
case Tag::L_c: \
58
case Tag::L_i
59
60
#define C_LAM \
61
K_lam: \
62
case Tag::K_con: \
63
case Tag::K_fun
64
65
#define C_RULE \
66
K_norm: \
67
case Tag::K_rule
68
69
#define C_IMPORT \
70
K_import: \
71
case Tag::K_plugin
72
73
#define C_DECL \
74
K_axm: \
75
case Tag::K_let: \
76
case Tag::K_mod: \
77
case Tag::K_rec: \
78
case Tag::K_use: \
79
case Tag::C_IMPORT: \
80
case Tag::C_RULE: \
81
case Tag::C_LAM
82
83
/// Direct-style binders; all other binders are CPS.
84
#define C_DS \
85
T_lm: \
86
case Tag::K_lam
87
88
/// Binders whose domain binds as tight as a `Cn`, i.e. no codomain follows.
89
#define C_CN \
90
K_Cn: \
91
case Tag::K_cn: \
92
case Tag::K_con
93
94
/// Binders that receive an implicit `ret` continuation.
95
#define C_FN \
96
K_Fn: \
97
case Tag::K_fn: \
98
case Tag::K_fun
99
100
#define C_SEQ \
101
D_angle_l: \
102
case Tag::D_quote_l
103
104
#define C_PI \
105
D_brace_l: \
106
case Tag::K_Cn: \
107
case Tag::K_Fn
108
109
#define C_LM \
110
T_lm: \
111
case Tag::K_cn: \
112
case Tag::K_fn
113
114
#define C_EXPR \
115
C_PRIMARY: \
116
case Tag::C_ID: \
117
case Tag::C_LIT: \
118
case Tag::C_DECL: \
119
case Tag::C_PI: \
120
case Tag::C_LM: \
121
case Tag::K_Type:
/*TypeExpr*/
\
122
case Tag::K_Rule:
/*RuleExpr*/
\
123
case Tag::K_match:
/*MatchExpr*/
\
124
case Tag::K_ret:
/*RetExpr*/
\
125
case Tag::C_SEQ:
/*SeqExpr*/
\
126
case Tag::D_brckt_l:
/*SigmaExpr*/
\
127
case Tag::D_curly_l:
/*UniqExpr*/
\
128
case Tag::D_paren_l
/*TupleExpr*/
129
130
#define C_CURRIED_B \
131
D_brace_l: \
132
case Tag::D_brckt_l: \
133
case Tag::D_quote_l
134
135
#define C_CURRIED_P \
136
D_brace_l: \
137
case Tag::D_brckt_l: \
138
case Tag::D_paren_l
139
// clang-format on
140
141
/// Turns such a family into a predicate - a `case` label is of no use outside of a `switch`.
142
#define ISA(tag, family) \
143
([&] { \
144
switch (tag) { \
145
case Tok::Tag::family: return true; \
146
default: return false; \
147
} \
148
}())
src
mim
ast
family.h
Generated by
1.18.0