A VM bytecode interpreter for EduScript, an educational language

This is nice. Here’s a stylistic suggestion: since files are structs in Zig, you could declare some types, like Token at the top level of their own file, e.g:

// file: Token.zig

// fields can be declared at the top level:
type: Type,
lexeme: []const u8,
literal: ?LiteralValue,
line: u32,
pos: usize,

// Now you have `Token.Type` instead of `token.TokenType`.
pub const Type = enum {
    // It is convention for enum variants to be snake_case.
    dot,
    // ...

    // Variant names that clash with keywords can use @"identifer" syntax.
   @"if",
}

Also, in main you can remove the direct import of token by using enum literals, and therefore remove the direct import of token.zig:

        if (token.type == .eof) // ...
3 Likes