Browse Source

worked on Positions and removed some debug Console.WriteLine

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@301 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Andrea Paatz 20 years ago
parent
commit
639a4d231f
  1. 4
      src/Libraries/NRefactory/Project/Src/Lexer/AbstractLexer.cs
  2. 8
      src/Libraries/NRefactory/Project/Src/Lexer/CSharp/Lexer.cs
  3. 44
      src/Libraries/NRefactory/Test/Lexer/CSharp/LexerPositionTests.cs

4
src/Libraries/NRefactory/Project/Src/Lexer/AbstractLexer.cs

@ -102,7 +102,7 @@ namespace ICSharpCode.NRefactory.Parser @@ -102,7 +102,7 @@ namespace ICSharpCode.NRefactory.Parser
/// </summary>
public Token Token {
get {
Console.WriteLine("Call to Token");
// Console.WriteLine("Call to Token");
return lastToken;
}
}
@ -112,7 +112,7 @@ namespace ICSharpCode.NRefactory.Parser @@ -112,7 +112,7 @@ namespace ICSharpCode.NRefactory.Parser
/// </summary>
public Token LookAhead {
get {
Console.WriteLine("Call to LookAhead");
// Console.WriteLine("Call to LookAhead");
return curToken;
}
}

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

@ -71,7 +71,7 @@ namespace ICSharpCode.NRefactory.Parser.CSharp @@ -71,7 +71,7 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
if (next == -1) {
errors.Error(Line, Col, String.Format("EOF after @"));
} else {
int x = Col;
int x = Col - 1;
int y = Line;
ch = (char)next;
if (ch == '"') {
@ -358,12 +358,12 @@ namespace ICSharpCode.NRefactory.Parser.CSharp @@ -358,12 +358,12 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
Token ReadVerbatimString()
{
int x = Col;
int y = Line;
int nextChar;
sb.Length = 0;
originalValue.Length = 0;
originalValue.Append("@\"");
int x = Col - 2; // @ and " already read
int y = Line;
int nextChar;
while ((nextChar = ReaderRead()) != -1) {
char ch = (char)nextChar;

44
src/Libraries/NRefactory/Test/Lexer/CSharp/LexerPositionTests.cs

@ -78,33 +78,35 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.CSharp @@ -78,33 +78,35 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.CSharp
t = l.NextToken();
Assert.AreEqual(new Point(9, 1), t.Location);
}
[Test]
public void TestFloationPointNumber()
{
ILexer l = GenerateLexer("0.142 public");
Token t = l.NextToken();
Assert.AreEqual(new Point(1, 1), t.Location);
t = l.NextToken();
Assert.AreEqual(new Point(7, 1), t.Location);
}
// [Test]
// public void TestVerbatimString()
// public void TestFloationPointNumber()
// {
// ILexer l = GenerateLexer("@\"a\"\"a\" public");
// ILexer l = GenerateLexer("0.142 public");
// Token t = l.NextToken();
// Assert.AreEqual(new Point(1, 1), t.Location);
// t = l.NextToken();
// Assert.AreEqual(new Point(9, 1), t.Location);
// }
// [Test]
// public void TestNoFloationPointNumber()
// {
// ILexer l = GenerateLexer("0.a");
// Token t = l.NextToken();
// Assert.AreEqual(new Point(1, 1), t.Location);
// t = l.NextToken();
// Assert.AreEqual(new Point(3, 1), t.Location);
// Assert.AreEqual(new Point(7, 1), t.Location);
// }
[Test]
public void TestVerbatimString()
{
ILexer l = GenerateLexer("@\"a\"\"a\" public");
Token t = l.NextToken();
Assert.AreEqual(new Point(1, 1), t.Location);
t = l.NextToken();
Assert.AreEqual(new Point(9, 1), t.Location);
}
[Test]
public void TestNoFloationPointNumber()
{
ILexer l = GenerateLexer("0.a");
Token t = l.NextToken();
Console.WriteLine(t);
Assert.AreEqual(new Point(1, 1), t.Location);
t = l.NextToken();
Console.WriteLine(t);
Assert.AreEqual(new Point(3, 1), t.Location);
}
[Test]
public void TestNumber()
{

Loading…
Cancel
Save