37 m_value(
static_cast<double>(value))
65 m_value(other.m_value),
69 m_filename(other.m_filename)
82 swap(m_type, other.m_type);
83 swap(m_value, other.m_value);
84 swap(m_list, other.m_list);
85 swap(m_line, other.m_line);
86 swap(m_col, other.m_col);
87 swap(m_filename, other.m_filename);
94 return std::get<std::string>(
m_value);
99 return std::get<double>(
m_value);
104 return std::get<Keyword>(
m_value);
111 m_list.push_back(node);
161 m_filename = filename;
186 termcolor::magenta });
194 static int index = 0;
199 os <<
'"' << N.string() <<
'"';
203 os <<
"(Symbol) " << N.string();
207 os <<
"(Capture) " << N.string();
211 os <<
"(GetField) " << N.string();
220 os <<
colors[index %
colors.size()] <<
"( " << termcolor::reset;
222 for (
auto& t : N.m_list)
225 os <<
colors[index %
colors.size()] <<
")" << termcolor::reset;
251 os <<
colors[index %
colors.size()] <<
"( " << termcolor::reset <<
"Macro ";
253 for (
auto& t : N.m_list)
256 os <<
colors[index %
colors.size()] <<
")" << termcolor::reset;
261 os <<
"(Spread) " << N.string();
275 std::ostream&
operator<<(std::ostream& os,
const std::vector<Node>& N)
noexcept
295 throw TypeError(
"Can not compare lists");
304 return (
static_cast<int>(A.
nodeType()) -
static_cast<int>(B.
nodeType())) < 0;
334 return A.
string().size() == 0;
ArkScript homemade exceptions.
AST node used by the parser, optimizer and compiler.
A type error triggered when types don't match.
A node of an Abstract Syntax Tree for ArkScript.
NodeType nodeType() const noexcept
Return the node type.
Node & operator=(Node other) noexcept
Construct a new Node object.
static const Node & getListNode()
Provide a statically initialized / correct and guaranteed to be initialized Node representing "Empty ...
void setNodeType(NodeType type) noexcept
Set the Node Type object.
const std::string & filename() const noexcept
Return the filename in which this node was created.
const std::string & string() const noexcept
Return the string held by the value (if the node type allows it)
void setPos(std::size_t line, std::size_t col) noexcept
Set the Position of the node in the text.
const std::vector< Node > & constList() const noexcept
Return the list of sub-nodes held by the node.
std::vector< Node > m_list
void setKeyword(Keyword kw) noexcept
Set the Keyword object.
Keyword keyword() const noexcept
Return the keyword held by the value (if the node type allows it)
void setFilename(const std::string &filename) noexcept
Set the original Filename where the node was.
void setNumber(double value) noexcept
Set the Number object.
static const Node & getNilNode()
Provide a statically initialized / correct and guaranteed to be initialized Node representing "Nil".
std::size_t col() const noexcept
Get the column at which this node was created.
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.
void setString(const std::string &value) noexcept
Set the String object.
static const Node & getTrueNode()
Provide a statically initialized / correct and guaranteed to be initialized Node representing "true".
double number() const noexcept
Return the number held by the value (if the node type allows it)
static const Node & getFalseNode()
Provide a statically initialized / correct and guaranteed to be initialized Node representing "false"...
std::size_t line() const noexcept
Get the line at which this node was created.
friend void swap(Node &lhs, Node &rhs) noexcept
std::vector< Node > & list() noexcept
Return the list of sub-nodes held by the node.
std::ostream & operator<<(std::ostream &os, const std::vector< Node > &N) noexcept
bool operator!(const Node &A)
void swap(Node &lhs, Node &rhs) noexcept
NodeType
The different node types available.
Keyword
The different keywords available.
bool operator<(const Closure &A, const Closure &B) noexcept
bool operator==(const Closure &A, const Closure &B) noexcept