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