Skip to content

Commit

Permalink
Update the samples...eveything now works apart from test 018
Browse files Browse the repository at this point in the history
  • Loading branch information
malcolmstill committed Mar 28, 2024
1 parent 270e63c commit 460f826
Show file tree
Hide file tree
Showing 31 changed files with 983 additions and 254 deletions.
11 changes: 8 additions & 3 deletions biscuit-datalog/src/expression.zig
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,17 @@ const Unary = enum {
length,

pub fn evaluate(expr: Unary, value: Term, symbols: *SymbolTable) !Term {
_ = symbols; // Different type instead of SymbolTable
//
return switch (expr) {
.negate => if (value == .bool) .{ .bool = !value.bool } else return error.UnexpectedTermInUnaryNegate,
.parens => value,
else => error.UnexpectedUnaryTermCombination,
.length => .{
.integer = switch (value) {
.string => |index| std.math.cast(i64, (try symbols.getString(index)).len) orelse return error.FailedToCaseInt,
.bytes => |b| std.math.cast(i64, b.len) orelse return error.FailedToCaseInt,
.set => |s| std.math.cast(i64, s.count()) orelse return error.FailedToCaseInt,
else => return error.LengthNotSupportedOnValue,
},
},
};
}
};
Expand Down
7 changes: 5 additions & 2 deletions biscuit-samples/src/sample.zig
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,11 @@ pub const Result = union(enum) {
};

const World = struct {
facts: [][]const u8,
rules: [][]const u8,
facts: []FactOrigin,
rules: []RuleOrigin,
checks: [][]const u8,
policies: [][]const u8,
};

const FactOrigin = struct { []const u8, []?usize };
const RuleOrigin = struct { []const u8, usize };
Loading

0 comments on commit 460f826

Please sign in to comment.