pub enum AstNode {
Show 34 variants
Program(Vec<AstNodeId>),
VarDecl {
name: String,
init: Option<AstNodeId>,
kind: VarKind,
},
FuncDecl {
name: String,
params: Vec<String>,
body: AstNodeId,
},
Return(Option<AstNodeId>),
If {
condition: AstNodeId,
then_branch: AstNodeId,
else_branch: Option<AstNodeId>,
},
While {
condition: AstNodeId,
body: AstNodeId,
},
For {
init: Option<AstNodeId>,
condition: Option<AstNodeId>,
update: Option<AstNodeId>,
body: AstNodeId,
},
Block(Vec<AstNodeId>),
ExprStatement(AstNodeId),
BinaryExpr {
op: BinOp,
left: AstNodeId,
right: AstNodeId,
},
UnaryExpr {
op: UnaryOp,
operand: AstNodeId,
},
AssignExpr {
target: AstNodeId,
value: AstNodeId,
},
CompoundAssign {
op: BinOp,
target: AstNodeId,
value: AstNodeId,
},
CallExpr {
callee: AstNodeId,
args: Vec<AstNodeId>,
},
MemberExpr {
object: AstNodeId,
property: String,
},
IndexExpr {
object: AstNodeId,
index: AstNodeId,
},
ObjectLiteral(Vec<(String, AstNodeId)>),
ArrayLiteral(Vec<AstNodeId>),
StringLit(String),
NumberLit(JsNumber),
BoolLit(bool),
NullLit,
UndefinedLit,
Identifier(String),
This,
FuncExpr {
params: Vec<String>,
body: AstNodeId,
},
ArrowFunc {
params: Vec<String>,
body: AstNodeId,
},
NewExpr {
callee: AstNodeId,
args: Vec<AstNodeId>,
},
TypeofExpr(AstNodeId),
Throw(AstNodeId),
TryCatch {
try_body: AstNodeId,
catch_param: Option<String>,
catch_body: Option<AstNodeId>,
finally_body: Option<AstNodeId>,
},
Break,
Continue,
Empty,
}Expand description
AST node
Variants§
Program(Vec<AstNodeId>)
Program root: list of top-level statements
VarDecl
Variable declaration: (name, optional initializer)
FuncDecl
Function declaration
Return(Option<AstNodeId>)
Return statement
If
If statement
While
While loop
For
For loop
Fields
Block(Vec<AstNodeId>)
Block statement { … }
ExprStatement(AstNodeId)
Expression statement
BinaryExpr
Binary expression
UnaryExpr
Unary expression
AssignExpr
Assignment expression
CompoundAssign
Compound assignment (+=, -=, etc.)
CallExpr
Function call
MemberExpr
Member access (obj.prop)
IndexExpr
Index access (obj[expr])
ObjectLiteral(Vec<(String, AstNodeId)>)
Object literal { key: value, … }
ArrayLiteral(Vec<AstNodeId>)
Array literal [expr, …]
StringLit(String)
String literal
NumberLit(JsNumber)
Number literal
BoolLit(bool)
Boolean literal
NullLit
Null literal
UndefinedLit
Undefined
Identifier(String)
Identifier reference
This
this keyword
FuncExpr
Function expression
ArrowFunc
Arrow function (params) => body
NewExpr
new Foo(args)
TypeofExpr(AstNodeId)
typeof expr
Throw(AstNodeId)
throw expr
TryCatch
try/catch/finally
Fields
§
catch_param: Option<String>Break
break
Continue
continue
Empty
Empty statement
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AstNode
impl RefUnwindSafe for AstNode
impl Send for AstNode
impl Sync for AstNode
impl Unpin for AstNode
impl UnwindSafe for AstNode
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)