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

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

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

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

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

Loading…
Cancel
Save