Browse Source

Fixed another problem related to ternary expressions and "is" expressions.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.1@2485 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
b95469bf0a
  1. 2
      src/Libraries/NRefactory/Project/Src/Lexer/CSharp/KeywordList.txt
  2. 2
      src/Libraries/NRefactory/Project/Src/Lexer/CSharp/Tokens.cs
  3. 20
      src/Libraries/NRefactory/Test/Parser/Expressions/ConditionalExpressionTests.cs

2
src/Libraries/NRefactory/Project/Src/Lexer/CSharp/KeywordList.txt

@ -161,7 +161,7 @@ OverloadableBinaryOp("+", "-", "*", "/", "%", "&", "|", "^", "<<", "==", "!=", " @@ -161,7 +161,7 @@ OverloadableBinaryOp("+", "-", "*", "/", "%", "&", "|", "^", "<<", "==", "!=", "
TypeKW("char", "bool", "object", "string", "sbyte", "byte", "short", "ushort", "int", "uint", "long", "ulong", "float", "double", "decimal")
UnaryHead("+", "-", "!", "~", "*", "++", "--", "&")
AssnStartOp("+", "-", "!", "~", "*")
CastFollower(Identifier, Literal, "(", "new", "this", "base", "null", "checked", "unchecked", "typeof", "sizeof", "delegate", @OverloadableUnaryOp)
CastFollower(Identifier, Literal, "(", "new", "this", "base", "null", "checked", "unchecked", "typeof", "sizeof", "delegate", @OverloadableUnaryOp, @UnaryOp)
AssgnOps("=", "+=", "-=", "*=", "/=", "%=", "&=", "|=", "<<=")
UnaryOp("+", "-", "!", "~", "*", "++", "--", "&")
TypeDeclarationKW("class", "interface", "struct", "enum", "delegate")

2
src/Libraries/NRefactory/Project/Src/Lexer/CSharp/Tokens.cs

@ -158,7 +158,7 @@ namespace ICSharpCode.NRefactory.Parser.CSharp @@ -158,7 +158,7 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
public static BitArray TypeKW = NewSet(Char, Bool, Object, String, Sbyte, Byte, Short, Ushort, Int, Uint, Long, Ulong, Float, Double, Decimal);
public static BitArray UnaryHead = NewSet(Plus, Minus, Not, BitwiseComplement, Times, Increment, Decrement, BitwiseAnd);
public static BitArray AssnStartOp = NewSet(Plus, Minus, Not, BitwiseComplement, Times);
public static BitArray CastFollower = NewSet(Identifier, Literal, OpenParenthesis, New, This, Base, Null, Checked, Unchecked, Typeof, Sizeof, Delegate, Minus, Not, BitwiseComplement, Increment, Decrement, True, False);
public static BitArray CastFollower = NewSet(Identifier, Literal, OpenParenthesis, New, This, Base, Null, Checked, Unchecked, Typeof, Sizeof, Delegate, Minus, Not, BitwiseComplement, Increment, Decrement, True, False, Plus, Minus, Not, BitwiseComplement, Times, Increment, Decrement, BitwiseAnd);
public static BitArray AssgnOps = NewSet(Assign, PlusAssign, MinusAssign, TimesAssign, DivAssign, ModAssign, BitwiseAndAssign, BitwiseOrAssign, ShiftLeftAssign);
public static BitArray UnaryOp = NewSet(Plus, Minus, Not, BitwiseComplement, Times, Increment, Decrement, BitwiseAnd);
public static BitArray TypeDeclarationKW = NewSet(Class, Interface, Struct, Enum, Delegate);

20
src/Libraries/NRefactory/Test/Parser/Expressions/ConditionalExpressionTests.cs

@ -38,6 +38,16 @@ namespace ICSharpCode.NRefactory.Tests.Ast @@ -38,6 +38,16 @@ namespace ICSharpCode.NRefactory.Tests.Ast
Assert.IsTrue(ce.FalseExpression is FieldReferenceExpression);
}
[Test]
public void CSharpConditionalIsWithNullableExpressionTest()
{
ConditionalExpression ce = ParseUtilCSharp.ParseExpression<ConditionalExpression>("a is b? ? a() : a.B");
Assert.IsTrue(ce.Condition is TypeOfIsExpression);
Assert.IsTrue(ce.TrueExpression is InvocationExpression);
Assert.IsTrue(ce.FalseExpression is FieldReferenceExpression);
}
[Test]
public void CSharpConditionalIsExpressionTest2()
{
@ -68,6 +78,16 @@ namespace ICSharpCode.NRefactory.Tests.Ast @@ -68,6 +78,16 @@ namespace ICSharpCode.NRefactory.Tests.Ast
Assert.IsTrue(ce.TrueExpression is UnaryOperatorExpression);
Assert.IsTrue(ce.FalseExpression is PrimitiveExpression);
}
[Test]
public void CSharpConditionalIsWithExplicitPositiveValue()
{
ConditionalExpression ce = ParseUtilCSharp.ParseExpression<ConditionalExpression>("a is b ? +1 : 1");
Assert.IsTrue(ce.Condition is TypeOfIsExpression);
Assert.IsTrue(ce.TrueExpression is UnaryOperatorExpression);
Assert.IsTrue(ce.FalseExpression is PrimitiveExpression);
}
#endregion
#region VB.NET

Loading…
Cancel
Save