pub enum Node {
Show 84 variants
Import {
from: Option<Box<AST>>,
import: Vec<AST>,
alias: Vec<AST>,
},
Class {
ty: Box<AST>,
args: Vec<AST>,
parents: Vec<AST>,
body: OptAST,
},
Generic {
id: Box<AST>,
isa: OptAST,
},
Parent {
ty: Box<AST>,
args: Vec<AST>,
},
Reassign {
left: Box<AST>,
right: Box<AST>,
op: NodeOp,
},
VariableDef {
mutable: bool,
var: Box<AST>,
ty: OptAST,
expr: OptAST,
forward: Vec<AST>,
},
FunDef {
pure: bool,
id: Box<AST>,
args: Vec<AST>,
ret: OptAST,
raises: Vec<AST>,
body: OptAST,
},
AnonFun {
args: Vec<AST>,
body: Box<AST>,
},
Raise {
error: Box<AST>,
},
Handle {
expr_or_stmt: Box<AST>,
cases: Vec<AST>,
},
With {
resource: Box<AST>,
alias: Option<(Box<AST>, bool, Option<Box<AST>>)>,
expr: Box<AST>,
},
FunctionCall {
name: Box<AST>,
args: Vec<AST>,
},
PropertyCall {
instance: Box<AST>,
property: Box<AST>,
},
Id {
lit: String,
},
ExpressionType {
expr: Box<AST>,
mutable: bool,
ty: OptAST,
},
TypeDef {
ty: Box<AST>,
isa: OptAST,
body: OptAST,
},
TypeAlias {
ty: Box<AST>,
isa: Box<AST>,
conditions: Vec<AST>,
},
TypeTup {
types: Vec<AST>,
},
TypeUnion {
types: Vec<AST>,
},
Type {
id: Box<AST>,
generics: Vec<AST>,
},
TypeFun {
args: Vec<AST>,
ret_ty: Box<AST>,
},
Condition {
cond: Box<AST>,
el: OptAST,
},
FunArg {
vararg: bool,
mutable: bool,
var: Box<AST>,
ty: OptAST,
default: OptAST,
},
Dict {
elements: Vec<(AST, AST)>,
},
DictBuilder {
from: Box<AST>,
to: Box<AST>,
conditions: Vec<AST>,
},
Set {
elements: Vec<AST>,
},
SetBuilder {
item: Box<AST>,
conditions: Vec<AST>,
},
List {
elements: Vec<AST>,
},
ListBuilder {
item: Box<AST>,
conditions: Vec<AST>,
},
Tuple {
elements: Vec<AST>,
},
Range {
from: Box<AST>,
to: Box<AST>,
inclusive: bool,
step: OptAST,
},
Slice {
from: Box<AST>,
to: Box<AST>,
inclusive: bool,
step: OptAST,
},
Index {
item: Box<AST>,
range: Box<AST>,
},
Block {
statements: Vec<AST>,
},
Real {
lit: String,
},
Int {
lit: String,
},
ENum {
num: String,
exp: String,
},
Str {
lit: String,
expressions: Vec<AST>,
},
DocStr {
lit: String,
},
Bool {
lit: bool,
},
Add {
left: Box<AST>,
right: Box<AST>,
},
AddU {
expr: Box<AST>,
},
Sub {
left: Box<AST>,
right: Box<AST>,
},
SubU {
expr: Box<AST>,
},
Mul {
left: Box<AST>,
right: Box<AST>,
},
Div {
left: Box<AST>,
right: Box<AST>,
},
FDiv {
left: Box<AST>,
right: Box<AST>,
},
Mod {
left: Box<AST>,
right: Box<AST>,
},
Pow {
left: Box<AST>,
right: Box<AST>,
},
Sqrt {
expr: Box<AST>,
},
BAnd {
left: Box<AST>,
right: Box<AST>,
},
BOr {
left: Box<AST>,
right: Box<AST>,
},
BXOr {
left: Box<AST>,
right: Box<AST>,
},
BOneCmpl {
expr: Box<AST>,
},
BLShift {
left: Box<AST>,
right: Box<AST>,
},
BRShift {
left: Box<AST>,
right: Box<AST>,
},
Le {
left: Box<AST>,
right: Box<AST>,
},
Ge {
left: Box<AST>,
right: Box<AST>,
},
Leq {
left: Box<AST>,
right: Box<AST>,
},
Geq {
left: Box<AST>,
right: Box<AST>,
},
Is {
left: Box<AST>,
right: Box<AST>,
},
IsN {
left: Box<AST>,
right: Box<AST>,
},
Eq {
left: Box<AST>,
right: Box<AST>,
},
Neq {
left: Box<AST>,
right: Box<AST>,
},
IsA {
left: Box<AST>,
right: Box<AST>,
},
IsNA {
left: Box<AST>,
right: Box<AST>,
},
Not {
expr: Box<AST>,
},
And {
left: Box<AST>,
right: Box<AST>,
},
Or {
left: Box<AST>,
right: Box<AST>,
},
IfElse {
cond: Box<AST>,
then: Box<AST>,
el: OptAST,
},
Match {
cond: Box<AST>,
cases: Vec<AST>,
},
Case {
cond: Box<AST>,
body: Box<AST>,
},
For {
expr: Box<AST>,
col: Box<AST>,
body: Box<AST>,
},
In {
left: Box<AST>,
right: Box<AST>,
},
While {
cond: Box<AST>,
body: Box<AST>,
},
Break,
Continue,
Return {
expr: Box<AST>,
},
ReturnEmpty,
Underscore,
Undefined,
Pass,
Question {
left: Box<AST>,
right: Box<AST>,
},
QuestionOp {
expr: Box<AST>,
},
}
Variants§
Import
Class
Generic
Parent
Reassign
VariableDef
FunDef
AnonFun
Raise
Handle
With
FunctionCall
PropertyCall
Id
ExpressionType
TypeDef
TypeAlias
TypeTup
TypeUnion
Type
TypeFun
Condition
FunArg
Dict
DictBuilder
Set
SetBuilder
List
ListBuilder
Tuple
Range
Slice
Index
Block
Real
Int
ENum
Str
DocStr
Bool
Add
AddU
Sub
SubU
Mul
Div
FDiv
Mod
Pow
Sqrt
BAnd
BOr
BXOr
BOneCmpl
BLShift
BRShift
Le
Ge
Leq
Geq
Is
IsN
Eq
Neq
IsA
IsNA
Not
And
Or
IfElse
Match
Case
For
In
While
Break
Continue
Return
ReturnEmpty
Underscore
Undefined
Pass
Question
QuestionOp
Implementations§
source§impl Node
impl Node
sourcepub fn map(&self, mapping: &dyn Fn(&Node) -> Node) -> Node
pub fn map(&self, mapping: &dyn Fn(&Node) -> Node) -> Node
Apply mapping to node, before recursively applying mapping to result
pub fn same_value(&self, other: &Node) -> bool
sourcepub fn is_expression(&self) -> bool
pub fn is_expression(&self) -> bool
True if node is an expression with certainty.
If False, then it might still be an expression if for instance it is a function call. In such a case, the type checker must determine if it is an expression.