2019-06-04 02:12:16 +00:00
|
|
|
pub const TokenType = enum {
|
|
|
|
// basic tokens
|
|
|
|
LeftParen,
|
|
|
|
RightParen,
|
|
|
|
LeftBrace,
|
|
|
|
RightBrace,
|
|
|
|
LeftSquare,
|
|
|
|
RightSquare,
|
|
|
|
Dot,
|
|
|
|
Equal,
|
|
|
|
Semicolon,
|
|
|
|
Comma,
|
|
|
|
Colon,
|
|
|
|
Ampersand,
|
|
|
|
Pipe,
|
|
|
|
QuestionMark,
|
|
|
|
DollarSign,
|
|
|
|
|
|
|
|
// math operators
|
|
|
|
Plus,
|
|
|
|
Minus,
|
|
|
|
Star,
|
|
|
|
Slash,
|
|
|
|
Modulo,
|
|
|
|
|
|
|
|
// one-two char tokens
|
|
|
|
DotEqual,
|
|
|
|
LeftDoubleChevron, // AKA "<<"
|
|
|
|
PlusPlus,
|
|
|
|
PlusEqual,
|
|
|
|
MinusEqual,
|
|
|
|
|
2019-06-04 18:06:57 +00:00
|
|
|
// comparison ones
|
|
|
|
EqualEqual,
|
|
|
|
Less,
|
2019-06-04 02:12:16 +00:00
|
|
|
LessEqual,
|
2019-06-04 18:06:57 +00:00
|
|
|
Greater,
|
2019-06-04 02:12:16 +00:00
|
|
|
GreaterEqual,
|
|
|
|
Bang,
|
|
|
|
BangEqual,
|
|
|
|
|
|
|
|
// complex types
|
|
|
|
Integer,
|
|
|
|
Float,
|
|
|
|
String,
|
|
|
|
Identifier,
|
|
|
|
|
|
|
|
// keywords
|
|
|
|
Break,
|
|
|
|
Const,
|
|
|
|
Continue,
|
|
|
|
Defer,
|
|
|
|
Else,
|
|
|
|
Enum,
|
|
|
|
Fn,
|
|
|
|
For,
|
|
|
|
Go,
|
|
|
|
Goto,
|
|
|
|
If,
|
|
|
|
Import,
|
|
|
|
In,
|
|
|
|
Interface,
|
|
|
|
Match,
|
|
|
|
Module,
|
|
|
|
Mut,
|
|
|
|
Or,
|
|
|
|
Return,
|
|
|
|
Struct,
|
|
|
|
Type,
|
2019-06-06 01:06:12 +00:00
|
|
|
True,
|
|
|
|
False,
|
|
|
|
None,
|
2019-06-04 18:06:57 +00:00
|
|
|
|
2019-08-24 19:00:22 +00:00
|
|
|
Println,
|
|
|
|
|
2019-06-04 18:06:57 +00:00
|
|
|
EOF,
|
2019-06-04 02:12:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
pub const Token = struct {
|
|
|
|
ttype: TokenType,
|
2019-06-04 18:06:57 +00:00
|
|
|
lexeme: []const u8,
|
|
|
|
line: usize,
|
2019-06-04 02:12:16 +00:00
|
|
|
};
|