34 m(K_extern, "extern") \
43 m(K_import, "import") \
48 m(K_match, "match" ) \
49 m(K_module, "module") \
50 m(K_plugin, "plugin") \
54 m(K_where, "where" ) \
57#define CODE(t, str) + size_t(1)
62 m(EoF, "<end of file>" ) \
64 m(L_s, "<signed integer literal>") \
65 m(L_u, "<integer literal>" ) \
66 m(L_i, "<index literal>" ) \
67 m(L_f, "<floating-point literal>") \
68 m(L_c, "<char literal>" ) \
69 m(L_str, "<string literal>" ) \
71 m(M_id, "<identifier>" ) \
72 m(M_anx, "<annex name>" ) \
88 m(T_fat_arrow, "=>") \
100 m(T_semicolon, ";") \
104#define MIM_SUBST(m) \
108 m("insert", K_ins ) \
116#define CODE(t, str) t,
142 , u_(
std::bit_cast<uint64_t>(s)) {}
146 , u_(
std::bit_cast<uint64_t>(d)) {}
155 assert(
tag == Tag::M_id ||
tag == Tag::M_anx ||
tag == Tag::L_str);
161 Loc
loc()
const {
return loc_; }
162 explicit operator bool()
const {
return tag_ != Tag::Nil; }
165 char8_t lit_c()
const { assert(
isa(Tag::L_c));
return c_; }
166 uint64_t
lit_u()
const { assert(
isa(Tag::L_u ) ||
isa(Tag::L_s ) ||
isa(Tag::L_f ));
return u_; }
167 Sym
sym()
const { assert(
isa(Tag::M_anx) ||
isa(Tag::M_id) ||
isa(Tag::L_str));
return sym_; }
169 std::string
str()
const;
friend std::ostream & operator<<(std::ostream &, Tok)
const Lit * lit_i() const
Tok(Loc loc, Tag tag, Sym sym)
Tok(Loc loc, const Lit *i)
static constexpr Tok::Tag delim_l2r(Tag tag)
friend std::ostream & operator<<(std::ostream &os, Tok::Tag tag)
static const char * tag2str(Tok::Tag)