kojote/parse/types.ha
Lobo Torres 04efdcac8e add pound literals for booleans and characters
replaces the old character literal syntax that i really didn't like and
feels more scheme-ish
2024-12-04 21:40:14 -03:00

32 lines
921 B
Hare

use io;
use fmt;
export type invalid = !(uint, uint);
export type unterminated = !(const str, uint, uint);
export type error = !(invalid | unterminated | io::error);
export type quotstart = void;
export type quotend = void;
export type mapstart = void;
export type mapend = void;
export type comment = struct { v: str };
export type word = struct { v: str };
export type symbol = struct { v: str, kw: bool };
export type token = (quotstart | quotend | mapstart | mapend |
word | symbol | comment | str | rune | bool);
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: unterminated =>
return fmt::bsprintf(buf,
"{}:{}: Unterminated {} found", err.1, err.2, err.0);
case let err: io::error =>
return io::strerror(err);
};
};