diff --git a/include/chaiscript/dispatchkit/bootstrap.hpp b/include/chaiscript/dispatchkit/bootstrap.hpp index 8d0fab1..d61f338 100644 --- a/include/chaiscript/dispatchkit/bootstrap.hpp +++ b/include/chaiscript/dispatchkit/bootstrap.hpp @@ -210,41 +210,41 @@ namespace chaiscript */ static void opers_arithmetic_pod(ModulePtr m = ModulePtr(new Module())) { - m->add(fun(&Boxed_Number::operator&=), "&="); - m->add(fun(&Boxed_Number::operator|=), "|="); - m->add(fun(&Boxed_Number::operator%=), "%="); - m->add(fun(&Boxed_Number::operator^=), "^="); - m->add(fun(&Boxed_Number::operator<<=), "<<="); - m->add(fun(&Boxed_Number::operator>>=), ">>="); + m->add(fun(&Boxed_Number::equals), "=="); + m->add(fun(&Boxed_Number::less_than), "<"); + m->add(fun(&Boxed_Number::greater_than), ">"); + m->add(fun(&Boxed_Number::greater_than_equal), ">="); + m->add(fun(&Boxed_Number::less_than_equal), "<="); + m->add(fun(&Boxed_Number::not_equal), "!="); - m->add(fun(&Boxed_Number::operator&), "&"); - m->add(fun(&Boxed_Number::operator~), "~"); - m->add(fun(&Boxed_Number::operator^), "^"); - m->add(fun(&Boxed_Number::operator|), "|"); - m->add(fun(&Boxed_Number::operator<<), "<<"); - m->add(fun(&Boxed_Number::operator%), "%"); - m->add(fun(&Boxed_Number::operator>>), ">>"); + m->add(fun(&Boxed_Number::pre_decrement), "--"); + m->add(fun(&Boxed_Number::pre_increment), "++"); + m->add(fun(&Boxed_Number::sum), "+"); + m->add(fun(&Boxed_Number::unary_plus), "+"); + m->add(fun(&Boxed_Number::unary_minus), "-"); + m->add(fun(&Boxed_Number::difference), "-"); + m->add(fun(&Boxed_Number::assign_bitwise_and), "&="); + m->add(fun(&Boxed_Number::assign), "="); + m->add(fun(&Boxed_Number::assign_bitwise_or), "|="); + m->add(fun(&Boxed_Number::assign_bitwise_xor), "^="); + m->add(fun(&Boxed_Number::assign_remainder), "%="); + m->add(fun(&Boxed_Number::assign_shift_left), "<<="); + m->add(fun(&Boxed_Number::assign_shift_right), ">>="); + m->add(fun(&Boxed_Number::bitwise_and), "&"); + m->add(fun(&Boxed_Number::bitwise_complement), "~"); + m->add(fun(&Boxed_Number::bitwise_xor), "^"); + m->add(fun(&Boxed_Number::bitwise_or), "|"); + m->add(fun(&Boxed_Number::assign_product), "*="); + m->add(fun(&Boxed_Number::assign_quotient), "/="); + m->add(fun(&Boxed_Number::assign_sum), "+="); + m->add(fun(&Boxed_Number::assign_difference), "-="); + m->add(fun(&Boxed_Number::quotient), "/"); + m->add(fun(&Boxed_Number::shift_left), "<<"); + m->add(fun(&Boxed_Number::product), "*"); + m->add(fun(&Boxed_Number::remainder), "%"); + m->add(fun(&Boxed_Number::shift_right), ">>"); - m->add(fun(&Boxed_Number::operator=), "="); - m->add(fun(&Boxed_Number::operator*=), "*="); - m->add(fun(&Boxed_Number::operator/=), "/="); - m->add(fun(&Boxed_Number::operator+=), "+="); - m->add(fun(&Boxed_Number::operator-=), "-="); - m->add(fun(&Boxed_Number::operator--), "--"); - m->add(fun(&Boxed_Number::operator++), "++"); - m->add(fun(&Boxed_Number::operator/), "/"); - m->add(fun(&Boxed_Number::operator*), "*"); - m->add(fun(&Boxed_Number::operator+), "+"); - m->add(fun(&Boxed_Number::operator-), "-"); - m->add(fun(&Boxed_Number::operator+), "+"); - m->add(fun(&Boxed_Number::operator-), "-"); - m->add(fun(&Boxed_Number::operator==), "=="); - m->add(fun(&Boxed_Number::operator>), ">"); - m->add(fun(&Boxed_Number::operator>=), ">="); - m->add(fun(&Boxed_Number::operator<), "<"); - m->add(fun(&Boxed_Number::operator<=), "<="); - m->add(fun(&Boxed_Number::operator!=), "!="); } /** diff --git a/include/chaiscript/dispatchkit/boxed_number.hpp b/include/chaiscript/dispatchkit/boxed_number.hpp index 81b1f12..a5f6b50 100644 --- a/include/chaiscript/dispatchkit/boxed_number.hpp +++ b/include/chaiscript/dispatchkit/boxed_number.hpp @@ -7,13 +7,9 @@ #ifndef CHAISCRIPT_BOXED_NUMERIC_HPP_ #define CHAISCRIPT_BOXED_NUMERIC_HPP_ -#include "type_info.hpp" #include "boxed_value.hpp" -#include "boxed_cast_helper.hpp" -#include "../language/chaiscript_common.hpp" -#include +#include "../language/chaiscript_algebraic.hpp" #include -#include namespace chaiscript { @@ -347,133 +343,296 @@ namespace chaiscript return boxed_cast(oper(Operators::not_equal, this->bv, t_rhs.bv)); } - Boxed_Value operator--() const + Boxed_Number operator--() { return oper(Operators::pre_decrement, this->bv, var(0)); } - Boxed_Value operator++() const + Boxed_Number operator++() { return oper(Operators::pre_increment, this->bv, var(0)); } - Boxed_Value operator+(const Boxed_Number &t_rhs) const + Boxed_Number operator+(const Boxed_Number &t_rhs) const { return oper(Operators::sum, this->bv, t_rhs.bv); } - Boxed_Value operator+() const + Boxed_Number operator+() const { return oper(Operators::unary_plus, this->bv, Boxed_Value(0)); } - Boxed_Value operator-() const + Boxed_Number operator-() const { return oper(Operators::unary_minus, this->bv, Boxed_Value(0)); } - Boxed_Value operator-(const Boxed_Number &t_rhs) const + Boxed_Number operator-(const Boxed_Number &t_rhs) const { return oper(Operators::difference, this->bv, t_rhs.bv); } - Boxed_Value operator&=(const Boxed_Number &t_rhs) const + Boxed_Number operator&=(const Boxed_Number &t_rhs) { return oper(Operators::assign_bitwise_and, this->bv, t_rhs.bv); } - Boxed_Value operator=(const Boxed_Number &t_rhs) const + Boxed_Number operator=(const Boxed_Number &t_rhs) const { return oper(Operators::assign, this->bv, t_rhs.bv); } - Boxed_Value operator|=(const Boxed_Number &t_rhs) const + Boxed_Number operator|=(const Boxed_Number &t_rhs) { return oper(Operators::assign_bitwise_or, this->bv, t_rhs.bv); } - Boxed_Value operator^=(const Boxed_Number &t_rhs) const + Boxed_Number operator^=(const Boxed_Number &t_rhs) { return oper(Operators::assign_bitwise_xor, this->bv, t_rhs.bv); } - Boxed_Value operator%=(const Boxed_Number &t_rhs) const + Boxed_Number operator%=(const Boxed_Number &t_rhs) { return oper(Operators::assign_remainder, this->bv, t_rhs.bv); } - Boxed_Value operator<<=(const Boxed_Number &t_rhs) const + Boxed_Number operator<<=(const Boxed_Number &t_rhs) { return oper(Operators::assign_shift_left, this->bv, t_rhs.bv); } - Boxed_Value operator>>=(const Boxed_Number &t_rhs) const + Boxed_Number operator>>=(const Boxed_Number &t_rhs) { return oper(Operators::assign_shift_right, this->bv, t_rhs.bv); } - Boxed_Value operator&(const Boxed_Number &t_rhs) const + Boxed_Number operator&(const Boxed_Number &t_rhs) const { return oper(Operators::bitwise_and, this->bv, t_rhs.bv); } - Boxed_Value operator~() const + Boxed_Number operator~() const { return oper(Operators::bitwise_complement, this->bv, Boxed_Value(0)); } - Boxed_Value operator^(const Boxed_Number &t_rhs) const + Boxed_Number operator^(const Boxed_Number &t_rhs) const { return oper(Operators::bitwise_xor, this->bv, t_rhs.bv); } - Boxed_Value operator|(const Boxed_Number &t_rhs) const + Boxed_Number operator|(const Boxed_Number &t_rhs) const { return oper(Operators::bitwise_or, this->bv, t_rhs.bv); } - Boxed_Value operator*=(const Boxed_Number &t_rhs) const + Boxed_Number operator*=(const Boxed_Number &t_rhs) { return oper(Operators::assign_product, this->bv, t_rhs.bv); } - Boxed_Value operator/=(const Boxed_Number &t_rhs) const + Boxed_Number operator/=(const Boxed_Number &t_rhs) { return oper(Operators::assign_quotient, this->bv, t_rhs.bv); } - Boxed_Value operator+=(const Boxed_Number &t_rhs) const + Boxed_Number operator+=(const Boxed_Number &t_rhs) { return oper(Operators::assign_sum, this->bv, t_rhs.bv); } - Boxed_Value operator-=(const Boxed_Number &t_rhs) const + Boxed_Number operator-=(const Boxed_Number &t_rhs) { return oper(Operators::assign_difference, this->bv, t_rhs.bv); } - Boxed_Value operator/(const Boxed_Number &t_rhs) const + Boxed_Number operator/(const Boxed_Number &t_rhs) const { return oper(Operators::quotient, this->bv, t_rhs.bv); } - Boxed_Value operator<<(const Boxed_Number &t_rhs) const + Boxed_Number operator<<(const Boxed_Number &t_rhs) const { return oper(Operators::shift_left, this->bv, t_rhs.bv); } - Boxed_Value operator*(const Boxed_Number &t_rhs) const + Boxed_Number operator*(const Boxed_Number &t_rhs) const { return oper(Operators::product, this->bv, t_rhs.bv); } - Boxed_Value operator%(const Boxed_Number &t_rhs) const + Boxed_Number operator%(const Boxed_Number &t_rhs) const { return oper(Operators::remainder, this->bv, t_rhs.bv); } - Boxed_Value operator>>(const Boxed_Number &t_rhs) const + Boxed_Number operator>>(const Boxed_Number &t_rhs) const { return oper(Operators::shift_right, this->bv, t_rhs.bv); } + + + static bool equals(const Boxed_Number &t_lhs, const Boxed_Number &t_rhs) + { + return boxed_cast(oper(Operators::equals, t_lhs.bv, t_rhs.bv)); + } + + static bool less_than(const Boxed_Number &t_lhs, const Boxed_Number &t_rhs) + { + return boxed_cast(oper(Operators::less_than, t_lhs.bv, t_rhs.bv)); + } + + static bool greater_than(const Boxed_Number &t_lhs, const Boxed_Number &t_rhs) + { + return boxed_cast(oper(Operators::greater_than, t_lhs.bv, t_rhs.bv)); + } + + static bool greater_than_equal(const Boxed_Number &t_lhs, const Boxed_Number &t_rhs) + { + return boxed_cast(oper(Operators::greater_than_equal, t_lhs.bv, t_rhs.bv)); + } + + static bool less_than_equal(const Boxed_Number &t_lhs, const Boxed_Number &t_rhs) + { + return boxed_cast(oper(Operators::less_than_equal, t_lhs.bv, t_rhs.bv)); + } + + static bool not_equal(const Boxed_Number &t_lhs, const Boxed_Number &t_rhs) + { + return boxed_cast(oper(Operators::not_equal, t_lhs.bv, t_rhs.bv)); + } + + static Boxed_Number pre_decrement(Boxed_Number t_lhs) + { + return oper(Operators::pre_decrement, t_lhs.bv, var(0)); + } + + static Boxed_Number pre_increment(Boxed_Number t_lhs) + { + return oper(Operators::pre_increment, t_lhs.bv, var(0)); + } + + static const Boxed_Number sum(const Boxed_Number &t_lhs, const Boxed_Number &t_rhs) + { + return oper(Operators::sum, t_lhs.bv, t_rhs.bv); + } + + static const Boxed_Number unary_plus(const Boxed_Number &t_lhs) + { + return oper(Operators::unary_plus, t_lhs.bv, Boxed_Value(0)); + } + + static const Boxed_Number unary_minus(const Boxed_Number &t_lhs) + { + return oper(Operators::unary_minus, t_lhs.bv, Boxed_Value(0)); + } + + static const Boxed_Number difference(const Boxed_Number &t_lhs, const Boxed_Number &t_rhs) + { + return oper(Operators::difference, t_lhs.bv, t_rhs.bv); + } + + static Boxed_Number assign_bitwise_and(Boxed_Number t_lhs, const Boxed_Number &t_rhs) + { + return oper(Operators::assign_bitwise_and, t_lhs.bv, t_rhs.bv); + } + + static Boxed_Number assign(Boxed_Number t_lhs, const Boxed_Number &t_rhs) + { + return oper(Operators::assign, t_lhs.bv, t_rhs.bv); + } + + static Boxed_Number assign_bitwise_or(Boxed_Number t_lhs, const Boxed_Number &t_rhs) + { + return oper(Operators::assign_bitwise_or, t_lhs.bv, t_rhs.bv); + } + + static Boxed_Number assign_bitwise_xor(Boxed_Number t_lhs, const Boxed_Number &t_rhs) + { + return oper(Operators::assign_bitwise_xor, t_lhs.bv, t_rhs.bv); + } + + static Boxed_Number assign_remainder(Boxed_Number t_lhs, const Boxed_Number &t_rhs) + { + return oper(Operators::assign_remainder, t_lhs.bv, t_rhs.bv); + } + + static Boxed_Number assign_shift_left(Boxed_Number t_lhs, const Boxed_Number &t_rhs) + { + return oper(Operators::assign_shift_left, t_lhs.bv, t_rhs.bv); + } + + static Boxed_Number assign_shift_right(Boxed_Number t_lhs, const Boxed_Number &t_rhs) + { + return oper(Operators::assign_shift_right, t_lhs.bv, t_rhs.bv); + } + + static const Boxed_Number bitwise_and(const Boxed_Number &t_lhs, const Boxed_Number &t_rhs) + { + return oper(Operators::bitwise_and, t_lhs.bv, t_rhs.bv); + } + + static const Boxed_Number bitwise_complement(const Boxed_Number &t_lhs) + { + return oper(Operators::bitwise_complement, t_lhs.bv, Boxed_Value(0)); + } + + static const Boxed_Number bitwise_xor(const Boxed_Number &t_lhs, const Boxed_Number &t_rhs) + { + return oper(Operators::bitwise_xor, t_lhs.bv, t_rhs.bv); + } + + static const Boxed_Number bitwise_or(const Boxed_Number &t_lhs, const Boxed_Number &t_rhs) + { + return oper(Operators::bitwise_or, t_lhs.bv, t_rhs.bv); + } + + static Boxed_Number assign_product(Boxed_Number t_lhs, const Boxed_Number &t_rhs) + { + return oper(Operators::assign_product, t_lhs.bv, t_rhs.bv); + } + + static Boxed_Number assign_quotient(Boxed_Number t_lhs, const Boxed_Number &t_rhs) + { + return oper(Operators::assign_quotient, t_lhs.bv, t_rhs.bv); + } + + static Boxed_Number assign_sum(Boxed_Number t_lhs, const Boxed_Number &t_rhs) + { + return oper(Operators::assign_sum, t_lhs.bv, t_rhs.bv); + } + static Boxed_Number assign_difference(Boxed_Number t_lhs, const Boxed_Number &t_rhs) + { + return oper(Operators::assign_difference, t_lhs.bv, t_rhs.bv); + } + + static const Boxed_Number quotient(const Boxed_Number &t_lhs, const Boxed_Number &t_rhs) + { + return oper(Operators::quotient, t_lhs.bv, t_rhs.bv); + } + + static const Boxed_Number shift_left(const Boxed_Number &t_lhs, const Boxed_Number &t_rhs) + { + return oper(Operators::shift_left, t_lhs.bv, t_rhs.bv); + } + + static const Boxed_Number product(const Boxed_Number &t_lhs, const Boxed_Number &t_rhs) + { + return oper(Operators::product, t_lhs.bv, t_rhs.bv); + } + + static const Boxed_Number remainder(const Boxed_Number &t_lhs, const Boxed_Number &t_rhs) + { + return oper(Operators::remainder, t_lhs.bv, t_rhs.bv); + } + + static const Boxed_Number shift_right(const Boxed_Number &t_lhs, const Boxed_Number &t_rhs) + { + return oper(Operators::shift_right, t_lhs.bv, t_rhs.bv); + } + + + static Boxed_Value do_oper(Operators::Opers t_oper, const Boxed_Value &t_lhs, const Boxed_Value &t_rhs) { return oper(t_oper, t_lhs, t_rhs); @@ -484,6 +643,8 @@ namespace chaiscript return oper(t_oper, t_lhs, const_var(0)); } + + Boxed_Value bv; }; diff --git a/include/chaiscript/dispatchkit/handle_return.hpp b/include/chaiscript/dispatchkit/handle_return.hpp index e9fe6ae..3a52eb1 100644 --- a/include/chaiscript/dispatchkit/handle_return.hpp +++ b/include/chaiscript/dispatchkit/handle_return.hpp @@ -8,6 +8,7 @@ #define CHAISCRIPT_HANDLE_RETURN_HPP_ #include "boxed_value.hpp" +#include "boxed_number.hpp" #include "type_info.hpp" #include #include @@ -135,6 +136,30 @@ namespace chaiscript } }; + /** + * Used internally for handling a return value from a Proxy_Function call + */ + template<> + struct Handle_Return + { + static Boxed_Value handle(const Boxed_Number &r) + { + return r.bv; + } + }; + + /** + * Used internally for handling a return value from a Proxy_Function call + */ + template<> + struct Handle_Return + { + static Boxed_Value handle(const Boxed_Number &r) + { + return r.bv; + } + }; + /** * Used internally for handling a return value from a Proxy_Function call diff --git a/include/chaiscript/language/chaiscript_algebraic.hpp b/include/chaiscript/language/chaiscript_algebraic.hpp new file mode 100644 index 0000000..37cc0ba --- /dev/null +++ b/include/chaiscript/language/chaiscript_algebraic.hpp @@ -0,0 +1,131 @@ +// This file is distributed under the BSD License. +// See "license.txt" for details. +// Copyright 2009-2011, Jonathan Turner (jonathan@emptycrate.com) +// and Jason Turner (jason@emptycrate.com) +// http://www.chaiscript.com + +#ifndef CHAISCRIPT_ALGEBRAIC_HPP_ +#define CHAISCRIPT_ALGEBRAIC_HPP_ + +#include +#include + +namespace chaiscript +{ + + struct Operators { + enum Opers + { + boolean_flag, + equals, less_than, greater_than, less_than_equal, greater_than_equal, not_equal, + non_const_flag, + assign, pre_increment, pre_decrement, assign_product, assign_sum, + assign_quotient, assign_difference, + non_const_int_flag, + assign_bitwise_and, assign_bitwise_or, assign_shift_left, assign_shift_right, + assign_remainder, assign_bitwise_xor, + const_int_flag, + shift_left, shift_right, remainder, bitwise_and, bitwise_or, bitwise_xor, bitwise_complement, + const_flag, + sum, quotient, product, difference, unary_plus, unary_minus, + invalid + }; + + static const char *to_string(Opers t_oper) { + const char *opers[] = { + "", + "==", "<", ">", "<=", ">=", "!=", + "", + "=", "++", "--", "*=", "+=", + "/=", "-=", + "", + "&=", "|=", "<<=", ">>=", + "%=", "^=", + "", + "<<", ">>", "%", "&", "|", "^", "~", + "", + "+", "/", "*", "-", "+", "-", + "" + }; + return opers[t_oper]; + } + + static Opers to_operator(const std::string &t_str, bool t_is_unary = false) + { + if (t_str == "==") + { + return equals; + } else if (t_str == "<") { + return less_than; + } else if (t_str == ">") { + return greater_than; + } else if (t_str == "<=") { + return less_than_equal; + } else if (t_str == ">=") { + return greater_than_equal; + } else if (t_str == "!=") { + return not_equal; + } else if (t_str == "=") { + return assign; + } else if (t_str == "++") { + return pre_increment; + } else if (t_str == "--") { + return pre_decrement; + } else if (t_str == "*=") { + return assign_product; + } else if (t_str == "+=") { + return assign_sum; + } else if (t_str == "-=") { + return assign_difference; + } else if (t_str == "&=") { + return assign_bitwise_and; + } else if (t_str == "|=") { + return assign_bitwise_or; + } else if (t_str == "<<=") { + return assign_shift_left; + } else if (t_str == ">>=") { + return assign_shift_right; + } else if (t_str == "%=") { + return assign_remainder; + } else if (t_str == "^=") { + return assign_bitwise_xor; + } else if (t_str == "<<") { + return shift_left; + } else if (t_str == ">>") { + return shift_right; + } else if (t_str == "%") { + return remainder; + } else if (t_str == "&") { + return bitwise_and; + } else if (t_str == "|") { + return bitwise_or; + } else if (t_str == "^") { + return bitwise_xor; + } else if (t_str == "~") { + return bitwise_complement; + } else if (t_str == "+") { + if (t_is_unary) { + return unary_plus; + } else { + return sum; + } + } else if (t_str == "-") { + if (t_is_unary) { + return unary_minus; + } else { + return difference; + } + } else if (t_str == "/") { + return quotient; + } else if (t_str == "*") { + return product; + } else { + return invalid; + } + } + + }; +} + +#endif /* _CHAISCRIPT_ALGEBRAIC_HPP */ + diff --git a/include/chaiscript/language/chaiscript_common.hpp b/include/chaiscript/language/chaiscript_common.hpp index 0247c06..7b21f52 100644 --- a/include/chaiscript/language/chaiscript_common.hpp +++ b/include/chaiscript/language/chaiscript_common.hpp @@ -15,118 +15,6 @@ namespace chaiscript /// Signature of module entry point that all binary loadable modules must implement. typedef ModulePtr (*Create_Module_Func)(); - struct Operators { - enum Opers - { - boolean_flag, - equals, less_than, greater_than, less_than_equal, greater_than_equal, not_equal, - non_const_flag, - assign, pre_increment, pre_decrement, assign_product, assign_sum, - assign_quotient, assign_difference, - non_const_int_flag, - assign_bitwise_and, assign_bitwise_or, assign_shift_left, assign_shift_right, - assign_remainder, assign_bitwise_xor, - const_int_flag, - shift_left, shift_right, remainder, bitwise_and, bitwise_or, bitwise_xor, bitwise_complement, - const_flag, - sum, quotient, product, difference, unary_plus, unary_minus, - invalid - }; - - static const char *to_string(Opers t_oper) { - const char *opers[] = { - "", - "==", "<", ">", "<=", ">=", "!=", - "", - "=", "++", "--", "*=", "+=", - "/=", "-=", - "", - "&=", "|=", "<<=", ">>=", - "%=", "^=", - "", - "<<", ">>", "%", "&", "|", "^", "~", - "", - "+", "/", "*", "-", "+", "-", - "" - }; - return opers[t_oper]; - } - - static Opers to_operator(const std::string &t_str, bool t_is_unary = false) - { - if (t_str == "==") - { - return equals; - } else if (t_str == "<") { - return less_than; - } else if (t_str == ">") { - return greater_than; - } else if (t_str == "<=") { - return less_than_equal; - } else if (t_str == ">=") { - return greater_than_equal; - } else if (t_str == "!=") { - return not_equal; - } else if (t_str == "=") { - return assign; - } else if (t_str == "++") { - return pre_increment; - } else if (t_str == "--") { - return pre_decrement; - } else if (t_str == "*=") { - return assign_product; - } else if (t_str == "+=") { - return assign_sum; - } else if (t_str == "-=") { - return assign_difference; - } else if (t_str == "&=") { - return assign_bitwise_and; - } else if (t_str == "|=") { - return assign_bitwise_or; - } else if (t_str == "<<=") { - return assign_shift_left; - } else if (t_str == ">>=") { - return assign_shift_right; - } else if (t_str == "%=") { - return assign_remainder; - } else if (t_str == "^=") { - return assign_bitwise_xor; - } else if (t_str == "<<") { - return shift_left; - } else if (t_str == ">>") { - return shift_right; - } else if (t_str == "%") { - return remainder; - } else if (t_str == "&") { - return bitwise_and; - } else if (t_str == "|") { - return bitwise_or; - } else if (t_str == "^") { - return bitwise_xor; - } else if (t_str == "~") { - return bitwise_complement; - } else if (t_str == "+") { - if (t_is_unary) { - return unary_plus; - } else { - return sum; - } - } else if (t_str == "-") { - if (t_is_unary) { - return unary_minus; - } else { - return difference; - } - } else if (t_str == "/") { - return quotient; - } else if (t_str == "*") { - return product; - } else { - return invalid; - } - } - - }; /// Types of AST nodes available to the parser and eval class AST_Node_Type {