-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExpression.h
More file actions
37 lines (33 loc) · 892 Bytes
/
Copy pathExpression.h
File metadata and controls
37 lines (33 loc) · 892 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#pragma once
#ifndef EXPRESSION_H_
#define EXPRESSION_H_
#include <list>
#include <vector>
#include <stack>
#include <string>
#include "Symbol.h"
#include "functiontree.h"
/*
The Expression enforces the lexical grammar of arithmetic expressions
*/
class Expression
{
public:
typedef std::list<Symbol<double>* >::iterator expression_ptr;
Expression();
~Expression(void);
void NewOperand(Symbol<double>* symbol);
enum State{StartState, RightOfOperator, BuildingOperand, BuildingOperandAfterDecimal, ErrorState};
void Update(Symbol<double>* const& symbol);
std::string const& GetExpressionAsString(){return _expressionString;}
void ClearExpression();
void BackExpression();
void Evaluate();
private:
std::string _expressionString;
std::list<Symbol<double>* > _expression;
CompositeOperandSymbol<double>* _currentOperand;
State _state;
std::stack<State> _pastStates;
};
#endif