vig/src/tokens.zig
2019-06-05 22:06:12 -03:00

81 lines
1 KiB
Zig

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,
// comparison ones
EqualEqual,
Less,
LessEqual,
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,
True,
False,
None,
EOF,
};
pub const Token = struct {
ttype: TokenType,
lexeme: []const u8,
line: usize,
};