Struct rcalc::ASTNode [] [src]

pub struct ASTNode { /* fields omitted */ }

Describes a node in an Abstract Syntax Tree.

We can imagine an AST to look like a tree from a root-down approach:

Be careful when using this code, it's not being tested!
AST:
       [Root Token]
  [LToken]    [RToken]
[...]       [...]  [...]

Looking at any node in the tree, we see that it consists of its own value and 0-2 children. Thus, we define an ASTNode to be a Token with up to two neighboring ASTNodes.

Methods

impl ASTNode
[src]

[src]

Creates an ASTNode from a Token and a vector of children nodes.

let token = Token::NUMBER(5);
let children : Vec<ASTNode> = vec![];
let node = ASTNode::from(token, children);

[src]

Returns the token of an ASTNode.

[src]

Returns the children of an ASTNode as a Vec.