![]() |
ArkScript
A small, lisp-inspired, functional scripting language
|
A class that applies macros in a Node. More...
#include <Executor.hpp>
Public Member Functions | |
| MacroExecutor (MacroProcessor *processor, unsigned debug=0) | |
| Construct a new Macro Executor object. | |
| virtual | ~MacroExecutor ()=default |
| Need a virtual destructor to correctly destroy object. | |
| virtual bool | applyMacro (Node &node, unsigned depth)=0 |
| Executes macros in the Node if the Executor can handle it. | |
| virtual bool | canHandle (Node &node)=0 |
| Checks if the executor can apply a macro on the passed Node. | |
| virtual Node | macroNode (Node &node)=0 |
| Returns the macro node that will be expanded. | |
Protected Member Functions | |
| const Node * | findNearestMacro (const std::string &name) const |
| Find the nearest macro matching a giving name. | |
| void | applyMacroProxy (Node &node, unsigned depth) |
| Apply a macro on a given node. | |
| void | handleMacroNode (Node &node) const |
| Registers macros based on their type, expand conditional macros. | |
| bool | isTruthy (const Node &node) const |
| Check if a node can be evaluated to true. | |
| Node | evaluate (Node &node, unsigned depth, bool is_not_body) const |
| Evaluate only the macros. | |
| void | throwMacroProcessingError (const std::string &message, const Node &node) |
| Throw a macro processing error. | |
Protected Attributes | |
| unsigned int | m_debug |
| MacroProcessor * | m_processor |
| This is a non-owned pointer. | |
A class that applies macros in a Node.
Definition at line 27 of file Executor.hpp.
|
explicit |
Construct a new Macro Executor object.
| processor | |
| debug |
Definition at line 7 of file Executor.cpp.
|
virtualdefault |
Need a virtual destructor to correctly destroy object.
|
pure virtual |
Executes macros in the Node if the Executor can handle it.
| node | the node that contains a macro |
| depth |
Implemented in Ark::internal::ConditionalExecutor, Ark::internal::FunctionExecutor, and Ark::internal::SymbolExecutor.
|
protected |
Apply a macro on a given node.
Proxy function for MacroProcessor::applyMacro
| node | |
| depth |
Definition at line 17 of file Executor.cpp.
References Ark::internal::MacroProcessor::applyMacro(), and m_processor.
Referenced by Ark::internal::ConditionalExecutor::applyMacro(), Ark::internal::FunctionExecutor::applyMacro(), and Ark::internal::SymbolExecutor::applyMacro().
|
pure virtual |
Checks if the executor can apply a macro on the passed Node.
| node | the node that contains a macro |
Implemented in Ark::internal::ConditionalExecutor, Ark::internal::FunctionExecutor, and Ark::internal::SymbolExecutor.
|
protected |
Evaluate only the macros.
Proxy function for MacroProcessor::evaluate
| node | |
| depth | |
| is_not_body | true if the method is run on a non-body code (eg a condition of an if-macro) |
Definition at line 32 of file Executor.cpp.
References Ark::internal::MacroProcessor::evaluate(), and m_processor.
Referenced by Ark::internal::ConditionalExecutor::applyMacro(), Ark::internal::FunctionExecutor::applyMacro(), and Ark::internal::SymbolExecutor::applyMacro().
|
nodiscardprotected |
Find the nearest macro matching a giving name.
Proxy function for MacroProcessor::findNearestMacro
| name |
Definition at line 12 of file Executor.cpp.
References Ark::internal::MacroProcessor::findNearestMacro(), and m_processor.
Referenced by Ark::internal::FunctionExecutor::applyMacro(), Ark::internal::SymbolExecutor::applyMacro(), Ark::internal::FunctionExecutor::macroNode(), and Ark::internal::SymbolExecutor::macroNode().
|
protected |
Registers macros based on their type, expand conditional macros.
Validate macros and register them by their name Proxy function for MacroProcessor::handleMacroNode
| node | A node of type Macro |
Definition at line 22 of file Executor.cpp.
References Ark::internal::MacroProcessor::handleMacroNode(), and m_processor.
Referenced by Ark::internal::ConditionalExecutor::applyMacro().
|
nodiscardprotected |
Check if a node can be evaluated to true.
Proxy function for MacroProcessor::isTruthy
| node |
Definition at line 27 of file Executor.cpp.
References Ark::internal::MacroProcessor::isTruthy(), and m_processor.
Referenced by Ark::internal::ConditionalExecutor::applyMacro().
Returns the macro node that will be expanded.
| node | AST node on which the executor will run |
Implemented in Ark::internal::ConditionalExecutor, Ark::internal::FunctionExecutor, and Ark::internal::SymbolExecutor.
|
protected |
Throw a macro processing error.
Proxy function for MacroProcessor::throwMacroProcessingError
| message | the error |
| node | the node in which there is an error |
Definition at line 37 of file Executor.cpp.
References m_processor, and Ark::internal::MacroProcessor::throwMacroProcessingError().
Referenced by Ark::internal::FunctionExecutor::applyMacro(), and Ark::internal::FunctionExecutor::unify().
|
protected |
Definition at line 70 of file Executor.hpp.
|
protected |
This is a non-owned pointer.
Definition at line 71 of file Executor.hpp.
Referenced by applyMacroProxy(), evaluate(), findNearestMacro(), handleMacroNode(), isTruthy(), and throwMacroProcessingError().