feat(lexer): Scan empty string
This commit is contained in:
parent
4054ed5fce
commit
f72501fde2
5 changed files with 45 additions and 0 deletions
11
src/lexer/Lexer.kt
Normal file
11
src/lexer/Lexer.kt
Normal file
|
@ -0,0 +1,11 @@
|
|||
package lexer
|
||||
|
||||
class Lexer {
|
||||
fun scan(source: String): List<Token> {
|
||||
if (source.isEmpty()) {
|
||||
return listOf(Token(TokenType.EOF, LexerPosition(1, 1, 0)))
|
||||
}
|
||||
|
||||
return emptyList()
|
||||
}
|
||||
}
|
5
src/lexer/LexerPosition.kt
Normal file
5
src/lexer/LexerPosition.kt
Normal file
|
@ -0,0 +1,5 @@
|
|||
package lexer
|
||||
|
||||
class LexerPosition(val line: Int, val column: Int, val length: Int) {
|
||||
// Do nothing
|
||||
}
|
8
src/lexer/Token.kt
Normal file
8
src/lexer/Token.kt
Normal file
|
@ -0,0 +1,8 @@
|
|||
package lexer
|
||||
|
||||
class Token(
|
||||
val type: TokenType,
|
||||
val position: LexerPosition
|
||||
) {
|
||||
// Do nothing
|
||||
}
|
5
src/lexer/TokenType.kt
Normal file
5
src/lexer/TokenType.kt
Normal file
|
@ -0,0 +1,5 @@
|
|||
package lexer
|
||||
|
||||
enum class TokenType {
|
||||
EOF
|
||||
}
|
Reference in a new issue