feat(lexer): add token definitions
This commit is contained in:
1 parent
9d2c9340f0
commit
3dca55184f
1 file changed
+64
@@ -0,0 +1,64 @@
|
|||||||
|
package lumen.lexer
|
||||||
|
|
||||||
|
enum class TokenType {
|
||||||
|
// literals
|
||||||
|
IntLiteral,
|
||||||
|
DoubleLiteral,
|
||||||
|
StringLiteral,
|
||||||
|
Identifier,
|
||||||
|
|
||||||
|
// keywords
|
||||||
|
Let,
|
||||||
|
Var,
|
||||||
|
Fn,
|
||||||
|
Return,
|
||||||
|
If,
|
||||||
|
Else,
|
||||||
|
While,
|
||||||
|
For,
|
||||||
|
In,
|
||||||
|
True,
|
||||||
|
False,
|
||||||
|
Nil,
|
||||||
|
And,
|
||||||
|
Or,
|
||||||
|
Not,
|
||||||
|
Import,
|
||||||
|
|
||||||
|
// punctuation
|
||||||
|
Plus,
|
||||||
|
Minus,
|
||||||
|
Star,
|
||||||
|
Slash,
|
||||||
|
Percent,
|
||||||
|
Assign,
|
||||||
|
EqualEqual,
|
||||||
|
BangEqual,
|
||||||
|
Less,
|
||||||
|
LessEqual,
|
||||||
|
Greater,
|
||||||
|
GreaterEqual,
|
||||||
|
LeftParen,
|
||||||
|
RightParen,
|
||||||
|
LeftBracket,
|
||||||
|
RightBracket,
|
||||||
|
LeftBrace,
|
||||||
|
RightBrace,
|
||||||
|
Comma,
|
||||||
|
Colon,
|
||||||
|
Semicolon,
|
||||||
|
Dot,
|
||||||
|
Newline,
|
||||||
|
|
||||||
|
Eof
|
||||||
|
}
|
||||||
|
|
||||||
|
data class Token(
|
||||||
|
val type: TokenType,
|
||||||
|
val lexeme: String,
|
||||||
|
val line: Int,
|
||||||
|
val column: Int = 1,
|
||||||
|
val intValue: Long = 0L,
|
||||||
|
val doubleValue: Double = 0.0,
|
||||||
|
val stringValue: String = ""
|
||||||
|
)
|
||||||
Reference in new issue
Block a user