kojote/types.ha

26 lines
618 B
Hare
Raw Normal View History

2024-12-04 16:29:11 +00:00
use io;
use fmt;
export type invalid = !(uint, uint);
export type error = !(invalid | io::error);
export type punctuation = enum uint {
2024-12-04 02:41:23 +00:00
LEFT_PAREN, RIGHT_PAREN,
LEFT_SQUARE_BRACKET, RIGHT_SQUARE_BRACKET,
LEFT_CURLY_BRACKET, RIGHT_CURLY_BRACKET,
BACKSLASH, COLON,
};
2024-12-04 16:29:11 +00:00
export type word = struct { v: str };
export type token = (punctuation | word | str);
export fn strerror(err: error) const str = {
static let buf: [64]u8 = [0...];
match (err) {
case let err: invalid =>
return fmt::bsprintf(buf,
"{}:{}: Invalid token found", err.0, err.1);
case let err: io::error =>
return io::strerror(err);
};
};