Rename VariableExpression.OperandSides => VariableExpression.Sides
This commit is contained in:
@@ -90,7 +90,7 @@ namespace OpenRA.Support
|
||||
enum Associativity { Left, Right }
|
||||
|
||||
[Flags]
|
||||
enum OperandSides
|
||||
enum Sides
|
||||
{
|
||||
// Value type
|
||||
None = 0,
|
||||
@@ -159,12 +159,12 @@ namespace OpenRA.Support
|
||||
{
|
||||
public readonly string Symbol;
|
||||
public readonly Precedence Precedence;
|
||||
public readonly OperandSides OperandSides;
|
||||
public readonly Sides OperandSides;
|
||||
public readonly Associativity Associativity;
|
||||
public readonly Grouping Opens;
|
||||
public readonly Grouping Closes;
|
||||
|
||||
public TokenTypeInfo(string symbol, Precedence precedence, OperandSides operandSides = OperandSides.None,
|
||||
public TokenTypeInfo(string symbol, Precedence precedence, Sides operandSides = Sides.None,
|
||||
Associativity associativity = Associativity.Left,
|
||||
Grouping opens = Grouping.None, Grouping closes = Grouping.None)
|
||||
{
|
||||
@@ -182,9 +182,9 @@ namespace OpenRA.Support
|
||||
Symbol = symbol;
|
||||
Precedence = precedence;
|
||||
OperandSides = opens == Grouping.None ?
|
||||
(closes == Grouping.None ? OperandSides.None : OperandSides.Left)
|
||||
(closes == Grouping.None ? Sides.None : Sides.Left)
|
||||
:
|
||||
(closes == Grouping.None ? OperandSides.Right : OperandSides.Both);
|
||||
(closes == Grouping.None ? Sides.Right : Sides.Both);
|
||||
Associativity = associativity;
|
||||
Opens = opens;
|
||||
Closes = closes;
|
||||
@@ -219,52 +219,52 @@ namespace OpenRA.Support
|
||||
yield return new TokenTypeInfo(")", Precedence.Parens, Grouping.None, Grouping.Parens);
|
||||
continue;
|
||||
case TokenType.Not:
|
||||
yield return new TokenTypeInfo("!", Precedence.Unary, OperandSides.Right, Associativity.Right);
|
||||
yield return new TokenTypeInfo("!", Precedence.Unary, Sides.Right, Associativity.Right);
|
||||
continue;
|
||||
case TokenType.OnesComplement:
|
||||
yield return new TokenTypeInfo("~", Precedence.Unary, OperandSides.Right, Associativity.Right);
|
||||
yield return new TokenTypeInfo("~", Precedence.Unary, Sides.Right, Associativity.Right);
|
||||
continue;
|
||||
case TokenType.Negate:
|
||||
yield return new TokenTypeInfo("-", Precedence.Unary, OperandSides.Right, Associativity.Right);
|
||||
yield return new TokenTypeInfo("-", Precedence.Unary, Sides.Right, Associativity.Right);
|
||||
continue;
|
||||
case TokenType.And:
|
||||
yield return new TokenTypeInfo("&&", Precedence.And, OperandSides.Both);
|
||||
yield return new TokenTypeInfo("&&", Precedence.And, Sides.Both);
|
||||
continue;
|
||||
case TokenType.Or:
|
||||
yield return new TokenTypeInfo("||", Precedence.Or, OperandSides.Both);
|
||||
yield return new TokenTypeInfo("||", Precedence.Or, Sides.Both);
|
||||
continue;
|
||||
case TokenType.Equals:
|
||||
yield return new TokenTypeInfo("==", Precedence.Equality, OperandSides.Both);
|
||||
yield return new TokenTypeInfo("==", Precedence.Equality, Sides.Both);
|
||||
continue;
|
||||
case TokenType.NotEquals:
|
||||
yield return new TokenTypeInfo("!=", Precedence.Equality, OperandSides.Both);
|
||||
yield return new TokenTypeInfo("!=", Precedence.Equality, Sides.Both);
|
||||
continue;
|
||||
case TokenType.LessThan:
|
||||
yield return new TokenTypeInfo("<", Precedence.Relation, OperandSides.Both);
|
||||
yield return new TokenTypeInfo("<", Precedence.Relation, Sides.Both);
|
||||
continue;
|
||||
case TokenType.LessThanOrEqual:
|
||||
yield return new TokenTypeInfo("<=", Precedence.Relation, OperandSides.Both);
|
||||
yield return new TokenTypeInfo("<=", Precedence.Relation, Sides.Both);
|
||||
continue;
|
||||
case TokenType.GreaterThan:
|
||||
yield return new TokenTypeInfo(">", Precedence.Relation, OperandSides.Both);
|
||||
yield return new TokenTypeInfo(">", Precedence.Relation, Sides.Both);
|
||||
continue;
|
||||
case TokenType.GreaterThanOrEqual:
|
||||
yield return new TokenTypeInfo(">=", Precedence.Relation, OperandSides.Both);
|
||||
yield return new TokenTypeInfo(">=", Precedence.Relation, Sides.Both);
|
||||
continue;
|
||||
case TokenType.Add:
|
||||
yield return new TokenTypeInfo("+", Precedence.Addition, OperandSides.Both);
|
||||
yield return new TokenTypeInfo("+", Precedence.Addition, Sides.Both);
|
||||
continue;
|
||||
case TokenType.Subtract:
|
||||
yield return new TokenTypeInfo("-", Precedence.Addition, OperandSides.Both);
|
||||
yield return new TokenTypeInfo("-", Precedence.Addition, Sides.Both);
|
||||
continue;
|
||||
case TokenType.Multiply:
|
||||
yield return new TokenTypeInfo("*", Precedence.Multiplication, OperandSides.Both);
|
||||
yield return new TokenTypeInfo("*", Precedence.Multiplication, Sides.Both);
|
||||
continue;
|
||||
case TokenType.Divide:
|
||||
yield return new TokenTypeInfo("/", Precedence.Multiplication, OperandSides.Both);
|
||||
yield return new TokenTypeInfo("/", Precedence.Multiplication, Sides.Both);
|
||||
continue;
|
||||
case TokenType.Modulo:
|
||||
yield return new TokenTypeInfo("%", Precedence.Multiplication, OperandSides.Both);
|
||||
yield return new TokenTypeInfo("%", Precedence.Multiplication, Sides.Both);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -277,7 +277,7 @@ namespace OpenRA.Support
|
||||
|
||||
static bool HasRightOperand(TokenType type)
|
||||
{
|
||||
return ((int)TokenTypeInfos[(int)type].OperandSides & (int)OperandSides.Right) != 0;
|
||||
return ((int)TokenTypeInfos[(int)type].OperandSides & (int)Sides.Right) != 0;
|
||||
}
|
||||
|
||||
static bool IsLeftOperandOrNone(TokenType type)
|
||||
@@ -293,10 +293,10 @@ namespace OpenRA.Support
|
||||
public virtual string Symbol { get { return TokenTypeInfos[(int)Type].Symbol; } }
|
||||
|
||||
public int Precedence { get { return (int)TokenTypeInfos[(int)Type].Precedence; } }
|
||||
public OperandSides OperandSides { get { return TokenTypeInfos[(int)Type].OperandSides; } }
|
||||
public Sides OperandSides { get { return TokenTypeInfos[(int)Type].OperandSides; } }
|
||||
public Associativity Associativity { get { return TokenTypeInfos[(int)Type].Associativity; } }
|
||||
public bool LeftOperand { get { return ((int)TokenTypeInfos[(int)Type].OperandSides & (int)OperandSides.Left) != 0; } }
|
||||
public bool RightOperand { get { return ((int)TokenTypeInfos[(int)Type].OperandSides & (int)OperandSides.Right) != 0; } }
|
||||
public bool LeftOperand { get { return ((int)TokenTypeInfos[(int)Type].OperandSides & (int)Sides.Left) != 0; } }
|
||||
public bool RightOperand { get { return ((int)TokenTypeInfos[(int)Type].OperandSides & (int)Sides.Right) != 0; } }
|
||||
|
||||
public Grouping Opens { get { return TokenTypeInfos[(int)Type].Opens; } }
|
||||
public Grouping Closes { get { return TokenTypeInfos[(int)Type].Closes; } }
|
||||
@@ -638,7 +638,7 @@ namespace OpenRA.Support
|
||||
while (!((temp = s.Pop()).Opens != Grouping.None))
|
||||
yield return temp;
|
||||
}
|
||||
else if (t.OperandSides == OperandSides.None)
|
||||
else if (t.OperandSides == Sides.None)
|
||||
yield return t;
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user