Browse Source

fixed BinaryOperatorExpressionTests

pull/2/head
Siegfried Pammer 15 years ago
parent
commit
5cb2e48423
  1. 415
      src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs
  2. 39
      src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG
  3. 1510
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs
  4. 45
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG
  5. 6
      src/Libraries/NRefactory/Test/Parser/Expressions/BinaryOperatorExpressionTests.cs

415
src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs

File diff suppressed because it is too large Load Diff

39
src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG

@ -2165,39 +2165,40 @@ AnonymousMethodExpr<out Expression outExpr> @@ -2165,39 +2165,40 @@ AnonymousMethodExpr<out Expression outExpr>
.
ConditionalOrExpr<ref Expression outExpr>
(. Expression expr; .)
(. Expression expr; Location startLocation = la.Location; .)
=
ConditionalAndExpr<ref outExpr> { "||" UnaryExpr<out expr> ConditionalAndExpr<ref expr> (. outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalOr, expr); .) }
ConditionalAndExpr<ref outExpr> { "||" UnaryExpr<out expr> ConditionalAndExpr<ref expr> (. outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalOr, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; .) }
.
ConditionalAndExpr<ref Expression outExpr>
(. Expression expr; .)
(. Expression expr; Location startLocation = la.Location; .)
=
InclusiveOrExpr<ref outExpr> { "&&" UnaryExpr<out expr> InclusiveOrExpr<ref expr> (. outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalAnd, expr); .) }
InclusiveOrExpr<ref outExpr> { "&&" UnaryExpr<out expr> InclusiveOrExpr<ref expr> (. outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalAnd, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; .) }
.
InclusiveOrExpr<ref Expression outExpr>
(. Expression expr; .)
(. Expression expr; Location startLocation = la.Location; .)
=
ExclusiveOrExpr<ref outExpr> { "|" UnaryExpr<out expr> ExclusiveOrExpr<ref expr> (. outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseOr, expr); .) }
ExclusiveOrExpr<ref outExpr> { "|" UnaryExpr<out expr> ExclusiveOrExpr<ref expr> (. outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseOr, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; .) }
.
ExclusiveOrExpr<ref Expression outExpr>
(. Expression expr; .)
(. Expression expr; Location startLocation = la.Location; .)
=
AndExpr<ref outExpr> { "^" UnaryExpr<out expr> AndExpr<ref expr> (. outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.ExclusiveOr, expr); .) }
AndExpr<ref outExpr> { "^" UnaryExpr<out expr> AndExpr<ref expr> (. outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.ExclusiveOr, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; .) }
.
AndExpr<ref Expression outExpr>
(. Expression expr; .)
(. Expression expr; Location startLocation = la.Location; .)
=
EqualityExpr<ref outExpr> { "&" UnaryExpr<out expr> EqualityExpr<ref expr> (. outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseAnd, expr); .) }
EqualityExpr<ref outExpr> { "&" UnaryExpr<out expr> EqualityExpr<ref expr> (. outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseAnd, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; .) }
.
EqualityExpr<ref Expression outExpr>
(.
Expression expr;
BinaryOperatorType op = BinaryOperatorType.None;
Location startLocation = la.Location;
.)
=
RelationalExpr<ref outExpr>
@ -2206,7 +2207,7 @@ EqualityExpr<ref Expression outExpr> @@ -2206,7 +2207,7 @@ EqualityExpr<ref Expression outExpr>
"!=" (. op = BinaryOperatorType.InEquality; .)
| "==" (. op = BinaryOperatorType.Equality; .)
)
UnaryExpr<out expr> RelationalExpr<ref expr> (. outExpr = new BinaryOperatorExpression(outExpr, op, expr); .)
UnaryExpr<out expr> RelationalExpr<ref expr> (. outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; .)
}
.
@ -2215,6 +2216,7 @@ RelationalExpr<ref Expression outExpr> @@ -2215,6 +2216,7 @@ RelationalExpr<ref Expression outExpr>
TypeReference type;
Expression expr;
BinaryOperatorType op = BinaryOperatorType.None;
Location startLocation = la.Location;
.)
=
ShiftExpr<ref outExpr>
@ -2226,18 +2228,18 @@ RelationalExpr<ref Expression outExpr> @@ -2226,18 +2228,18 @@ RelationalExpr<ref Expression outExpr>
)
UnaryExpr<out expr>
ShiftExpr<ref expr>
(. outExpr = new BinaryOperatorExpression(outExpr, op, expr); .)
(. outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; .)
|
( "is"
TypeWithRestriction<out type, false, false>
[ IF (la.kind == Tokens.Question && !IsPossibleExpressionStart(Peek(1).kind))
NullableQuestionMark<ref type> ]
(. outExpr = new TypeOfIsExpression(outExpr, type); .)
(. outExpr = new TypeOfIsExpression(outExpr, type) { StartLocation = startLocation, EndLocation = t.EndLocation }; .)
| "as"
TypeWithRestriction<out type, false, false>
[ IF (la.kind == Tokens.Question && !IsPossibleExpressionStart(Peek(1).kind))
NullableQuestionMark<ref type> ]
(. outExpr = new CastExpression(type, outExpr, CastType.TryCast); .)
(. outExpr = new CastExpression(type, outExpr, CastType.TryCast) { StartLocation = startLocation, EndLocation = t.EndLocation }; .)
)
}
.
@ -2246,6 +2248,7 @@ ShiftExpr<ref Expression outExpr> @@ -2246,6 +2248,7 @@ ShiftExpr<ref Expression outExpr>
(.
Expression expr;
BinaryOperatorType op = BinaryOperatorType.None;
Location startLocation = la.Location;
.)
=
AdditiveExpr<ref outExpr>
@ -2255,7 +2258,7 @@ ShiftExpr<ref Expression outExpr> @@ -2255,7 +2258,7 @@ ShiftExpr<ref Expression outExpr>
">" ">" (. op = BinaryOperatorType.ShiftRight; .)
)
)
UnaryExpr<out expr> AdditiveExpr<ref expr> (. outExpr = new BinaryOperatorExpression(outExpr, op, expr); .)
UnaryExpr<out expr> AdditiveExpr<ref expr> (. outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; .)
}
.
@ -2263,6 +2266,7 @@ AdditiveExpr<ref Expression outExpr> @@ -2263,6 +2266,7 @@ AdditiveExpr<ref Expression outExpr>
(.
Expression expr;
BinaryOperatorType op = BinaryOperatorType.None;
Location startLocation = la.Location;
.)
=
MultiplicativeExpr<ref outExpr>
@ -2271,7 +2275,7 @@ AdditiveExpr<ref Expression outExpr> @@ -2271,7 +2275,7 @@ AdditiveExpr<ref Expression outExpr>
"+" (. op = BinaryOperatorType.Add; .)
| "-" (. op = BinaryOperatorType.Subtract; .)
)
UnaryExpr<out expr> MultiplicativeExpr<ref expr> (. outExpr = new BinaryOperatorExpression(outExpr, op, expr); .)
UnaryExpr<out expr> MultiplicativeExpr<ref expr> (. outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; .)
}
.
@ -2279,6 +2283,7 @@ MultiplicativeExpr<ref Expression outExpr> @@ -2279,6 +2283,7 @@ MultiplicativeExpr<ref Expression outExpr>
(.
Expression expr;
BinaryOperatorType op = BinaryOperatorType.None;
Location startLocation = la.Location;
.)
=
{
@ -2287,7 +2292,7 @@ MultiplicativeExpr<ref Expression outExpr> @@ -2287,7 +2292,7 @@ MultiplicativeExpr<ref Expression outExpr>
| "/" (. op = BinaryOperatorType.Divide; .)
| "%" (. op = BinaryOperatorType.Modulus; .)
)
UnaryExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, op, expr); .)
UnaryExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; .)
}
.

