32 lines
609 B
Zig
32 lines
609 B
Zig
|
const std = @import("std");
|
||
|
const tokens = @import("tokens.std");
|
||
|
|
||
|
const Allocator = std.mem.Allocator;
|
||
|
|
||
|
pub const TokenError = error{
|
||
|
Unexpected,
|
||
|
Unterminated,
|
||
|
};
|
||
|
|
||
|
fn isDigit(char: u8) bool {
|
||
|
return char >= '0' and char <= '9';
|
||
|
}
|
||
|
|
||
|
fn isAlpha(c: u8) bool {
|
||
|
return (c >= 'a' and c <= 'z') or
|
||
|
(c >= 'A' and c <= 'Z') or
|
||
|
c == '_';
|
||
|
}
|
||
|
|
||
|
fn isAlphaNumeric(char: u8) bool {
|
||
|
return isAlpha(char) or isDigit(char);
|
||
|
}
|
||
|
|
||
|
pub const Scanner = struct {
|
||
|
allocator: *Allocator,
|
||
|
|
||
|
pub fn init(allocator: *Allocator) Scanner {
|
||
|
return Scanner{ .allocator = allocator };
|
||
|
}
|
||
|
};
|