feat(lexer): Comments

This commit is contained in:
Tibo De Peuter 2025-03-27 18:34:24 +01:00
parent dc9e43e9ba
commit 8429733200
Signed by: tdpeuter
GPG key ID: 38297DE43F75FFE2
3 changed files with 61 additions and 3 deletions

View file

@ -167,4 +167,27 @@ class LexerScanTest {
assertEquals("string with space", tokens[0].value, "Expected 'string with space', got ${tokens[0].value}")
}
@Test
fun scan_comments_returns_nothing() {
val lexer = Lexer("% comment")
val tokens = lexer.scan()
assertEquals(1, tokens.size)
assertEquals(TokenType.EOF, tokens[0].type, "Expected EOF token, got ${tokens[0].type}")
}
@Test
fun scan_comment_and_sentence_returns_sentence() {
val tokens = Lexer("""
% comment
sentence
""".trimIndent()).scan()
assertEquals(2, tokens.size)
assertEquals(TokenType.ALPHANUMERIC, tokens[0].type, "Expected ALPHANUMERIC token, got ${tokens[0].type}")
assertEquals("sentence", tokens[0].value, "Expected 'sentence', got ${tokens[0].value}")
}
}