1510
src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs

File diff suppressed because it is too large Load Diff

45
src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG

@ -1694,7 +1694,7 @@ SimpleExpr<out Expression pexpr> @@ -1694,7 +1694,7 @@ SimpleExpr<out Expression pexpr>
[ IF (la.kind == Tokens.OpenParenthesis && Peek(1).kind == Tokens.Of)
"(" "Of" TypeArgumentList<((MemberReferenceExpression)pexpr).TypeArguments> ")"
]
| "!" IdentifierOrKeyword<out name> (. pexpr = new BinaryOperatorExpression(pexpr, BinaryOperatorType.DictionaryAccess, new PrimitiveExpression(name, name)); .)
| "!" IdentifierOrKeyword<out name> (. pexpr = new BinaryOperatorExpression(pexpr, BinaryOperatorType.DictionaryAccess, new PrimitiveExpression(name, name) { StartLocation = t.Location, EndLocation = t.EndLocation }); .)
| (. XmlAxisType type = XmlAxisType.Attribute; bool isXmlName = false; .)
( ".@" | "..." (. type = XmlAxisType.Descendents; .) ) [ XmlOpenTag (. isXmlName = true; .) ] IdentifierOrKeyword<out name> [ XmlCloseTag ]
(. pexpr = new XmlMemberAccessExpression(pexpr, type, name, isXmlName); .)
@ -1780,7 +1780,7 @@ SimpleNonInvocationExpression<out Expression pexpr> @@ -1780,7 +1780,7 @@ SimpleNonInvocationExpression<out Expression pexpr>
| IdentifierOrKeyword<out name>
(. pexpr = new MemberReferenceExpression(null, name); .)
) |
"!" IdentifierOrKeyword<out name> (. pexpr = new BinaryOperatorExpression(null, BinaryOperatorType.DictionaryAccess, new PrimitiveExpression(name, name)); .)
"!" IdentifierOrKeyword<out name> (. pexpr = new BinaryOperatorExpression(null, BinaryOperatorType.DictionaryAccess, new PrimitiveExpression(name, name) { StartLocation = t.Location, EndLocation = t.EndLocation }); .)
| (. XmlAxisType axisType = XmlAxisType.Element; bool isXmlIdentifier = false; .)
( "..." (. axisType = XmlAxisType.Descendents; .) | ".@" (. axisType = XmlAxisType.Attribute; .) ) (
[ XmlOpenTag (. isXmlIdentifier = true; .) ] IdentifierOrKeyword<out name> [ XmlCloseTag ]
@ -1950,6 +1950,7 @@ DisjunctionExpr<out Expression outExpr> @@ -1950,6 +1950,7 @@ DisjunctionExpr<out Expression outExpr>
(.
Expression expr;
BinaryOperatorType op = BinaryOperatorType.None;
Location startLocation = la.Location;
.) =
ConjunctionExpr<out outExpr>
{
@ -1958,7 +1959,7 @@ DisjunctionExpr<out Expression outExpr> @@ -1958,7 +1959,7 @@ DisjunctionExpr<out Expression outExpr>
| "OrElse" (. op = BinaryOperatorType.LogicalOr; .)
| "Xor" (. op = BinaryOperatorType.ExclusiveOr; .)
)
ConjunctionExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, op, expr); .)
ConjunctionExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; .)
}
.
@ -1966,6 +1967,7 @@ ConjunctionExpr<out Expression outExpr> @@ -1966,6 +1967,7 @@ ConjunctionExpr<out Expression outExpr>
(.
Expression expr;
BinaryOperatorType op = BinaryOperatorType.None;
Location startLocation = la.Location;
.) =
NotExpr<out outExpr>
{
@ -1973,7 +1975,7 @@ ConjunctionExpr<out Expression outExpr> @@ -1973,7 +1975,7 @@ ConjunctionExpr<out Expression outExpr>
"And" (. op = BinaryOperatorType.BitwiseAnd; .)
| "AndAlso" (. op = BinaryOperatorType.LogicalAnd; .)
)
NotExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, op, expr); .)
NotExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; .)
}
.
@ -1990,6 +1992,7 @@ ComparisonExpr<out Expression outExpr> @@ -1990,6 +1992,7 @@ ComparisonExpr<out Expression outExpr>
(.
Expression expr;
BinaryOperatorType op = BinaryOperatorType.None;
Location startLocation = la.Location;
.) =
ShiftExpr<out outExpr>
{
@ -2005,10 +2008,10 @@ ComparisonExpr<out Expression outExpr> @@ -2005,10 +2008,10 @@ ComparisonExpr<out Expression outExpr>
| "IsNot" (. op = BinaryOperatorType.ReferenceInequality; .)
)
(
ShiftExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, op, expr); .)
|
ShiftExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; .)
| (. Location startLocation2 = la.Location; .)
"Not"
ShiftExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, op, new UnaryOperatorExpression(expr, UnaryOperatorType.Not)); .)
ShiftExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, op, new UnaryOperatorExpression(expr, UnaryOperatorType.Not) { StartLocation = startLocation2, EndLocation = t.EndLocation }) { StartLocation = startLocation, EndLocation = t.EndLocation }; .)
)
}
.
@ -2017,6 +2020,7 @@ ShiftExpr<out Expression outExpr> @@ -2017,6 +2020,7 @@ ShiftExpr<out Expression outExpr>
(.
Expression expr;
BinaryOperatorType op = BinaryOperatorType.None;
Location startLocation = la.Location;
.) =
ConcatenationExpr<out outExpr>
{
@ -2024,20 +2028,21 @@ ShiftExpr<out Expression outExpr> @@ -2024,20 +2028,21 @@ ShiftExpr<out Expression outExpr>
"<<" (. op = BinaryOperatorType.ShiftLeft; .)
| ">>" (. op = BinaryOperatorType.ShiftRight; .)
)
ConcatenationExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, op, expr); .)
ConcatenationExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; .)
}
.
ConcatenationExpr<out Expression outExpr>
(. Expression expr; .)
(. Expression expr; Location startLocation = la.Location; .)
=
AdditiveExpr<out outExpr> { "&" AdditiveExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.Concat, expr); .) }
AdditiveExpr<out outExpr> { "&" AdditiveExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.Concat, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; .) }
.
AdditiveExpr<out Expression outExpr>
(.
Expression expr;
BinaryOperatorType op = BinaryOperatorType.None;
Location startLocation = la.Location;
.) =
ModuloExpr<out outExpr>
{
@ -2045,26 +2050,27 @@ AdditiveExpr<out Expression outExpr> @@ -2045,26 +2050,27 @@ AdditiveExpr<out Expression outExpr>
"+" (. op = BinaryOperatorType.Add; .)
| "-" (. op = BinaryOperatorType.Subtract; .)
)
ModuloExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, op, expr); .)
ModuloExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; .)
}
.
ModuloExpr<out Expression outExpr>
(. Expression expr; .)
(. Expression expr; Location startLocation = la.Location; .)
=
IntegerDivisionExpr<out outExpr> { "Mod" IntegerDivisionExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.Modulus, expr); .) }
IntegerDivisionExpr<out outExpr> { "Mod" IntegerDivisionExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.Modulus, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; .) }
.
IntegerDivisionExpr<out Expression outExpr>
(. Expression expr; .)
(. Expression expr; Location startLocation = la.Location; .)
=
MultiplicativeExpr<out outExpr> { "\\" MultiplicativeExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.DivideInteger, expr); .) }
MultiplicativeExpr<out outExpr> { "\\" MultiplicativeExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.DivideInteger, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; .) }
.
MultiplicativeExpr<out Expression outExpr>
(.
Expression expr;
BinaryOperatorType op = BinaryOperatorType.None;
Location startLocation = la.Location;
.) =
UnaryExpr<out outExpr>
{
@ -2072,7 +2078,7 @@ MultiplicativeExpr<out Expression outExpr> @@ -2072,7 +2078,7 @@ MultiplicativeExpr<out Expression outExpr>
"*" (. op = BinaryOperatorType.Multiply; .)
| "/" (. op = BinaryOperatorType.Divide; .)
)
UnaryExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, op, expr); .)
UnaryExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; .)
}
.
@ -2080,6 +2086,7 @@ UnaryExpr<out Expression uExpr> @@ -2080,6 +2086,7 @@ UnaryExpr<out Expression uExpr>
(.
Expression expr;
UnaryOperatorType uop = UnaryOperatorType.None;
Location startLocation = la.Location;
bool isUOp = false;
.) =
{ "+" (. uop = UnaryOperatorType.Plus; isUOp = true; .)
@ -2089,7 +2096,7 @@ UnaryExpr<out Expression uExpr> @@ -2089,7 +2096,7 @@ UnaryExpr<out Expression uExpr>
ExponentiationExpr<out expr>
(.
if (isUOp) {
uExpr = new UnaryOperatorExpression(expr, uop);
uExpr = new UnaryOperatorExpression(expr, uop) { StartLocation = startLocation, EndLocation = t.EndLocation };
} else {
uExpr = expr;
}
@ -2097,9 +2104,9 @@ UnaryExpr<out Expression uExpr> @@ -2097,9 +2104,9 @@ UnaryExpr<out Expression uExpr>
.
ExponentiationExpr<out Expression outExpr>
(. Expression expr; .)
(. Expression expr; Location startLocation = la.Location; .)
=
SimpleExpr<out outExpr> { "^" SimpleExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.Power, expr); .) }
SimpleExpr<out outExpr> { "^" SimpleExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.Power, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; .) }
.
ObjectCreateExpression<out Expression oce>

6
src/Libraries/NRefactory/Test/Parser/Expressions/BinaryOperatorExpressionTests.cs

@ -279,12 +279,6 @@ namespace ICSharpCode.NRefactory.Tests.Ast @@ -279,12 +279,6 @@ namespace ICSharpCode.NRefactory.Tests.Ast
SameOperatorPrecedenceTest("Or", BinaryOperatorType.BitwiseOr, "Xor", BinaryOperatorType.ExclusiveOr, true);
}
[Test]
public void VBNetTest()
{
VBNetTestBinaryOperatorExpressionTest("a ^ b", BinaryOperatorType.Power);
}
[Test]
public void VBNetPowerTest()
{

Loading…
Cancel
Save