diff --git a/Expression.cpp b/Expression.cpp index bb0aede..ec1455c 100644 --- a/Expression.cpp +++ b/Expression.cpp @@ -1,24 +1,29 @@ #include "Expression.h" +#include "Operand.h" #include namespace jet { - Expression::Expression(coreutils::ZString &expression) : MString() { - std::cout << "Expression construction:" << expression << std::endl; + Expression::Expression(coreutils::ZString &in) : MString() { + std::cout << "Expression construction:" << in << std::endl; - if(isNumber(0, expression)) { - - } else if(expression.equals("true")) - write(expression); - else if(expression.equals("false")) - write(expression); + Operand op1(in); + + boolean = op1.boolean; } Expression::~Expression() {} - bool Expression::isNumber(int reg, coreutils::ZString &expression) { - - return false; - } + bool Expression::getBooleanResult() { + return boolean; + } + double Expression::getNumericResult() { + return 0; + } + + coreutils::ZString Expression::getStringResult() { + return coreutils::ZString(); + } + } diff --git a/Expression.h b/Expression.h index 1aeabad..875b9d9 100644 --- a/Expression.h +++ b/Expression.h @@ -8,11 +8,13 @@ namespace jet { class Expression : public coreutils::MString { public: - Expression(coreutils::ZString &expression); + Expression(coreutils::ZString &in); virtual ~Expression(); - private: - bool isNumber(int reg, coreutils::ZString &expression); + bool getBooleanResult(); + double getNumericResult(); + coreutils::ZString getStringResult(); + bool boolean; }; } diff --git a/Operand.cpp b/Operand.cpp new file mode 100644 index 0000000..deaf72f --- /dev/null +++ b/Operand.cpp @@ -0,0 +1,36 @@ +#include "Operand.h" + +namespace jet { + + Operand::Operand(coreutils::ZString &in) { + + if(in.ifNext("true")) { + boolean = true; + return; + } + if(in.ifNext("false")) { + boolean = false; + return; + } + + + /* + if(in.ifNext("+")) { + } + if(in.ifNext("-")) { + } + if(in.getTokenInclude("0123456789")) { + } + if(in.ifNext(".")) { + } + if(in.getTokenInclude("0123456789")) { + } + + if(in.ifNext("\"")) { + } + */ + + + } + +} diff --git a/Operand.h b/Operand.h new file mode 100644 index 0000000..0d6b523 --- /dev/null +++ b/Operand.h @@ -0,0 +1,35 @@ +#ifndef __Operand_h__ +#define __Operand_h__ + +#include "ZString.h" + +namespace jet { + + class Operand { + + public: + Operand(coreutils::ZString &in); + + bool isNumber(); + bool isInteger(); + bool isFloat(); + bool isString(); + bool isVariable(); + + + /// + /// boolean is set by internal processes to return the boolean + /// equivilent value. + /// + + bool boolean; + + private: +// dataType enum ={}; + double doubleValue; + + + }; +} + +#endif \ No newline at end of file diff --git a/__if.cpp b/__if.cpp index cb8e2a5..e7ed345 100644 --- a/__if.cpp +++ b/__if.cpp @@ -1,4 +1,3 @@ - #include "__if.h" #include "Exception.h" #include @@ -15,11 +14,12 @@ namespace jet { throw coreutils::Exception("Either value1 or expr can be specified but not both."); if(variableDefined("value2")) { if(variableDefined("type")) { - result = "true"; + result = Expression(variables["expr"]); } else throw coreutils::Exception("type expected if value1 and value2 specified."); } else throw coreutils::Exception("value2 required if value1 specified."); + std::cout << variables["value1"].str() << "' and value2 '" << variables["value2"].str() << "' comparison" << std::endl; } else if(variableDefined("expr")) { if(variableDefined("value2")) throw coreutils::Exception("value2 should not be specified with expr."); diff --git a/testjet.cpp b/testjet.cpp index 9364ff7..5151c79 100644 --- a/testjet.cpp +++ b/testjet.cpp @@ -18,7 +18,7 @@ int main(int argc, char **argv) { " >>>$[thename]<<<\n" " local: >>>#[name]<<<\n" " \n" - " \n" + " \n" " 789\n" " \n" " 123\n"