#
Abstract Syntax Tree

Parsing a file using the Ethers ASM Dialect will generate an Abstract Syntax Tree. The root node will always be a ScopeNode whose name is `_`.

To parse a file into an Abstract Syntax tree, use the parse function.

##
Types

###
Location

offset ⇒ number

The offset into the source code to the start of this node.

length ⇒ number

The length of characters in the source code to the end of this node.

source ⇒ string

The source code of this node.

##
Nodes

@TODO: Place a diagram here showing the hierarchy

###
Node
source

node . tag ⇒ string

A unique tag for this node for the lifetime of the process.

node . location ⇒ Location

The source code and location within the source code that this node represents.

###
ValueNode inherits Node
source

A ValueNode is a node which may manipulate the stack.

###
LiteralNode inherits ValueNode
source

literalNode . value ⇒ string

The literal value of this node, which may be a DataHexstring or string of a decimal number.

literalNode . verbatim ⇒ boolean

This is true in a DataNode context, since in that case the value should be taken verbatim and no `PUSH` operation shoud be added, otherwise false.

###
PopNode inherits ValueNode
source

A PopNode is used to store a place-holder for an implicit pop from the stack. It represents the code for an implicit place-holder (i.e. `$$`) or an explicit place-holder (e.g. `$1`), which indicates the expect stack position to consume.

literalNode . index ⇒ number

The index this PopNode is representing. For an implicit place-holder this is `0`.

###
LinkNode inherits ValueNode
source

A LinkNode represents a link to another Node's data, for example `$foo` or `#bar`.

linkNode . label ⇒ string

Te name of the target node.

linkNode . type ⇒ "offset" | "length"

Whether this node is for an offset or a length value of the target node.

###
OpcodeNode inherits ValueNode
source

opcodeNode . opcode ⇒ Opcode

The opcode for this Node.

opcodeNode . operands ⇒ Array<ValueNode>

A list of all operands passed into this Node.

###
EvaluationNode inherits ValueNode
source

An EvaluationNode is used to execute code and insert the results but does not generate any output assembly, using the `{{! code here }}` syntax.

literalNode . verbatim ⇒ boolean

This is true in a DataNode context, since in that case the value should be taken verbatim and no `PUSH` operation shoud be added, otherwise false.

evaluationNode . script ⇒ string

The code to evaluate and produce the result to use as a literal.

###
ExecutionNode inherits Node
source

An ExecutionNode is used to execute code but does not generate any output assembly, using the `{{! code here }}` syntax.

evaluationNode . script ⇒ string

The code to execute. Any result is ignored.

###
LabelledNode inherits Node
source

A LabelledNode is used for any Node that has a name, and can therefore be targetted by a LinkNode.

labelledNode . name ⇒ string

The name of this node.

###
LabelNode inherits LabelledNode
source

A LabelNode is used as a place to `JUMP` to by referencing it name, using `@myLabel:`. A `JUMPDEST` is automatically inserted at the bytecode offset.

###
DataNode inherits LabelledNode
source

A DataNode allows for data to be inserted directly into the output assembly, using `@myData[ ... ]`. The data is padded if needed to ensure values that would otherwise be regarded as a `PUSH` value does not impact anything past the data.

dataNode . data ⇒ Array<ValueNode>

The child nodes, which each represent a verbatim piece of data in insert.

###
ScopeNode inherits LabelledNode
source

A ScopeNode allows a new frame of reference that all LinkNode's will use when resolving offset locations, using `@myScope{ ... }`.

scopeNode . statements ⇒ Array<Node>

The list of child nodes for this scope.

The content of this site is licensed under the Creative Commons Attribution 4.0 International License.