luaaaaah/src/types.zig

42 lines
733 B
Zig

const std = @import("std");
pub const Numeral = union(enum)
{
Integer: i64,
Float: f64,
};
pub const Table = struct
{
items: std.HashMap(Value, Value, std.hash_map.AutoContext(Value), std.hash_map.default_max_load_percentage),
pub fn insert(self: *const Table, key: Value, value: Value) !bool
{
self.items.put(key, value);
}
pub fn get(self: *const Table, key: Value) !Value
{
const value = self.items.get(key);
return if(value == null) Value.Nil else value.?;
}
};
pub const Value = union(enum)
{
Nil,
Bool: bool,
Numeral: Numeral,
String: []const u8,
Table: *Table,
};
pub const CodeRegion = struct
{
start: ?CodeLocation,
length: usize,
};
pub const CodeLocation = struct
{
line: usize,
col: usize,
};