ArkScript
A small, fast, functional and scripting language for video games
Symbol.cpp
Go to the documentation of this file.
2
3namespace Ark::internal
4{
6 {
7 return node.nodeType() == NodeType::Symbol;
8 }
9
11 {
12 if (const Node* macro = findNearestMacro(node.string()); macro != nullptr)
13 {
14 // ($ name value)
15 if (macro->constList().size() == 2)
16 {
17 node = macro->constList()[1];
18 return true;
19 }
20 }
21
22 return false;
23 }
24}
Executor for Symbol Macros.
const Node * findNearestMacro(const std::string &name) const
Find the nearest macro matching a giving name.
Definition: Executor.cpp:12
A node of an Abstract Syntax Tree for ArkScript.
Definition: Node.hpp:30
NodeType nodeType() const noexcept
Return the node type.
Definition: Node.cpp:71
const std::string & string() const noexcept
Return the string held by the value (if the node type allows it)
Definition: Node.cpp:41
const std::vector< Node > & constList() const noexcept
Return the list of sub-nodes held by the node.
Definition: Node.cpp:66
bool applyMacro(Node &node) override
Executes macros in the Node if the Executor can handle it.
Definition: Symbol.cpp:10
bool canHandle(Node &node) override
Checks if the executor can apply a macro on the passed Node.
Definition: Symbol.cpp:5