# HG changeset patch
# User Teemu Piippo <crimsondusk64@gmail.com>
# Date 1344894482 -10800
# Node ID f2596a239ea13f2fcebaca1aee0b45c41b24bedc
# Parent  2cfa6edbf9282dad41349c43eacd0e92c1a2e98f
Added ! operator support. It's not really an operator since it's just checked at the beginning of the expression value but eh.

diff -r 2cfa6edbf928 -r f2596a239ea1 parser.cxx
--- a/parser.cxx	Tue Aug 14 00:20:59 2012 +0300
+++ b/parser.cxx	Tue Aug 14 00:48:02 2012 +0300
@@ -646,7 +646,7 @@
 
 // ============================================================================
 // Finds an operator's corresponding dataheader
-static long DataHeaderByOperator (ScriptVar* var, int oper) {
+static word DataHeaderByOperator (ScriptVar* var, int oper) {
 	if (IsAssignmentOperator (oper)) {
 		if (!var)
 			error ("operator %d requires left operand to be a variable\n", oper);
@@ -791,6 +791,11 @@
 	
 	ScriptVar* g;
 	
+	// Prefixing "!" means negation.
+	bool negate = !token.compare ("!");
+	if (negate) // Jump past the "!"
+		MustNext ();
+	
 	if (!token.compare ("(")) {
 		// Expression
 		MustNext ();
@@ -838,6 +843,10 @@
 		}
 	}
 	
+	// Negate it now if desired
+	if (negate)
+		b->Write<word> (DH_NEGATELOGICAL);
+	
 	return b;
 }