Fixing how the Lexer handles text.

Scanning a file has all the lines terminating with a '\n' newline
character, but when giving the text directly to the lexer via the
scan_text function it should not append a newline at the end if there
was no newline in the original input.
This commit is contained in:
Myrddin Dundragon 2025-05-05 18:11:47 -04:00
parent 34a579332d
commit 693ff20224

View File

@ -170,6 +170,13 @@ impl Lexer
cursor.column = 0; cursor.column = 0;
} }
// Remove the last newline character if the text did not end with a
// newline.
if !text.ends_with('\n')
{
stream.pop();
}
Ok(transform(&stream)) Ok(transform(&stream))
} }