Skip to content

Commit

Permalink
Moved passing of input to SyntaxParser from constructor to align with…
Browse files Browse the repository at this point in the history
… InfixProcessor and Solver
  • Loading branch information
BorderKeeper committed Jan 14, 2020
1 parent d3dcfbd commit 12007be
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions ArithmeticCalculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<FormulaItem*>* formulaList = parser->ParseExpression();
LinkedList<FormulaItem*>* formulaList = parser->ParseExpression(equation);

Stack<FormulaItem*>* postfixStack = postfixConverter->CreatePostfixStack(formulaList);

Expand Down
7 changes: 4 additions & 3 deletions SyntaxParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

using namespace std;

SyntaxParser::SyntaxParser(string input) {
_input = input;
SyntaxParser::SyntaxParser() {
_parsedExpression = new LinkedList<FormulaItem*>();
_current = 0;
}
Expand Down Expand Up @@ -122,7 +121,9 @@ void SyntaxParser::ParseNumber() {
delete buffer;
}

LinkedList<FormulaItem*>* SyntaxParser::ParseExpression() {
LinkedList<FormulaItem*>* SyntaxParser::ParseExpression(string input) {
_input = input;

while (true) {
char c = GetNextChar();

Expand Down
4 changes: 2 additions & 2 deletions SyntaxParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class SyntaxParser {
void ParseText();
void ParseNumber();
public:
SyntaxParser(string input);
SyntaxParser();
~SyntaxParser();
LinkedList<FormulaItem*>* ParseExpression();
LinkedList<FormulaItem*>* ParseExpression(string input);
};

0 comments on commit 12007be

Please sign in to comment.