![]() |
ArkScript
A small, fast, functional and scripting language for video games
|
A node of an Abstract Syntax Tree for ArkScript. More...
#include <Node.hpp>
Public Types | |
using | Value = std::variant< double, std::string, Keyword > |
Public Member Functions | |
Node ()=default | |
Node (long value) noexcept | |
Construct a new Node object. | |
Node (double value) noexcept | |
Construct a new Node object. | |
Node (const std::string &value) noexcept | |
Construct a new Node object. | |
Node (Keyword value) noexcept | |
Construct a new Node object. | |
Node (NodeType type) noexcept | |
Construct a new Node object, does not set the value. | |
Node (const Node &other) noexcept | |
Construct a new Node object. | |
Node & | operator= (Node other) noexcept |
Construct a new Node object. | |
void | swap (Node &other) noexcept |
Construct a new Node object. | |
const std::string & | string () const noexcept |
Return the string held by the value (if the node type allows it) | |
double | number () const noexcept |
Return the number held by the value (if the node type allows it) | |
Keyword | keyword () const noexcept |
Return the keyword held by the value (if the node type allows it) | |
void | push_back (const Node &node) noexcept |
Every node has a list as well as a value so we can push_back on all node no matter their type. | |
std::vector< Node > & | list () noexcept |
Return the list of sub-nodes held by the node. | |
const std::vector< Node > & | constList () const noexcept |
Return the list of sub-nodes held by the node. | |
NodeType | nodeType () const noexcept |
Return the node type. | |
void | setNodeType (NodeType type) noexcept |
Set the Node Type object. | |
void | setString (const std::string &value) noexcept |
Set the String object. | |
void | setNumber (double value) noexcept |
Set the Number object. | |
void | setKeyword (Keyword kw) noexcept |
Set the Keyword object. | |
void | setPos (std::size_t line, std::size_t col) noexcept |
Set the Position of the node in the text. | |
void | setFilename (const std::string &filename) noexcept |
Set the original Filename where the node was. | |
std::size_t | line () const noexcept |
Get the line at which this node was created. | |
std::size_t | col () const noexcept |
Get the column at which this node was created. | |
const std::string & | filename () const noexcept |
Return the filename in which this node was created. | |
Static Public Member Functions | |
static const Node & | getTrueNode () |
Provide a statically initialized / correct and guaranteed to be initialized Node representing "true". | |
static const Node & | getFalseNode () |
Provide a statically initialized / correct and guaranteed to be initialized Node representing "false". | |
static const Node & | getNilNode () |
Provide a statically initialized / correct and guaranteed to be initialized Node representing "Nil". | |
static const Node & | getListNode () |
Provide a statically initialized / correct and guaranteed to be initialized Node representing "Empty List". | |
Private Member Functions | |
Node (const std::string &value, NodeType const &type) noexcept | |
Construct a new Node object. This is private because it is only used by the static member of this class to generate specialized versions of the node. | |
Private Attributes | |
NodeType | m_type |
Value | m_value |
std::vector< Node > | m_list |
std::size_t | m_line = 0 |
std::size_t | m_col = 0 |
std::string | m_filename = "" |
Friends | |
std::ostream & | operator<< (std::ostream &os, const Node &N) noexcept |
void | swap (Node &lhs, Node &rhs) noexcept |
bool | operator== (const Node &A, const Node &B) |
bool | operator< (const Node &A, const Node &B) |
bool | operator! (const Node &A) |
using Ark::internal::Node::Value = std::variant<double, std::string, Keyword> |
|
default |
|
explicitnoexcept |
|
explicitnoexcept |
|
explicitnoexcept |
|
explicitnoexcept |
|
explicitnoexcept |
|
noexcept |
|
explicitprivatenoexcept |
|
noexcept |
Get the column at which this node was created.
Definition at line 169 of file Node.cpp.
References m_col.
Referenced by Ark::JsonCompiler::_compile(), Ark::internal::make_node(), Ark::internal::make_node_list(), and Ark::internal::makeNodeBasedErrorCtx().
|
noexcept |
Return the list of sub-nodes held by the node.
Definition at line 119 of file Node.cpp.
References m_list.
Referenced by Ark::JsonCompiler::_compile(), Ark::Compiler::_compile(), Ark::internal::ConditionalExecutor::applyMacro(), Ark::internal::FunctionExecutor::applyMacro(), Ark::internal::SymbolExecutor::applyMacro(), Ark::internal::FunctionExecutor::canHandle(), Ark::internal::Parser::checkForInclude(), Ark::Compiler::compileDel(), Ark::Compiler::compileFunction(), Ark::Compiler::compileIf(), Ark::Compiler::compileLetMutSet(), Ark::Compiler::compilePluginImport(), Ark::Compiler::compileQuote(), Ark::Compiler::compileSpecific(), Ark::Compiler::compileWhile(), Ark::internal::Optimizer::countOccurences(), Ark::internal::MacroProcessor::evaluate(), Ark::internal::MacroProcessor::hadBegin(), Ark::Compiler::handleCalls(), Ark::internal::MacroProcessor::isConstEval(), Ark::internal::MacroProcessor::process(), Ark::Compiler::putValue(), Ark::internal::MacroProcessor::registerFuncDef(), Ark::internal::MacroProcessor::registerMacro(), Ark::internal::Optimizer::remove_unused(), Ark::internal::MacroProcessor::removeBegin(), Ark::internal::Optimizer::runOnGlobalScopeVars(), and Ark::JsonCompiler::toJsonList().
|
noexcept |
Return the filename in which this node was created.
Definition at line 174 of file Node.cpp.
References m_filename.
Referenced by Ark::JsonCompiler::_compile(), and Ark::internal::makeNodeBasedErrorCtx().
|
static |
Provide a statically initialized / correct and guaranteed to be initialized Node representing "false".
Definition at line 16 of file Node.cpp.
References Ark::internal::Symbol.
Referenced by Ark::internal::MacroProcessor::evaluate().
|
static |
Provide a statically initialized / correct and guaranteed to be initialized Node representing "Empty List".
Definition at line 28 of file Node.cpp.
References Ark::internal::Symbol.
Referenced by Ark::internal::FunctionExecutor::applyMacro(), and Ark::internal::MacroProcessor::evaluate().
|
static |
Provide a statically initialized / correct and guaranteed to be initialized Node representing "Nil".
Definition at line 22 of file Node.cpp.
References Ark::internal::Symbol.
Referenced by Ark::internal::ConditionalExecutor::applyMacro(), and Ark::internal::MacroProcessor::evaluate().
|
static |
Provide a statically initialized / correct and guaranteed to be initialized Node representing "true".
Definition at line 10 of file Node.cpp.
References Ark::internal::Symbol.
Referenced by Ark::internal::MacroProcessor::evaluate().
|
noexcept |
Return the keyword held by the value (if the node type allows it)
Definition at line 102 of file Node.cpp.
References m_value.
Referenced by Ark::JsonCompiler::_compile(), Ark::internal::ConditionalExecutor::applyMacro(), Ark::internal::Parser::checkForInclude(), Ark::internal::MacroProcessor::registerMacro(), and Ark::internal::MacroProcessor::removeBegin().
|
noexcept |
Get the line at which this node was created.
Definition at line 164 of file Node.cpp.
References m_line.
Referenced by Ark::JsonCompiler::_compile(), Ark::internal::make_node(), Ark::internal::make_node_list(), and Ark::internal::makeNodeBasedErrorCtx().
|
noexcept |
Return the list of sub-nodes held by the node.
Definition at line 114 of file Node.cpp.
References m_list.
Referenced by Ark::internal::ConditionalExecutor::applyMacro(), Ark::internal::FunctionExecutor::applyMacro(), Ark::internal::ConditionalExecutor::canHandle(), Ark::internal::Parser::checkForInclude(), Ark::internal::Optimizer::countOccurences(), Ark::internal::MacroProcessor::evaluate(), Ark::internal::Parser::feed(), Ark::internal::Parser::parseFun(), Ark::internal::Parser::parseLetMut(), Ark::internal::Parser::parseSet(), Ark::internal::Parser::parseShorthand(), Ark::internal::Parser::parseWhile(), Ark::internal::MacroProcessor::process(), Ark::internal::MacroProcessor::recurApply(), Ark::internal::MacroProcessor::registerMacro(), Ark::internal::Optimizer::remove_unused(), Ark::internal::MacroProcessor::removeBegin(), Ark::internal::Optimizer::runOnGlobalScopeVars(), and Ark::internal::MacroProcessor::unify().
|
noexcept |
Return the node type.
Definition at line 126 of file Node.cpp.
References m_type.
Referenced by Ark::JsonCompiler::_compile(), Ark::Compiler::_compile(), Ark::internal::ConditionalExecutor::applyMacro(), Ark::internal::ConditionalExecutor::canHandle(), Ark::internal::FunctionExecutor::canHandle(), Ark::internal::SymbolExecutor::canHandle(), Ark::internal::Parser::checkForInclude(), Ark::internal::Parser::checkForInvalidTokens(), Ark::internal::Optimizer::countOccurences(), Ark::internal::MacroProcessor::evaluate(), Ark::internal::MacroProcessor::hadBegin(), Ark::internal::MacroProcessor::isConstEval(), Ark::internal::MacroProcessor::isTruthy(), Ark::internal::makeNodeBasedErrorCtx(), Ark::internal::Parser::parseShorthand(), Ark::internal::MacroProcessor::process(), Ark::internal::MacroProcessor::recurApply(), Ark::internal::MacroProcessor::registerFuncDef(), Ark::internal::MacroProcessor::registerMacro(), Ark::internal::Optimizer::remove_unused(), Ark::internal::MacroProcessor::removeBegin(), and Ark::internal::MacroProcessor::unify().
|
noexcept |
Return the number held by the value (if the node type allows it)
Definition at line 97 of file Node.cpp.
References m_value.
Referenced by Ark::JsonCompiler::_compile(), Ark::internal::MacroProcessor::evaluate(), and Ark::internal::MacroProcessor::isTruthy().
Construct a new Node object.
other |
Definition at line 72 of file Node.cpp.
References Ark::internal::swap().
|
noexcept |
Every node has a list as well as a value so we can push_back on all node no matter their type.
node | a sub-node to push on the list held by the current node |
Definition at line 109 of file Node.cpp.
Referenced by Ark::internal::MacroProcessor::evaluate(), Ark::internal::Parser::parse(), Ark::internal::Parser::parseBegin(), Ark::internal::Parser::parseDel(), Ark::internal::Parser::parseFun(), Ark::internal::Parser::parseIf(), Ark::internal::Parser::parseImport(), Ark::internal::Parser::parseLetMut(), Ark::internal::Parser::parseQuote(), Ark::internal::Parser::parseSet(), Ark::internal::Parser::parseShorthand(), and Ark::internal::Parser::parseWhile().
|
noexcept |
Set the original Filename where the node was.
filename |
Definition at line 159 of file Node.cpp.
Referenced by Ark::internal::Parser::feed(), Ark::internal::make_node(), and Ark::internal::make_node_list().
|
noexcept |
|
noexcept |
Set the Node Type object.
type |
Definition at line 131 of file Node.cpp.
Referenced by Ark::internal::ConditionalExecutor::applyMacro(), Ark::internal::MacroProcessor::evaluate(), and Ark::internal::MacroProcessor::unify().
|
noexcept |
|
noexcept |
Set the Position of the node in the text.
line | |
col |
Definition at line 153 of file Node.cpp.
Referenced by Ark::internal::make_node(), and Ark::internal::make_node_list().
|
noexcept |
Set the String object.
value |
Definition at line 136 of file Node.cpp.
Referenced by Ark::internal::Parser::atom(), and Ark::internal::MacroProcessor::evaluate().
|
noexcept |
Return the string held by the value (if the node type allows it)
Definition at line 92 of file Node.cpp.
References m_value.
Referenced by Ark::JsonCompiler::_compile(), Ark::Compiler::_compile(), Ark::internal::FunctionExecutor::applyMacro(), Ark::internal::SymbolExecutor::applyMacro(), Ark::Compiler::compileSpecific(), Ark::Compiler::compileSymbol(), Ark::internal::Optimizer::countOccurences(), Ark::internal::MacroProcessor::evaluate(), Ark::internal::MacroProcessor::isConstEval(), Ark::internal::MacroProcessor::isTruthy(), Ark::internal::makeNodeBasedErrorCtx(), Ark::internal::MacroProcessor::registerMacro(), and Ark::internal::MacroProcessor::unify().
|
noexcept |
Construct a new Node object.
other |
Definition at line 78 of file Node.cpp.
References Ark::internal::swap().
|
friend |
|
private |
|
private |
Definition at line 245 of file Node.hpp.
Referenced by filename().
|
private |
|
private |
Definition at line 242 of file Node.hpp.
Referenced by constList(), and list().
|
private |
Definition at line 240 of file Node.hpp.
Referenced by nodeType().
|
private |