Added ! operator support. It's not really an operator since it's just checked at the beginning of the expression value but eh.

Tue, 14 Aug 2012 00:48:02 +0300

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Tue, 14 Aug 2012 00:48:02 +0300
changeset 52
f2596a239ea1
parent 51
2cfa6edbf928
child 53
9ef7e549391f

Added ! operator support. It's not really an operator since it's just checked at the beginning of the expression value but eh.

parser.cxx file | annotate | diff | comparison | revisions
--- 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;
 }
 

mercurial