48 public: |
48 public: |
49 using SymbolList = List<ExpressionSymbol*>; |
49 using SymbolList = List<ExpressionSymbol*>; |
50 |
50 |
51 Expression (BotscriptParser* parser, Lexer* lx, DataType reqtype); |
51 Expression (BotscriptParser* parser, Lexer* lx, DataType reqtype); |
52 ~Expression(); |
52 ~Expression(); |
53 ExpressionValue* GetResult(); |
53 ExpressionValue* Result(); |
54 |
54 |
55 private: |
55 private: |
56 BotscriptParser* mParser; |
56 BotscriptParser* mParser; |
57 Lexer* mLexer; |
57 Lexer* mLexer; |
58 SymbolList mSymbols; |
58 SymbolList mSymbols; |
59 DataType mType; |
59 DataType mType; |
60 String mBadTokenText; |
60 String mBadTokenText; |
61 |
61 |
62 ExpressionValue* Evaluate(); // Process the expression and yield a result |
62 ExpressionValue* Evaluate(); // Process the expression and yield a result |
63 ExpressionSymbol* ParseSymbol(); |
63 ExpressionSymbol* ParseSymbol(); |
64 String GetTokenString(); |
64 String TokenString(); |
65 void AdjustOperators(); |
65 void AdjustOperators(); |
66 void Verify(); // Ensure the expr is valid |
66 void Verify(); // Ensure the expr is valid |
67 void TryVerifyValue (bool* verified, SymbolList::Iterator it); |
67 void TryVerifyValue (bool* verified, SymbolList::Iterator it); |
68 ExpressionValue* EvaluateOperator (const ExpressionOperator* op, |
68 ExpressionValue* EvaluateOperator (const ExpressionOperator* op, |
69 const List<ExpressionValue*>& values); |
69 const List<ExpressionValue*>& values); |
76 { |
76 { |
77 public: |
77 public: |
78 ExpressionSymbol (ExpressionSymbolType type) : |
78 ExpressionSymbol (ExpressionSymbolType type) : |
79 mType (type) {} |
79 mType (type) {} |
80 |
80 |
81 PROPERTY (private, ExpressionSymbolType, Type, NO_OPS, STOCK_WRITE) |
81 PROPERTY (private, ExpressionSymbolType, Type, SetType, STOCK_WRITE) |
82 }; |
82 }; |
83 |
83 |
84 // ============================================================================= |
84 // ============================================================================= |
85 // |
85 // |
86 class ExpressionOperator final : public ExpressionSymbol |
86 class ExpressionOperator final : public ExpressionSymbol |
87 { |
87 { |
88 PROPERTY (public, ExpressionOperatorType, ID, NO_OPS, STOCK_WRITE) |
88 PROPERTY (public, ExpressionOperatorType, ID, SetID, STOCK_WRITE) |
89 |
89 |
90 public: |
90 public: |
91 ExpressionOperator (ExpressionOperatorType id); |
91 ExpressionOperator (ExpressionOperatorType id); |
92 }; |
92 }; |
93 |
93 |
94 // ============================================================================= |
94 // ============================================================================= |
95 // |
95 // |
96 class ExpressionValue final : public ExpressionSymbol |
96 class ExpressionValue final : public ExpressionSymbol |
97 { |
97 { |
98 PROPERTY (public, int, Value, NUM_OPS, STOCK_WRITE) |
98 PROPERTY (public, int, Value, SetValue, STOCK_WRITE) |
99 PROPERTY (public, DataBuffer*, Buffer, NO_OPS, STOCK_WRITE) |
99 PROPERTY (public, DataBuffer*, Buffer, SetBuffer, STOCK_WRITE) |
100 PROPERTY (public, DataType, ValueType, NO_OPS, STOCK_WRITE) |
100 PROPERTY (public, DataType, ValueType, SetValueType, STOCK_WRITE) |
101 |
101 |
102 public: |
102 public: |
103 ExpressionValue (DataType valuetype); |
103 ExpressionValue (DataType valuetype); |
104 ~ExpressionValue(); |
104 ~ExpressionValue(); |
105 |
105 |