[][src]Enum almond::ast::NodeKind

pub enum NodeKind<'a> {
    Identifier {
        name: String,
    },
    Literal {
        value: LiteralValue,
    },
    Program {
        body: Vec<Node<'a>>,
    },
    ExpressionStatement {
        expression: Box<Node<'a>>,
        directive: Option<String>,
    },
    BlockStatement {
        body: Vec<Node<'a>>,
    },
    EmptyStatement,
    DebuggerStatement,
    WithStatement {
        object: Box<Node<'a>>,
        body: Box<Node<'a>>,
    },
    ReturnStatement {
        argument: Box<Option<Node<'a>>>,
    },
    LabeledStatement {
        label: Box<Node<'a>>,
        body: Box<Node<'a>>,
    },
    BreakStatement {
        label: Box<Option<Node<'a>>>,
    },
    ContinueStatement {
        label: Box<Option<Node<'a>>>,
    },
    IfStatement {
        test: Box<Node<'a>>,
        consequent: Box<Node<'a>>,
        alternate: Box<Option<Node<'a>>>,
    },
    SwitchStatement {
        discriminant: Box<Node<'a>>,
        cases: Vec<Node<'a>>,
    },
    SwitchCase {
        test: Box<Option<Node<'a>>>,
        consequent: Vec<Node<'a>>,
    },
    ThrowStatement {
        argument: Box<Node<'a>>,
    },
    TryStatement {
        block: Box<Node<'a>>,
        handler: Box<Option<Node<'a>>>,
        finalizer: Box<Option<Node<'a>>>,
    },
    CatchClause {
        param: Box<Node<'a>>,
        body: Box<Node<'a>>,
    },
    WhileStatement {
        test: Box<Node<'a>>,
        body: Box<Node<'a>>,
    },
    DoWhileStatement {
        body: Box<Node<'a>>,
        test: Box<Node<'a>>,
    },
    ForStatement {
        init: Box<Option<Node<'a>>>,
        test: Box<Option<Node<'a>>>,
        update: Box<Option<Node<'a>>>,
        body: Box<Node<'a>>,
    },
    ForInStatement {
        left: Box<Node<'a>>,
        right: Box<Node<'a>>,
        body: Box<Node<'a>>,
    },
    FunctionDeclaration {
        function: Function<'a>,
    },
    VariableDeclaration {
        declarations: Vec<Node<'a>>,
        kind: VariableDeclarationKind,
    },
    VariableDeclarator {
        id: Box<Node<'a>>,
        init: Box<Option<Node<'a>>>,
    },
    ThisExpression,
    ArrayExpression {
        elements: Vec<Option<Node<'a>>>,
    },
    ObjectExpression {
        properties: Vec<Node<'a>>,
    },
    Property {
        key: Box<Node<'a>>,
        value: Box<Node<'a>>,
        kind: PropertyKind,
    },
    FunctionExpression {
        function: Function<'a>,
    },
    UnaryExpression {
        operator: UnaryOperator,
        prefix: bool,
        argument: Box<Node<'a>>,
    },
    UpdateExpression {
        operator: UpdateOperator,
        argument: Box<Node<'a>>,
        prefix: bool,
    },
    AwaitExpression {
        argument: Box<Node<'a>>,
    },
    BinaryExpression {
        operator: BinaryOperator,
        left: Box<Node<'a>>,
        right: Box<Node<'a>>,
    },
    AssignmentExpression {
        operator: AssignmentOperator,
        left: Box<Node<'a>>,
        right: Box<Node<'a>>,
    },
    LogicalExpression {
        operator: LogicalOperator,
        left: Box<Node<'a>>,
        right: Box<Node<'a>>,
    },
    MemberExpression {
        object: Box<Node<'a>>,
        property: Box<Node<'a>>,
        computed: bool,
    },
    ConditionalExpression {
        test: Box<Node<'a>>,
        consequent: Box<Node<'a>>,
        alternate: Box<Node<'a>>,
    },
    CallExpression {
        callee: Box<Node<'a>>,
        arguments: Vec<Node<'a>>,
    },
    NewExpression {
        callee: Box<Node<'a>>,
        arguments: Vec<Node<'a>>,
    },
    SequenceExpression {
        expressions: Vec<Node<'a>>,
    },
    Pattern,
    Error,
}

A mega enum with ever single possible AST node. Refer to https://github.com/estree/estree/blob/master/es5.md for spec on AST nodes.

