From 3ba81a7d0ae6b2873242bc634bc338ccb04d1c03 Mon Sep 17 00:00:00 2001 From: Brad Arant Date: Thu, 8 Aug 2024 16:34:20 -0700 Subject: [PATCH] More Expression.cpp work. --- Expression.cpp | 16 ++++++++++++++++ Expression.h | 1 + 2 files changed, 17 insertions(+) diff --git a/Expression.cpp b/Expression.cpp index 7277cb9..66e962d 100644 --- a/Expression.cpp +++ b/Expression.cpp @@ -1,5 +1,6 @@ #include "Expression.h" #include "Operand.h" +#include "Exception.h" #include namespace jet { @@ -12,6 +13,21 @@ namespace jet { boolean = op1.boolean; string = op1.string; + if(in.unparsed().getLength() > 0) { + std::cout << "1)" << in.unparsed() << std::endl; + if(in.ifNext("+")) + operation = (char *)"+"; + else if(in.ifNext("-")) + operation = (char *)"-"; + else + throw coreutils::Exception("Expecting operator."); + in.skipWhitespace(); + if(in.unparsed().getLength() == 0) + throw coreutils::Exception("Expecting operand."); + Operand op2(in); + std::cout << op1.string << ":" << operation << ":" << op2.string << std::endl; + } + std::cout << "Leaving expression string: " << string << std::endl; std::cout << "Unparsed: [" << in.unparsed() << "]" << std::endl; } diff --git a/Expression.h b/Expression.h index 6d02c93..a7363ce 100644 --- a/Expression.h +++ b/Expression.h @@ -16,6 +16,7 @@ namespace jet { coreutils::ZString getStringResult(); bool boolean; coreutils::ZString string; + char *operation; }; }