Module amethystine::interpret

source ·
Expand description

Amethystine Interpreter

This file handles interpretation of the AST returned from the parser.

Amethystine interprets a given AST into simpler rules that can be traversed and directly edited by the interpreter. These rules are called ReturnValues. They are used to manage everything from variables to function returns.

A new ReturnValue can be created using ReturnValue::new with a given Rule:

ReturnValue::new(Rule::null) // create a null ReturnValue

A ReturnValue must contain a value of type String. This value can represent the content (like in string and number), or it can be empty.

A ReturnValue can also contain children, although this field is optional. The children vec contains an array of the node’s children nodes. This can be used to store data like an array’s elements.

A ReturnValue with a value field beginning with @: is treated as a reassignment. Its children field is expected to contain the new instance of the ReturnValue that it will be replaced with.



Type Aliases