diff --git a/ArithmeticCalculator.cpp b/ArithmeticCalculator.cpp index 7df9e9f..ab16785 100644 --- a/ArithmeticCalculator.cpp +++ b/ArithmeticCalculator.cpp @@ -4,11 +4,11 @@ #include "PostficCalculator.h" double ArithmeticCalculator::Solve(char* equation) { - SyntaxParser* parser = new SyntaxParser(equation); + SyntaxParser* parser = new SyntaxParser(); PostfixConvertor* postfixConverter = new PostfixConvertor(); PostfixCalculator* postfixCalculator = new PostfixCalculator(); - LinkedList* formulaList = parser->ParseExpression(); + LinkedList* formulaList = parser->ParseExpression(equation); Stack* postfixStack = postfixConverter->CreatePostfixStack(formulaList); diff --git a/SyntaxParser.cpp b/SyntaxParser.cpp index b0009f6..ba65450 100644 --- a/SyntaxParser.cpp +++ b/SyntaxParser.cpp @@ -4,8 +4,7 @@ using namespace std; -SyntaxParser::SyntaxParser(string input) { - _input = input; +SyntaxParser::SyntaxParser() { _parsedExpression = new LinkedList(); _current = 0; } @@ -122,7 +121,9 @@ void SyntaxParser::ParseNumber() { delete buffer; } -LinkedList* SyntaxParser::ParseExpression() { +LinkedList* SyntaxParser::ParseExpression(string input) { + _input = input; + while (true) { char c = GetNextChar(); diff --git a/SyntaxParser.h b/SyntaxParser.h index bb0885a..ec84614 100644 --- a/SyntaxParser.h +++ b/SyntaxParser.h @@ -17,7 +17,7 @@ class SyntaxParser { void ParseText(); void ParseNumber(); public: - SyntaxParser(string input); + SyntaxParser(); ~SyntaxParser(); - LinkedList* ParseExpression(); + LinkedList* ParseExpression(string input); }; \ No newline at end of file