2023-10-08 21:40:44 +02:00
|
|
|
const std = @import("std");
|
|
|
|
|
2023-09-15 11:07:50 +02:00
|
|
|
pub const Numeral = union(enum)
|
|
|
|
{
|
|
|
|
Integer: i64,
|
|
|
|
Float: f64,
|
|
|
|
};
|
2023-10-08 21:40:44 +02:00
|
|
|
pub const Table = struct
|
|
|
|
{
|
2023-11-17 01:37:29 +01:00
|
|
|
items: std.HashMap(Value, Value, std.hash_map.AutoContext(Value), std.hash_map.default_max_load_percentage),
|
2023-10-08 21:40:44 +02:00
|
|
|
|
|
|
|
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,
|
2023-11-17 01:37:29 +01:00
|
|
|
String: []const u8,
|
2023-10-08 21:40:44 +02:00
|
|
|
Table: *Table,
|
|
|
|
};
|
|
|
|
|
|
|
|
pub const CodeRegion = struct
|
|
|
|
{
|
|
|
|
start: ?CodeLocation,
|
|
|
|
length: usize,
|
|
|
|
};
|
|
|
|
pub const CodeLocation = struct
|
|
|
|
{
|
|
|
|
line: usize,
|
|
|
|
col: usize,
|
|
|
|
};
|