Browse Source

Update string resources.

Improve lexer code determining the type of integer literals.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.1@2639 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts 2.2.1
Daniel Grunwald 19 years ago
parent
commit
5f9f3db75c
  1. BIN
      data/resources/StringResources.cz.resources
  2. BIN
      data/resources/StringResources.es-mx.resources
  3. BIN
      data/resources/StringResources.es.resources
  4. BIN
      data/resources/StringResources.nl.resources
  5. BIN
      data/resources/StringResources.se.resources
  6. BIN
      data/resources/StringResources.tr.resources
  7. 17
      src/Libraries/NRefactory/Project/Src/Lexer/CSharp/Lexer.cs
  8. 9
      src/Libraries/NRefactory/Test/Parser/Expressions/ObjectCreateExpressionTests.cs

BIN
data/resources/StringResources.cz.resources

Binary file not shown.

BIN
data/resources/StringResources.es-mx.resources

Binary file not shown.

BIN
data/resources/StringResources.es.resources

Binary file not shown.

BIN
data/resources/StringResources.nl.resources

Binary file not shown.

BIN
data/resources/StringResources.se.resources

Binary file not shown.

BIN
data/resources/StringResources.tr.resources

Binary file not shown.

17
src/Libraries/NRefactory/Project/Src/Lexer/CSharp/Lexer.cs

@ -320,29 +320,26 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
} }
} }
// Try to determine a parsable value using ranges. (Quick hack!) // Try to determine a parsable value using ranges.
decimal d = 0;
if (ishex) {
ulong result; ulong result;
if (ulong.TryParse(digit, NumberStyles.HexNumber, null, out result)) { if (ishex) {
d = result; if (!ulong.TryParse(digit, NumberStyles.HexNumber, null, out result)) {
} else {
errors.Error(y, x, String.Format("Can't parse hexadecimal constant {0}", digit)); errors.Error(y, x, String.Format("Can't parse hexadecimal constant {0}", digit));
return new Token(Tokens.Literal, x, y, stringValue.ToString(), 0); return new Token(Tokens.Literal, x, y, stringValue.ToString(), 0);
} }
} else { } else {
if (!decimal.TryParse(digit, NumberStyles.Integer, null, out d)) { if (!ulong.TryParse(digit, NumberStyles.Integer, null, out result)) {
errors.Error(y, x, String.Format("Can't parse integral constant {0}", digit)); errors.Error(y, x, String.Format("Can't parse integral constant {0}", digit));
return new Token(Tokens.Literal, x, y, stringValue.ToString(), 0); return new Token(Tokens.Literal, x, y, stringValue.ToString(), 0);
} }
} }
if (d < long.MinValue || d > long.MaxValue) { if (result > long.MaxValue) {
islong = true; islong = true;
isunsigned = true; isunsigned = true;
} else if (d < uint.MinValue || d > uint.MaxValue) { } else if (result > uint.MaxValue) {
islong = true; islong = true;
} else if (d < int.MinValue || d > int.MaxValue) { } else if (result > int.MaxValue) {
isunsigned = true; isunsigned = true;
} }

9
src/Libraries/NRefactory/Test/Parser/Expressions/ObjectCreateExpressionTests.cs

@ -33,6 +33,15 @@ namespace ICSharpCode.NRefactory.Tests.Ast
CheckSimpleObjectCreateExpression(ParseUtilCSharp.ParseExpression<ObjectCreateExpression>("new MyObject(1, 2, 3)")); CheckSimpleObjectCreateExpression(ParseUtilCSharp.ParseExpression<ObjectCreateExpression>("new MyObject(1, 2, 3)"));
} }
[Test]
public void CSharpNullableObjectCreateExpressionTest()
{
ObjectCreateExpression oce = ParseUtilCSharp.ParseExpression<ObjectCreateExpression>("new IntPtr?(1)");
Assert.AreEqual("System.Nullable", oce.CreateType.SystemType);
Assert.AreEqual(1, oce.CreateType.GenericTypes.Count);
Assert.AreEqual("IntPtr", oce.CreateType.GenericTypes[0].Type);
}
[Test] [Test]
public void CSharpInvalidNestedObjectCreateExpressionTest() public void CSharpInvalidNestedObjectCreateExpressionTest()
{ {

Loading…
Cancel
Save