Enum erg_parser::ast::Expr
source · pub enum Expr {
Show 19 variants
Literal(Literal),
Accessor(Accessor),
Array(Array),
Tuple(Tuple),
Dict(Dict),
Set(Set),
Record(Record),
BinOp(BinOp),
UnaryOp(UnaryOp),
Call(Call),
DataPack(DataPack),
Lambda(Lambda),
TypeAscription(TypeAscription),
Def(Def),
Methods(Methods),
ClassDef(ClassDef),
PatchDef(PatchDef),
ReDef(ReDef),
Dummy(Dummy),
}
Expand description
Expression(式)
Variants§
Literal(Literal)
Accessor(Accessor)
Array(Array)
Tuple(Tuple)
Dict(Dict)
Set(Set)
Record(Record)
BinOp(BinOp)
UnaryOp(UnaryOp)
Call(Call)
DataPack(DataPack)
Lambda(Lambda)
TypeAscription(TypeAscription)
Def(Def)
Methods(Methods)
ClassDef(ClassDef)
PatchDef(PatchDef)
ReDef(ReDef)
Dummy(Dummy)
for mapping to Python AST
Implementations§
source§impl Expr
impl Expr
pub fn is_match_call(&self) -> bool
pub fn is_bin_in(&self) -> bool
pub fn is_const_acc(&self) -> bool
pub const fn is_definition(&self) -> bool
pub const fn name(&self) -> &'static str
pub fn need_to_be_closed(&self) -> bool
pub fn get_name(&self) -> Option<&Str>
pub fn local(name: &str, lineno: u32, col_begin: u32) -> Self
pub fn dummy_local(name: &str) -> Self
pub fn static_local(name: &'static str) -> Self
pub fn attr(self, ident: Identifier) -> Accessor
pub fn attr_expr(self, ident: Identifier) -> Self
pub fn subscr(self, index: Expr, r_sqbr: Token) -> Accessor
pub fn subscr_expr(self, index: Expr, r_sqbr: Token) -> Self
pub fn tuple_attr(self, index: Literal) -> Accessor
pub fn tuple_attr_expr(self, index: Literal) -> Self
pub fn type_app(self, type_args: TypeAppArgs) -> Accessor
pub fn call(self, args: Args) -> Call
pub fn call_expr(self, args: Args) -> Self
pub fn type_asc(self, t_spec: TypeSpecWithOp) -> TypeAscription
pub fn type_asc_expr(self, t_spec: TypeSpecWithOp) -> Self
Trait Implementations§
source§impl From<Identifier> for Expr
impl From<Identifier> for Expr
source§fn from(ident: Identifier) -> Self
fn from(ident: Identifier) -> Self
Converts to this type from the input type.
source§impl From<NormalRecord> for Expr
impl From<NormalRecord> for Expr
source§fn from(record: NormalRecord) -> Self
fn from(record: NormalRecord) -> Self
Converts to this type from the input type.
source§impl From<NormalTuple> for Expr
impl From<NormalTuple> for Expr
source§fn from(tuple: NormalTuple) -> Self
fn from(tuple: NormalTuple) -> Self
Converts to this type from the input type.
source§impl From<TypeAscription> for Expr
impl From<TypeAscription> for Expr
source§fn from(v: TypeAscription) -> Self
fn from(v: TypeAscription) -> Self
Converts to this type from the input type.
source§impl FromIterator<Expr> for Block
impl FromIterator<Expr> for Block
source§impl FromIterator<Expr> for Module
impl FromIterator<Expr> for Module
source§impl Locational for Expr
impl Locational for Expr
source§fn loc(&self) -> Location
fn loc(&self) -> Location
NOTE:
loc
cannot be treated as a light method when self
is a large grammatical element.
If possible, delay the computation by passing &impl Locational
or other means.