feat(lexer): Parentheses and quoted strings
This commit is contained in:
parent
e1f632ca40
commit
dc9e43e9ba
4 changed files with 155 additions and 23 deletions
28
tests/lexer/LexerScanPrologTest.kt
Normal file
28
tests/lexer/LexerScanPrologTest.kt
Normal file
|
@ -0,0 +1,28 @@
|
|||
package lexer
|
||||
|
||||
import org.junit.jupiter.api.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class LexerScanPrologTest {
|
||||
@Test
|
||||
fun scan_simple_atom() {
|
||||
val tokens = Lexer("atom.").scan()
|
||||
|
||||
assertEquals(3, tokens.size)
|
||||
|
||||
assertEquals(TokenType.ALPHANUMERIC, tokens[0].type, "Expected ALPHANUMERIC token, got ${tokens[0].type}")
|
||||
assertEquals(TokenType.DOT, tokens[1].type, "Expected DOT token, got ${tokens[1].type}")
|
||||
assertEquals(TokenType.EOF, tokens[2].type, "Expected EOF token, got ${tokens[2].type}")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun scan_variable() {
|
||||
val tokens = Lexer("X.").scan()
|
||||
|
||||
assertEquals(3, tokens.size)
|
||||
|
||||
assertEquals(TokenType.ALPHANUMERIC, tokens[0].type, "Expected ALPHANUMERIC token, got ${tokens[0].type}")
|
||||
assertEquals(TokenType.DOT, tokens[1].type, "Expected DOT token, got ${tokens[1].type}")
|
||||
assertEquals(TokenType.EOF, tokens[2].type, "Expected EOF token, got ${tokens[2].type}")
|
||||
}
|
||||
}
|
Reference in a new issue