src/Expression.h

changeset 115
9be16e1c1e44
parent 112
def56932f938
equal deleted inserted replaced
114:6cbeb9f8350f 115:9be16e1c1e44
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* Result(); 53 ExpressionValue* getResult();
54 54
55 private: 55 private:
56 BotscriptParser* mParser; 56 BotscriptParser* m_parser;
57 Lexer* mLexer; 57 Lexer* m_lexer;
58 SymbolList mSymbols; 58 SymbolList m_symbols;
59 DataType mType; 59 DataType m_type;
60 String mBadTokenText; 60 String m_badTokenText;
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 TokenString(); 64 String getTokenString();
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);
70 SymbolList::Iterator FindPrioritizedOperator(); 70 SymbolList::Iterator findPrioritizedOperator();
71 }; 71 };
72 72
73 // ============================================================================= 73 // =============================================================================
74 // 74 //
75 class ExpressionSymbol 75 class ExpressionSymbol
76 { 76 {
77 public: 77 public:
78 ExpressionSymbol (ExpressionSymbolType type) : 78 ExpressionSymbol (ExpressionSymbolType type) :
79 mType (type) {} 79 m_type (type) {}
80 80
81 PROPERTY (private, ExpressionSymbolType, Type, SetType, 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, SetID, 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, SetValue, STOCK_WRITE) 98 PROPERTY (public, int, value, setValue, STOCK_WRITE)
99 PROPERTY (public, DataBuffer*, Buffer, SetBuffer, STOCK_WRITE) 99 PROPERTY (public, DataBuffer*, buffer, setBuffer, STOCK_WRITE)
100 PROPERTY (public, DataType, ValueType, SetValueType, 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
106 void ConvertToBuffer(); 106 void convertToBuffer();
107 107
108 inline ExpressionValue* Clone() const 108 inline ExpressionValue* clone() const
109 { 109 {
110 return new ExpressionValue (*this); 110 return new ExpressionValue (*this);
111 } 111 }
112 112
113 inline bool IsConstexpr() const 113 inline bool isConstexpr() const
114 { 114 {
115 return Buffer() == null; 115 return buffer() == null;
116 } 116 }
117 }; 117 };
118 118
119 // ============================================================================= 119 // =============================================================================
120 // 120 //

mercurial