Module dynparser::ast::flat

source ·
Expand description

Data information to build the Flat AST And some functions to work with it

The AST is a tree, because… it has to be during the parsing and building.

But once the input has been processed, we will want to follow the tree in a specific order.

It’s not complicated visit the elements in a tree, but could be easier if the AST has been “flattened”

In order to flatten the tree, is necessary to add a new kind of node. The end ‘Rule’

Enums

Information of a node when ast has been flattened

Functions

Consume a Node indicating the end of a rule, if it’s a Rule kind with a specific name and return the rest of nodes
Consume a ast::flat::Node if it’s a Rule kind with a specific value and return the rest of nodes
Consume a node if it’s a Val kind and the vaule is equal to the provider one
Given a slice of nodes, return the value (&str) of first node if it is a Node::Val and return the rest of nodes
Get the value of the Node If node is not a Node::Val, it will return an error
It will get the node name of a node if it’s a rule one (begin or end). In other case, it will return an error
Return a reference to first node
Given a list of nodes, return the first and the rest on a tuple