From efa862d4f89401c5148746a5aba4d88ed6b6cbaa Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Wed, 22 Jul 2015 01:40:53 +0200 Subject: fixed operator precedence list * necessary since in SciTECO every operator has a different precedence. E.g. successive additions/subtractions cannot be evaluated from left to right (by their associativity). Perhaps this should be changed. * subtraction must have a higher precedence than addition, since (a+b)-c == a+(b-c) * division must have a higher precedence than multiplication since (a*b)/c == a*(b/c). This is not quite true for integer arithmetics. * this fixes expressions like 5-1+1 which were counterintuitively evaluated like 5-(1+1) --- src/expressions.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/expressions.h') diff --git a/src/expressions.h b/src/expressions.h index a0e2908..f97ec1c 100644 --- a/src/expressions.h +++ b/src/expressions.h @@ -159,11 +159,11 @@ public: enum Operator { OP_NIL = 0, OP_POW, // ^* - OP_MUL, // * - OP_DIV, // / OP_MOD, // ^/ - OP_ADD, // + + OP_DIV, // / + OP_MUL, // * OP_SUB, // - + OP_ADD, // + OP_AND, // & OP_XOR, // ^# OP_OR, // # -- cgit v1.2.3