Commit 12007be 1 parent d3dcfbd commit 12007be Copy full SHA for 12007be
File tree 3 files changed +8
-7
lines changed
3 files changed +8
-7
lines changed Original file line number Diff line number Diff line change 4
4
#include " PostficCalculator.h"
5
5
6
6
double ArithmeticCalculator::Solve (char * equation) {
7
- SyntaxParser* parser = new SyntaxParser (equation );
7
+ SyntaxParser* parser = new SyntaxParser ();
8
8
PostfixConvertor* postfixConverter = new PostfixConvertor ();
9
9
PostfixCalculator* postfixCalculator = new PostfixCalculator ();
10
10
11
- LinkedList<FormulaItem*>* formulaList = parser->ParseExpression ();
11
+ LinkedList<FormulaItem*>* formulaList = parser->ParseExpression (equation );
12
12
13
13
Stack<FormulaItem*>* postfixStack = postfixConverter->CreatePostfixStack (formulaList);
14
14
Original file line number Diff line number Diff line change 4
4
5
5
using namespace std ;
6
6
7
- SyntaxParser::SyntaxParser (string input) {
8
- _input = input;
7
+ SyntaxParser::SyntaxParser () {
9
8
_parsedExpression = new LinkedList<FormulaItem*>();
10
9
_current = 0 ;
11
10
}
@@ -122,7 +121,9 @@ void SyntaxParser::ParseNumber() {
122
121
delete buffer;
123
122
}
124
123
125
- LinkedList<FormulaItem*>* SyntaxParser::ParseExpression () {
124
+ LinkedList<FormulaItem*>* SyntaxParser::ParseExpression (string input) {
125
+ _input = input;
126
+
126
127
while (true ) {
127
128
char c = GetNextChar ();
128
129
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ class SyntaxParser {
17
17
void ParseText ();
18
18
void ParseNumber ();
19
19
public:
20
- SyntaxParser (string input );
20
+ SyntaxParser ();
21
21
~SyntaxParser ();
22
- LinkedList<FormulaItem*>* ParseExpression ();
22
+ LinkedList<FormulaItem*>* ParseExpression (string input );
23
23
};
You can’t perform that action at this time.
0 commit comments