pub enum Expr<A: AstTypes = DefaultTypes> {
Omitted,
Id(A::Path),
MetId(A::MacroId),
Lit(A::Literal),
Use(Use<A>),
Bind(Box<Bind<A>>),
Make(Box<Make<A>>),
Match(Box<Match<A>>),
Op(Op, Vec<At<Self, A>>),
}Expand description
Expressions: The beating heart of Conlang.
A program in Conlang is a single expression which, at compile time, sets up the state in which a program will run. This expression binds types, functions, and values to names which are exposed at runtime.
Whereas in the body of a function, do sequences are ordered, in the global
scope (or subsequent module scopes, which are children of the global module,)
do sequences are considered unordered, and subexpressions may be reordered
in whichever way the compiler sees fit. This is especially important when
performing import resolution, as imports typically depend on the order
in which names are bound.
Variants§
Omitted
Omitted by semicolon insertion-elision rules
Id(A::Path)
An identifier
MetId(A::MacroId)
An escaped token for macro binding
Lit(A::Literal)
A literal bool, string, char, or int
Use(Use<A>)
use Use
Bind(Box<Bind<A>>)
let Pat::NoTopAlt (= expr (else expr)?)? |
(fn | mod | impl) Pat::Fn Expr
Make(Box<Make<A>>)
Expr { (Ident (: Expr)?),* }
Match(Box<Match<A>>)
match Expr { (Pat => Expr),* }
Op(Op, Vec<At<Self, A>>)
Op Expr | Expr Op | Expr (Op Expr)+ | Op Expr Expr else Expr
Implementations§
Source§impl<A: AstTypes> Expr<A>
impl<A: AstTypes> Expr<A>
Sourcepub const fn at(self, annotation: A::Annotation) -> At<Expr<A>, A>
pub const fn at(self, annotation: A::Annotation) -> At<Expr<A>, A>
Attaches this Expr to an At node with the provided Annotation.
Sourcepub fn and_do(self, annotation: A::Annotation, other: At<Expr<A>, A>) -> Self
pub fn and_do(self, annotation: A::Annotation, other: At<Expr<A>, A>) -> Self
Attaches another expression to this one, continuing a do chain if possible.
Sourcepub fn to_tuple(self, annotation: A::Annotation) -> Self
pub fn to_tuple(self, annotation: A::Annotation) -> Self
Turns this expression into a tuple if it isn’t already one.
Sourcepub const fn is_place(&self) -> bool
pub const fn is_place(&self) -> bool
Returns whether self is a “place projection” expression (identifier, index, dot, or deref)
Trait Implementations§
Source§impl<A: AstTypes, B: AstTypes> Foldable<A, B> for Expr<A>
impl<A: AstTypes, B: AstTypes> Foldable<A, B> for Expr<A>
Source§impl<A: AstTypes> Match<A> for Expr<A>
impl<A: AstTypes> Match<A> for Expr<A>
Source§fn recurse(sub: &mut Subst<A>, pat: &Self, expr: &Self) -> bool
fn recurse(sub: &mut Subst<A>, pat: &Self, expr: &Self) -> bool
Source§fn apply_rule(&mut self, pat: &Self, template: &Self) -> bool
fn apply_rule(&mut self, pat: &Self, template: &Self) -> bool
pat to template on self