Skip to content

Commit

Permalink
fix #441
Browse files Browse the repository at this point in the history
  • Loading branch information
b3b00 committed Apr 26, 2024
1 parent ca8eae2 commit 85123de
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/sly/lexer/fsm/FSMLexer.cs
Expand Up @@ -452,7 +452,7 @@ private List<Token<N>> ConsumeIgnored(ReadOnlyMemory<char> source, LexerPosition
var currentCharacter = source.At<char>(position.Index);
if (WhiteSpaces.Contains(currentCharacter))
{
var whiteToken = new Token<N>(default(N), source.Slice(position.Index, 1), position,
var whiteToken = new Token<N>(default(N), source.Slice(position.Index, 1), position,
CommentType.No,
Channels.WhiteSpaces, isWhiteSpace: true, decimalSeparator: DecimalSeparator);
ignoredTokens.Add(whiteToken);
Expand All @@ -472,12 +472,18 @@ private List<Token<N>> ConsumeIgnored(ReadOnlyMemory<char> source, LexerPosition
position.Column = 0;
position.Line++;
eolReached = true;
while (position.Index < source.Length && eol != EolType.No)
{
eol = EOLManager.IsEndOfLine(source, position.Index);
if (eol != EolType.No)
{
position.Index += eol == EolType.Windows ? 2 : 1;
position.Column = 0;
position.Line++;
}
}
continue;
}
else
{
break;
}
}

break;
Expand Down
17 changes: 17 additions & 0 deletions tests/ParserTests/samples/IndentedWhileTests.cs
Expand Up @@ -326,5 +326,22 @@ public void TestIndentationError()
Check.That(error.Line).IsEqualTo(4);
Check.That(error.ErrorMessage).Contains("Indentation error");
}

[Fact]
public void TestEmptyLines()
{
var buildResult = buildParser();
var parser = buildResult.Result;
var program = @"
# infinite loop
i:= 2
while true do
skip
";
var result = parser.Parse(program);
Check.That(result).IsOkParsing();
}
}
}

0 comments on commit 85123de

Please sign in to comment.