src/Expression.h

changeset 92
3a00d396bce2
parent 91
427eb377d53e
child 93
11a24b697f43
--- a/src/Expression.h	Mon Feb 03 20:12:44 2014 +0200
+++ b/src/Expression.h	Tue Feb 04 02:28:33 2014 +0200
@@ -8,23 +8,51 @@
 
 // =============================================================================
 //
+enum EOperator
+{
+	opNegateLogical,
+	opUnaryMinus,
+	opMultiplication,
+	opDivision,
+	opModulus,
+	opAddition,
+	opSubtraction,
+	opLeftShift,
+	opRightShift,
+	opCompareLesser,
+	opCompareGreater,
+	opCompareAtLeast,
+	opCompareAtMost,
+	opCompareEquals,
+	opCompareNotEquals,
+	opBitwiseAnd,
+	opBitwiseXOr,
+	opBitwiseOr,
+	opLogicalAnd,
+	opLogicalOr,
+	opTernary,
+};
+
+// =============================================================================
+//
 class Expression final
 {
 	public:
-		Expression (BotscriptParser* parser, EType reqtype, Lexer* lx);
+		Expression (BotscriptParser* parser, Lexer* lx, EType reqtype);
 		~Expression();
 		ExpressionValue*		GetResult();
 
 	private:
+		BotscriptParser*		mParser;
 		Lexer*					mLexer;
 		List<ExpressionSymbol*>	mSymbols;
 		EType					mType;
 		ExpressionValue*		mResult;
-		BotscriptParser*		mParser;
 
 		ExpressionValue*		Evaluate(); // Process the expression and yield a result
 		ExpressionSymbol*		ParseSymbol();
 		String					GetTokenString();
+		void					AdjustOperators();
 		void					Verify(); // Ensure the expr is valid
 };
 
@@ -35,11 +63,14 @@
 	public:
 		enum EExpressionSymbolType
 		{
-			eOperator,
-			eOperand,
-			eColon,
+			eOperatorSymbol,
+			eValueSymbol,
+			eColonSymbol,
 		};
 
+		ExpressionSymbol (EExpressionSymbolType type) :
+			mType (type) {}
+
 	PROPERTY (private,	EExpressionSymbolType,	Type,	NO_OPS,	STOCK_WRITE)
 };
 
@@ -47,22 +78,23 @@
 //
 class ExpressionOperator final : public ExpressionSymbol
 {
-	PROPERTY (public,	int,	ID,	NO_OPS,	STOCK_WRITE)
+	PROPERTY (public,	EOperator,	ID,	NO_OPS,	STOCK_WRITE)
 
 	public:
-		ExpressionOperator (int id);
+		ExpressionOperator (EOperator id);
 };
 
 // =============================================================================
 //
 class ExpressionValue final : public ExpressionSymbol
 {
-	PROPERTY (public,	int,			Value,		BOOL_OPS,	STOCK_WRITE)
+	PROPERTY (public,	int,			Value,		NUM_OPS,	STOCK_WRITE)
 	PROPERTY (public,	DataBuffer*,	Buffer,		NO_OPS,		STOCK_WRITE)
 	PROPERTY (public,	EType,			ValueType,	NO_OPS,		STOCK_WRITE)
 
 	public:
 		ExpressionValue (EType valuetype);
+		~ExpressionValue();
 
 		void ConvertToBuffer();
 
@@ -82,7 +114,7 @@
 {
 	public:
 		ExpressionColon() :
-			mType (eColon) {}
+			ExpressionSymbol (eColonSymbol) {}
 };
 
 #endif // BOTC_EXPRESSION_H
\ No newline at end of file

mercurial