thp-zig/src/01_lexic/token.zig

26 lines
500 B
Zig
Raw Normal View History

2024-11-16 21:12:15 +00:00
pub const TokenType = enum {
Int,
Float,
};
pub const Token = struct {
value: []const u8,
token_type: TokenType,
start_pos: usize,
pub fn init(value: []const u8, token_type: TokenType, start: usize) Token {
return Token{
.value = value,
.token_type = token_type,
.start_pos = start,
};
}
};
2024-11-16 23:34:36 +00:00
pub const LexError = error{
LeadingZero,
Incomplete,
2024-11-17 12:37:38 +00:00
IncompleteFloatingNumber,
2024-11-17 12:54:12 +00:00
IncompleteScientificNumber,
2024-11-16 23:34:36 +00:00
};