MimIR
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
tok.h File Reference
#include <optional>
#include <string_view>
#include <utility>
#include <fe/assert.h>
#include <fe/format.h>
#include "mim/util/dbg.h"
Include dependency graph for tok.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  mim::ast::Tok

Namespaces

namespace  mim
namespace  mim::ast

Macros

#define CODE(name, ...)
#define CODE(name, assoc)
#define MIM_KEY(m)
#define CODE(t, str)
#define MIM_TOK(m)
#define MIM_SUBST(m)
#define CODE(str, t)
#define CODE(t, str)
#define CODE(str, t)
#define CODE(t, str, prec)
#define CODE(t, str, prec)
Precedence Table

X-macro listing all expression precedences from lowest to highest as m(name, assoc).

assoc is Left-, Right-, or Non-associative; a op b op c is an error for an N level. Only a level named by MIM_INFIX or by an entry below is an actual operator: Err, Bot, Pi, and Lit merely serve as a curr_prec bound while parsing. Application binds tighter than every operator - only Extract and Lit bind tighter still.

#define MIM_PREC(m)
Infix Operator Table

X-macros listing all infix operators as m(tag, str, prec).

#define MIM_INFIX_SUGAR(m)
 a str b is sugar for `str (a, b) ; what `str means is up to whatever the user binds it to.
#define MIM_INFIX_CORE(m)
 These have a meaning of their own; InfixExpr::emit_ dispatches on the tag.
#define MIM_INFIX(m)

Enumerations

enum class  mim::ast::Assoc {
  mim::ast::N ,
  mim::ast::L ,
  mim::ast::R
}
 Associativity of an infix expression. More...
enum class  mim::ast::Prec
 Expression precedences used by the parser and the dumper; ordered low to high. More...

Functions

constexpr Assoc mim::ast::prec_assoc (Prec p)
 Associativity of precedence level p.
constexpr bool mim::ast::is_rassoc (Prec p)
constexpr bool mim::ast::is_lassoc (Prec p)
constexpr bool mim::ast::should_reduce (Prec curr, Prec op)
 Should a Pratt parser reduce when the current binding power is curr and the infix operator has precedence op?

Variables

constexpr auto mim::ast::Num_Keys = size_t(0) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1) + size_t(1)
constexpr auto mim::ast::Num_Subst = size_t(0) + size_t(1) + size_t(1) + size_t(1)

Macro Definition Documentation

◆ CODE [1/8]

#define CODE ( name,
assoc )
Value:
case Prec::name: return Assoc::assoc;

Definition at line 51 of file tok.h.

◆ CODE [2/8]

◆ CODE [3/8]

#define CODE ( str,
t )
Value:
case Tag::t:

Definition at line 51 of file tok.h.

◆ CODE [4/8]

#define CODE ( str,
t )
Value:
+ size_t(1)

Definition at line 51 of file tok.h.

◆ CODE [5/8]

#define CODE ( t,
str )
Value:
t,

Definition at line 51 of file tok.h.

◆ CODE [6/8]

#define CODE ( t,
str )
Value:
+ size_t(1)

Definition at line 51 of file tok.h.

◆ CODE [7/8]

#define CODE ( t,
str,
prec )
Value:
case Tag::t: return "`" str;

Definition at line 51 of file tok.h.

◆ CODE [8/8]

#define CODE ( t,
str,
prec )
Value:
case Tag::t: return Prec::prec;

Definition at line 51 of file tok.h.

◆ MIM_INFIX

#define MIM_INFIX ( m)
Value:
#define MIM_INFIX_SUGAR(m)
a str b is sugar for `str (a, b) ; what `str means is up to whatever the user binds it to.
Definition tok.h:189
#define MIM_INFIX_CORE(m)
These have a meaning of their own; InfixExpr::emit_ dispatches on the tag.
Definition tok.h:205

Definition at line 213 of file tok.h.

Referenced by mim::ast::Tok::infix_prec().

◆ MIM_INFIX_CORE

#define MIM_INFIX_CORE ( m)
Value:
m(T_extract, "#", Extract) \
m(T_union, "∪", Union ) \
m(K_inj, "inj", Inj ) \
m(T_arrow_r, "→", Arrow ) \
m(T_arrow_l, "←", Ins ) \
m(T_at, "@", App )

These have a meaning of their own; InfixExpr::emit_ dispatches on the tag.

Definition at line 205 of file tok.h.

◆ MIM_INFIX_SUGAR

#define MIM_INFIX_SUGAR ( m)
Value:
m(T_eq, "==", Eq ) \
m(T_ne, "!=", Eq ) \
m(T_lt, "<", Rel ) \
m(T_le, "<=", Rel ) \
m(T_gt, ">", Rel ) \
m(T_ge, ">=", Rel ) \
m(T_shl, "<<", Shift) \
m(T_shr, ">>", Shift) \
m(T_add, "+", Add ) \
m(T_sub, "-", Add ) \
m(T_star, "*", Mul ) \
m(T_div, "/", Mul ) \
m(T_rem, "%", Mul )

a str b is sugar for `str (a, b) ; what `str means is up to whatever the user binds it to.

Definition at line 189 of file tok.h.

Referenced by mim::ast::Tok::infix_sym().

◆ MIM_KEY

#define MIM_KEY ( m)

Definition at line 75 of file tok.h.

Referenced by mim::Driver::Driver(), and mim::ast::Tok::tag2str().

◆ MIM_PREC

#define MIM_PREC ( m)
Value:
m(Err, N) \
m(Bot, N) \
m(Where, L) \
m(Ins, R) \
m(Inj, R) \
m(Union, L) \
m(Arrow, R) \
m(Pi, N) \
m(Eq, N) \
m(Rel, N) \
m(Add, L) \
m(Mul, L) \
m(Shift, L) \
m(App, L) \
m(Extract, L) \
m(Lit, N)

Definition at line 26 of file tok.h.

Referenced by mim::ast::prec_assoc().

◆ MIM_SUBST

#define MIM_SUBST ( m)
Value:
m("lm", T_lm ) \
m("bot", T_bot ) \
m("top", T_top ) \

Definition at line 216 of file tok.h.

Referenced by mim::Driver::Driver(), and mim::ast::Tok::is_key().

◆ MIM_TOK

#define MIM_TOK ( m)

Definition at line 128 of file tok.h.

Referenced by mim::ast::Tok::tag2str().