diff --git a/Upsilon/Parser/Lexer.cs b/Upsilon/Parser/Lexer.cs index 3b436fe..d1bbe60 100644 --- a/Upsilon/Parser/Lexer.cs +++ b/Upsilon/Parser/Lexer.cs @@ -250,7 +250,7 @@ namespace Upsilon.Parser var str = stringBuilder.ToString(); if (kind == SyntaxKind.Identifier) { - return new IdentifierToken(str, new TextSpan(startLine, start, _linePosition, _position)); + return new IdentifierToken(str, new TextSpan(startLine, start, _linePosition, _position + 1)); } if (kind == SyntaxKind.ReturnKeyword) diff --git a/Upsilon/Text/SourceText.cs b/Upsilon/Text/SourceText.cs index 39cf7a7..8209f58 100644 --- a/Upsilon/Text/SourceText.cs +++ b/Upsilon/Text/SourceText.cs @@ -17,6 +17,7 @@ namespace Upsilon.Text if (startPosition < 0) startPosition = 0; if (startLine == endLine) { + if (endPosition > _text[startLine].Length) endPosition = _text[startLine].Length; return _text[startLine].Substring(startPosition, endPosition - startPosition); } var sb = new StringBuilder(); diff --git a/Upsilon/Text/SourceTextLine.cs b/Upsilon/Text/SourceTextLine.cs deleted file mode 100644 index b85f17c..0000000 --- a/Upsilon/Text/SourceTextLine.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace Upsilon.Text -{ - public struct SourceTextLine - { - public SourceTextLine(int start, int lineLength) - { - Start = start; - LineLength = lineLength; - } - - public int Start { get; } - public int LineLength { get; } - public int End => Start + LineLength; - } -} \ No newline at end of file