From 468cb19bce9caf11b027da791b1d6f0aa1b41602 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Fri, 14 Nov 2014 03:21:42 +0100 Subject: added ^# (XOR) operator also changed precedence of + operator (higher than minus). the effects of this should be minimal --- src/expressions.cpp | 3 +++ src/expressions.h | 3 ++- src/parser.cpp | 5 +++++ 3 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/expressions.cpp b/src/expressions.cpp index a528f16..5a389fd 100644 --- a/src/expressions.cpp +++ b/src/expressions.cpp @@ -170,6 +170,9 @@ Expressions::calc(void) case OP_AND: result = vleft & vright; break; + case OP_XOR: + result = vleft ^ vright; + break; case OP_OR: result = vleft | vright; break; diff --git a/src/expressions.h b/src/expressions.h index 8e690e8..730ddad 100644 --- a/src/expressions.h +++ b/src/expressions.h @@ -143,9 +143,10 @@ public: OP_MUL, // * OP_DIV, // / OP_MOD, // ^/ - OP_SUB, // - OP_ADD, // + + OP_SUB, // - OP_AND, // & + OP_XOR, // ^# OP_OR, // # // pseudo operators: OP_NEW, diff --git a/src/parser.cpp b/src/parser.cpp index 24d48c2..f839840 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -1735,6 +1735,11 @@ StateControl::custom(gchar chr) expressions.push_calc(Expressions::OP_MOD); break; + case '#': + BEGIN_EXEC(&States::start); + expressions.push_calc(Expressions::OP_XOR); + break; + default: throw Error("Unsupported command <^%c>", chr); } -- cgit v1.2.3