Variants

Identifier

An identifier. Note that an identifier may be an expression or a destructuring pattern.

Fields of Identifier

name: String
Literal

A literal token. Note that a literal can be an expression.

Fields of Literal

value: LiteralValue
Program

A complete program source tree.

Fields of Program

body: Vec<Node<'a>>

type: [ Directive | Statement ]

ExpressionStatement

An expression statement, i.e., a statement consisting of a single expression.

or:

A directive from the directive prologue of a script or function. The directive property is the raw string source of the directive without quotes.

Note

There is no separate Directive case in the enum because the ESTree spec describes the Directive node as having a type field of ExpressionStatement.

Fields of ExpressionStatement

expression: Box<Node<'a>>

type: Expression

directive: Option<String>

The raw string source of the directive without quotes. If not a directive, should be None.

BlockStatement

A block statement, i.e., a sequence of statements surrounded by braces.

or:

The body of a function, which is a block statement that may begin with directives.

Note

There is no separate FunctionBody case in the enum because the ESTree spec describes the FunctionBody node as having a type field of BlockStatement.

Fields of BlockStatement

body: Vec<Node<'a>>

type: [ Statement ]

EmptyStatement

An empty statement, i.e., a solitary semicolon.

DebuggerStatement

A debugger statement.

WithStatement

A with statement.

Fields of WithStatement

object: Box<Node<'a>>

type: Expression

body: Box<Node<'a>>

type: Statement

ReturnStatement

A return statement.

Fields of ReturnStatement

argument: Box<Option<Node<'a>>>

type: Expression | null

LabeledStatement

A labeled statement, i.e., a statement prefixed by a break/continue label.

Fields of LabeledStatement

label: Box<Node<'a>>

type: Identifier

body: Box<Node<'a>>

type: Statement

BreakStatement

A break statement.

Fields of BreakStatement

label: Box<Option<Node<'a>>>

type: Identifier | null

ContinueStatement

A continue statement.

Fields of ContinueStatement

label: Box<Option<Node<'a>>>

type: Identifier | null

IfStatement

An if statement.

Fields of IfStatement

test: Box<Node<'a>>

type: Expression

consequent: Box<Node<'a>>

type: Statement

alternate: Box<Option<Node<'a>>>

type: Statement | null

SwitchStatement

A switch statement.

Fields of SwitchStatement

discriminant: Box<Node<'a>>

type: Expression

cases: Vec<Node<'a>>

type: [ SwitchCase ]

SwitchCase

A case (if test is an Expression) or default (if test === null) clause in the body of a switch statement.

Fields of SwitchCase

test: Box<Option<Node<'a>>>

type: Expression | null

consequent: Vec<Node<'a>>

type: [ Statement ]

ThrowStatement

A throw statement.

Fields of ThrowStatement

argument: Box<Node<'a>>

type: Expression

TryStatement

A try statement. If handler is null then finalizer must be a BlockStatement.

Fields of TryStatement

block: Box<Node<'a>>

type: BlockStatement

handler: Box<Option<Node<'a>>>

type: CatchClause | null

finalizer: Box<Option<Node<'a>>>

type: BlockStatement | null

CatchClause

Fields of CatchClause

param: Box<Node<'a>>

type: Pattern

body: Box<Node<'a>>

type: BlockStatement

WhileStatement

A while statement.

Fields of WhileStatement

test: Box<Node<'a>>

type: Expression

body: Box<Node<'a>>

type: Statement

DoWhileStatement

A do/while statement.

Fields of DoWhileStatement

body: Box<Node<'a>>

type: Statement

test: Box<Node<'a>>

type: Expression

ForStatement

A for statement.

Fields of ForStatement

init: Box<Option<Node<'a>>>

type: VariableDeclaration | Expression | null

test: Box<Option<Node<'a>>>

type: Expression | null

update: Box<Option<Node<'a>>>

type: Expression | null

body: Box<Node<'a>>

type: Statement

ForInStatement

A for/in statement.

Fields of ForInStatement

left: Box<Node<'a>>

type: VariableDeclaration | Pattern

right: Box<Node<'a>>

type: Expression

body: Box<Node<'a>>

type: Statement

FunctionDeclaration

A function declaration. Note that unlike in the parent interface Function, the id cannot be null.

Fields of FunctionDeclaration

function: Function<'a>

type: Function

VariableDeclaration

A variable declaration.

Fields of VariableDeclaration

