Removed useless code

This commit is contained in:
Adrien Bouvais 2024-11-12 21:18:19 +01:00
parent 3a61e81024
commit 5e9c64caf6

View File

@ -243,10 +243,6 @@ pub const Parser = struct {
state = .end; state = .end;
}, },
.keyword_to => { .keyword_to => {
var array = std.ArrayList(UUID).init(self.allocator);
defer array.deinit();
try self.file_engine.getAllUUIDList(struct_name, &array);
token = self.toker.next(); token = self.toker.next();
if (token.tag != .l_paren) return printError( if (token.tag != .l_paren) return printError(
"Error: Expected (", "Error: Expected (",
@ -362,7 +358,6 @@ pub const Parser = struct {
/// Take an array of UUID and populate it with what match what is between {} /// Take an array of UUID and populate it with what match what is between {}
/// Main is to know if between {} or (), main is true if between {}, otherwise between () inside {} /// Main is to know if between {} or (), main is true if between {}, otherwise between () inside {}
/// TODO: Optimize this so it can use multiple condition at the same time instead of parsing the all file for each condition
fn parseFilter(self: Parser, struct_name: []const u8, is_sub: bool) ZipponError!Filter { fn parseFilter(self: Parser, struct_name: []const u8, is_sub: bool) ZipponError!Filter {
var filter = try Filter.init(self.allocator); var filter = try Filter.init(self.allocator);
errdefer filter.deinit(); errdefer filter.deinit();
@ -536,6 +531,8 @@ pub const Parser = struct {
.angle_bracket_left_equal => condition.operation = .inferior_or_equal, // <= .angle_bracket_left_equal => condition.operation = .inferior_or_equal, // <=
.angle_bracket_right_equal => condition.operation = .superior_or_equal, // >= .angle_bracket_right_equal => condition.operation = .superior_or_equal, // >=
.bang_equal => condition.operation = .different, // != .bang_equal => condition.operation = .different, // !=
.keyword_in => condition.operation = .in,
.keyword_not_in => condition.operation = .not_in,
else => return printError( else => return printError(
"Error: Expected condition. Including < > <= >= = !=", "Error: Expected condition. Including < > <= >= = !=",
ZiQlParserError.SynthaxError, ZiQlParserError.SynthaxError,
@ -553,19 +550,17 @@ pub const Parser = struct {
.int => .int_literal, .int => .int_literal,
.float => .float_literal, .float => .float_literal,
.str => .string_literal, .str => .string_literal,
.link => .uuid_literal,
.self => .uuid_literal, .self => .uuid_literal,
.date => .date_literal, .date => .date_literal,
.time => .time_literal, .time => .time_literal,
.datetime => .datetime_literal, .datetime => .datetime_literal,
.int_array => .int_literal, .int_array => .int_literal,
.float_array => .float_literal, .float_array => .float_literal,
.link_array => .uuid_literal,
.str_array => .string_literal, .str_array => .string_literal,
.date_array => .date_literal, .date_array => .date_literal,
.time_array => .time_literal, .time_array => .time_literal,
.datetime_array => .datetime_literal, .datetime_array => .datetime_literal,
.bool, .bool_array => null, // handle bool separately .bool, .bool_array, .link, .link_array => null, // handle separately
}; };
if (expected_tag) |tag| { if (expected_tag) |tag| {
@ -607,6 +602,9 @@ pub const Parser = struct {
); );
} }
} }
} else if (condition.data_type == .link) {
// If token is ", this mean a single UUID
// If token is { or [, this mean a new filter
} }
} }
@ -1015,7 +1013,7 @@ test "GRAB filter with string" {
test "GRAB with additional data" { test "GRAB with additional data" {
try testParsing("GRAB User [1] {age < 18}"); try testParsing("GRAB User [1] {age < 18}");
try testParsing("GRAB User [name] {age < 18}"); try testParsing("GRAB User [id, name] {age < 18}");
try testParsing("GRAB User [100; name] {age < 18}"); try testParsing("GRAB User [100; name] {age < 18}");
} }