ConditionExpression: setup operator precedences
This commit is contained in:
@@ -129,11 +129,14 @@ namespace OpenRA.Support
|
|||||||
|
|
||||||
enum Precedence
|
enum Precedence
|
||||||
{
|
{
|
||||||
Invalid = ~0,
|
Unary = 16,
|
||||||
Parens = -1,
|
Equality = 8,
|
||||||
|
And = 4,
|
||||||
|
Or = 3,
|
||||||
|
Binary = 0,
|
||||||
Value = 0,
|
Value = 0,
|
||||||
Unary = 1,
|
Parens = -1,
|
||||||
Binary = 0
|
Invalid = ~0
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TokenTypeInfo
|
struct TokenTypeInfo
|
||||||
@@ -197,16 +200,16 @@ namespace OpenRA.Support
|
|||||||
yield return new TokenTypeInfo("!", Precedence.Unary, OperandSides.Right, Associativity.Right);
|
yield return new TokenTypeInfo("!", Precedence.Unary, OperandSides.Right, Associativity.Right);
|
||||||
continue;
|
continue;
|
||||||
case TokenType.And:
|
case TokenType.And:
|
||||||
yield return new TokenTypeInfo("&&", Precedence.Binary, OperandSides.Both);
|
yield return new TokenTypeInfo("&&", Precedence.And, OperandSides.Both);
|
||||||
continue;
|
continue;
|
||||||
case TokenType.Or:
|
case TokenType.Or:
|
||||||
yield return new TokenTypeInfo("||", Precedence.Binary, OperandSides.Both);
|
yield return new TokenTypeInfo("||", Precedence.Or, OperandSides.Both);
|
||||||
continue;
|
continue;
|
||||||
case TokenType.Equals:
|
case TokenType.Equals:
|
||||||
yield return new TokenTypeInfo("==", Precedence.Binary, OperandSides.Both);
|
yield return new TokenTypeInfo("==", Precedence.Equality, OperandSides.Both);
|
||||||
continue;
|
continue;
|
||||||
case TokenType.NotEquals:
|
case TokenType.NotEquals:
|
||||||
yield return new TokenTypeInfo("!=", Precedence.Binary, OperandSides.Both);
|
yield return new TokenTypeInfo("!=", Precedence.Equality, OperandSides.Both);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user