declarations: Vec<Node<'a>>

type: [ VariableDeclarator ]

kind: VariableDeclarationKind
VariableDeclarator

A variable declarator.

Fields of VariableDeclarator

id: Box<Node<'a>>

type: Pattern

init: Box<Option<Node<'a>>>

type: Expression | null

ThisExpression

A this expression.

ArrayExpression

An array expression. An element might be null if it represents a hole in a sparse array. E.g. [1,,2].

Fields of ArrayExpression

elements: Vec<Option<Node<'a>>>

type: [ Expression | null ]

ObjectExpression

An object expression.

Fields of ObjectExpression

properties: Vec<Node<'a>>

type: [ Property ]

Property

A literal property in an object expression can have either a string or number as its value.

Fields of Property

key: Box<Node<'a>>

type: Literal | Identifier

value: Box<Node<'a>>

type: Expression

kind: PropertyKind
FunctionExpression

A function expression.

Fields of FunctionExpression

function: Function<'a>

type: Function

UnaryExpression

An unary operator expression.

Fields of UnaryExpression

operator: UnaryOperatorprefix: boolargument: Box<Node<'a>>

type: Expression

UpdateExpression

An update (increment or decrement) operator expression.

Fields of UpdateExpression

operator: UpdateOperatorargument: Box<Node<'a>>

type: Expression

prefix: bool
AwaitExpression

An await expression.

Fields of AwaitExpression

argument: Box<Node<'a>>

type: Expression

BinaryExpression

A binary operator expression.

Fields of BinaryExpression

operator: BinaryOperatorleft: Box<Node<'a>>

type: Expression

right: Box<Node<'a>>

type: Expression

AssignmentExpression

An assignment operator expression.

Fields of AssignmentExpression

operator: AssignmentOperatorleft: Box<Node<'a>>

type: Pattern | Expression

right: Box<Node<'a>>

type: Expression

LogicalExpression

A logical operator expression.

Fields of LogicalExpression

operator: LogicalOperatorleft: Box<Node<'a>>

type: Expression

right: Box<Node<'a>>

type: Expression

MemberExpression

A member expression. If computed is true, the node corresponds to a computed (a[b]) member expression and property is an Expression. If computed is false, the node corresponds to a static (a.b) member expression and property is an Identifier.

Fields of MemberExpression

object: Box<Node<'a>>

type: Expression

property: Box<Node<'a>>

type: Identifier | Literal

computed: bool
ConditionalExpression

A conditional expression, i.e., a ternary ?/: expression.

Fields of ConditionalExpression

test: Box<Node<'a>>

type: Expression

consequent: Box<Node<'a>>

type: Expression

alternate: Box<Node<'a>>

type: Expression

CallExpression

A function or method call expression.

Fields of CallExpression

callee: Box<Node<'a>>

type: Expression

arguments: Vec<Node<'a>>

type: [ Expression ]

NewExpression

A new expression.

Fields of NewExpression

callee: Box<Node<'a>>

type: Expression

arguments: Vec<Node<'a>>

type: [ Expression ]

SequenceExpression

A sequence expression, i.e., a comma-separated sequence of expressions.

Fields of SequenceExpression

expressions: Vec<Node<'a>>

type: [ Expression ]

Pattern
Error

An error node. Should be used when source is not syntaxically correct.

Implementations

impl<'a> NodeKind<'a>[src]

pub fn with_pos(
    self,
    start: LocatedSpan<&'a str>,
    end: LocatedSpan<&'a str>
) -> Node<'a>
[src]

Creates a Node from NodeKind with specified pos.

Trait Implementations

impl<'a> Clone for NodeKind<'a>[src]

impl<'a> Debug for NodeKind<'a>[src]

impl<'a> From<LiteralValue> for NodeKind<'a>[src]

impl<'a> PartialEq<NodeKind<'a>> for NodeKind<'a>[src]

impl<'a> Serialize for NodeKind<'a>[src]

impl<'a> StructuralPartialEq for NodeKind<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for NodeKind<'a>

impl<'a> Send for NodeKind<'a>

impl<'a> Sync for NodeKind<'a>

impl<'a> Unpin for NodeKind<'a>

impl<'a> UnwindSafe for NodeKind<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Conv for T

impl<T> Conv for T

impl<T> FmtForward for T

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pipe for T where
    T: ?Sized

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<T> Tap for T

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> TryConv for T

impl<T> TryConv for T

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.