vig/src/tokens.zig

84 lines
1 KiB
Zig
Raw Normal View History

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,
LessEqual,
2019-06-04 18:06:57 +00:00
Greater,
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,
};
pub const Token = struct {
ttype: TokenType,
2019-06-04 18:06:57 +00:00
lexeme: []const u8,
line: usize,
};