Enum erg_parser::ast::Expr
source · pub enum Expr {
Show 21 variants
Literal(Literal),
Accessor(Accessor),
List(List),
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),
Compound(Compound),
InlineModule(InlineModule),
Dummy(Dummy),
}
Expand description
Expression(式)
Variants§
Literal(Literal)
Accessor(Accessor)
List(List)
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)
Compound(Compound)
InlineModule(InlineModule)
Dummy(Dummy)
for mapping to Python AST
Implementations§
source§impl Expr
impl Expr
pub fn is_match_call(&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, col_end: 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 call1(self, expr: Expr) -> Self
pub fn call2(self, expr1: Expr, expr2: Expr) -> Self
pub fn type_asc(self, t_spec: TypeSpecWithOp) -> TypeAscription
pub fn type_asc_expr(self, t_spec: TypeSpecWithOp) -> Self
pub fn bin_op(self, op: Token, rhs: Expr) -> BinOp
pub fn unary_op(self, op: Token) -> UnaryOp
sourcepub fn complexity(&self) -> usize
pub fn complexity(&self) -> usize
Return the complexity of the expression in terms of type inference. For function calls, type inference is performed sequentially, starting with the least complex argument.
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<InlineModule> for Expr
impl From<InlineModule> for Expr
source§fn from(v: InlineModule) -> Self
fn from(v: InlineModule) -> 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§impl NestedDisplay for Expr
impl NestedDisplay for Expr
source§impl PartialEq for Expr
impl PartialEq for Expr
source§impl Stream<Expr> for Block
impl Stream<Expr> for Block
fn payload(self) -> Vec<Expr>
fn ref_payload(&self) -> &Vec<Expr>
fn ref_mut_payload(&mut self) -> &mut Vec<Expr>
fn clear(&mut self)
fn len(&self) -> usize
fn size(&self) -> usize
fn is_empty(&self) -> bool
fn insert(&mut self, idx: usize, elem: T)
fn remove(&mut self, idx: usize) -> T
fn push(&mut self, elem: T)
fn append<S>(&mut self, s: &mut S)where
S: Stream<T>,
fn pop(&mut self) -> Option<T>
fn lpop(&mut self) -> Option<T>
fn get(&self, idx: usize) -> Option<&T>
fn get_mut(&mut self, idx: usize) -> Option<&mut T>
fn first(&self) -> Option<&T>
fn first_mut(&mut self) -> Option<&mut T>
fn last(&self) -> Option<&T>
fn last_mut(&mut self) -> Option<&mut T>
fn iter(&self) -> Iter<'_, T>
fn iter_mut(&mut self) -> IterMut<'_, T>
fn take_all(&mut self) -> Vec<T>
fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = T>,
fn split_off(&mut self, at: usize) -> Vec<T>
source§fn retain(&mut self, f: impl FnMut(&T) -> bool)
fn retain(&mut self, f: impl FnMut(&T) -> bool)
Remove all elements that don’t satisfy the predicate.
fn concat(self, other: Self) -> Self
source§impl Stream<Expr> for Compound
impl Stream<Expr> for Compound
fn payload(self) -> Vec<Expr>
fn ref_payload(&self) -> &Vec<Expr>
fn ref_mut_payload(&mut self) -> &mut Vec<Expr>
fn clear(&mut self)
fn len(&self) -> usize
fn size(&self) -> usize
fn is_empty(&self) -> bool
fn insert(&mut self, idx: usize, elem: T)
fn remove(&mut self, idx: usize) -> T
fn push(&mut self, elem: T)
fn append<S>(&mut self, s: &mut S)where
S: Stream<T>,
fn pop(&mut self) -> Option<T>
fn lpop(&mut self) -> Option<T>
fn get(&self, idx: usize) -> Option<&T>
fn get_mut(&mut self, idx: usize) -> Option<&mut T>
fn first(&self) -> Option<&T>
fn first_mut(&mut self) -> Option<&mut T>
fn last(&self) -> Option<&T>
fn last_mut(&mut self) -> Option<&mut T>
fn iter(&self) -> Iter<'_, T>
fn iter_mut(&mut self) -> IterMut<'_, T>
fn take_all(&mut self) -> Vec<T>
fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = T>,
fn split_off(&mut self, at: usize) -> Vec<T>
source§fn retain(&mut self, f: impl FnMut(&T) -> bool)
fn retain(&mut self, f: impl FnMut(&T) -> bool)
Remove all elements that don’t satisfy the predicate.
fn concat(self, other: Self) -> Self
source§impl Stream<Expr> for Dummy
impl Stream<Expr> for Dummy
fn ref_payload(&self) -> &Vec<Expr>
fn ref_mut_payload(&mut self) -> &mut Vec<Expr>
fn payload(self) -> Vec<Expr>
fn clear(&mut self)
fn len(&self) -> usize
fn size(&self) -> usize
fn is_empty(&self) -> bool
fn insert(&mut self, idx: usize, elem: T)
fn remove(&mut self, idx: usize) -> T
fn push(&mut self, elem: T)
fn append<S>(&mut self, s: &mut S)where
S: Stream<T>,
fn pop(&mut self) -> Option<T>
fn lpop(&mut self) -> Option<T>
fn get(&self, idx: usize) -> Option<&T>
fn get_mut(&mut self, idx: usize) -> Option<&mut T>
fn first(&self) -> Option<&T>
fn first_mut(&mut self) -> Option<&mut T>
fn last(&self) -> Option<&T>
fn last_mut(&mut self) -> Option<&mut T>
fn iter(&self) -> Iter<'_, T>
fn iter_mut(&mut self) -> IterMut<'_, T>
fn take_all(&mut self) -> Vec<T>
fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = T>,
fn split_off(&mut self, at: usize) -> Vec<T>
source§fn retain(&mut self, f: impl FnMut(&T) -> bool)
fn retain(&mut self, f: impl FnMut(&T) -> bool)
Remove all elements that don’t satisfy the predicate.
fn concat(self, other: Self) -> Self
source§impl Stream<Expr> for Module
impl Stream<Expr> for Module
fn payload(self) -> Vec<Expr>
fn ref_payload(&self) -> &Vec<Expr>
fn ref_mut_payload(&mut self) -> &mut Vec<Expr>
fn clear(&mut self)
fn len(&self) -> usize
fn size(&self) -> usize
fn is_empty(&self) -> bool
fn insert(&mut self, idx: usize, elem: T)
fn remove(&mut self, idx: usize) -> T
fn push(&mut self, elem: T)
fn append<S>(&mut self, s: &mut S)where
S: Stream<T>,
fn pop(&mut self) -> Option<T>
fn lpop(&mut self) -> Option<T>
fn get(&self, idx: usize) -> Option<&T>
fn get_mut(&mut self, idx: usize) -> Option<&mut T>
fn first(&self) -> Option<&T>
fn first_mut(&mut self) -> Option<&mut T>
fn last(&self) -> Option<&T>
fn last_mut(&mut self) -> Option<&mut T>
fn iter(&self) -> Iter<'_, T>
fn iter_mut(&mut self) -> IterMut<'_, T>
fn take_all(&mut self) -> Vec<T>
fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = T>,
fn split_off(&mut self, at: usize) -> Vec<T>
source§fn retain(&mut self, f: impl FnMut(&T) -> bool)
fn retain(&mut self, f: impl FnMut(&T) -> bool)
Remove all elements that don’t satisfy the predicate.
fn concat(self, other: Self) -> Self
source§impl TryFrom<&ParamListPattern> for Expr
impl TryFrom<&ParamListPattern> for Expr
source§impl TryFrom<&ParamPattern> for Expr
impl TryFrom<&ParamPattern> for Expr
source§impl TryFrom<&ParamTuplePattern> for Expr
impl TryFrom<&ParamTuplePattern> for Expr
impl Eq for Expr
impl StructuralPartialEq for Expr
Auto Trait Implementations§
impl Freeze for Expr
impl RefUnwindSafe for Expr
impl Send for Expr
impl Sync for Expr
impl Unpin for Expr
impl UnwindSafe for Expr
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more