From bbea7642fcc320debfc85ae70887ece92ea59d9a Mon Sep 17 00:00:00 2001 From: atlimit8 Date: Tue, 14 Feb 2017 10:45:38 -0600 Subject: [PATCH] ConditionExpression: setup operator precedences --- OpenRA.Game/Support/ConditionExpression.cs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/OpenRA.Game/Support/ConditionExpression.cs b/OpenRA.Game/Support/ConditionExpression.cs index 260bd42d3e..be4fb98798 100644 --- a/OpenRA.Game/Support/ConditionExpression.cs +++ b/OpenRA.Game/Support/ConditionExpression.cs @@ -129,11 +129,14 @@ namespace OpenRA.Support enum Precedence { - Invalid = ~0, - Parens = -1, + Unary = 16, + Equality = 8, + And = 4, + Or = 3, + Binary = 0, Value = 0, - Unary = 1, - Binary = 0 + Parens = -1, + Invalid = ~0 } struct TokenTypeInfo @@ -197,16 +200,16 @@ namespace OpenRA.Support yield return new TokenTypeInfo("!", Precedence.Unary, OperandSides.Right, Associativity.Right); continue; case TokenType.And: - yield return new TokenTypeInfo("&&", Precedence.Binary, OperandSides.Both); + yield return new TokenTypeInfo("&&", Precedence.And, OperandSides.Both); continue; case TokenType.Or: - yield return new TokenTypeInfo("||", Precedence.Binary, OperandSides.Both); + yield return new TokenTypeInfo("||", Precedence.Or, OperandSides.Both); continue; case TokenType.Equals: - yield return new TokenTypeInfo("==", Precedence.Binary, OperandSides.Both); + yield return new TokenTypeInfo("==", Precedence.Equality, OperandSides.Both); continue; case TokenType.NotEquals: - yield return new TokenTypeInfo("!=", Precedence.Binary, OperandSides.Both); + yield return new TokenTypeInfo("!=", Precedence.Equality, OperandSides.Both); continue; }