def convert_length(node, state, arguments): state.ensure(node, any((arguments.min, arguments.max))) count = IR.call("count", [state.compute_path()]) filters = None for value, operator in [ (arguments.min, IR.as_operator(">=")), (arguments.max, IR.as_operator("<=")), ]: if value is None: continue state.ensure(value, isinstance(value, grammar.Constant)) state.ensure(value, isinstance(value.value, int)) filters = IR.combine_filters( filters, IR.filter(count, IR.literal(value.value), operator)) assert filters is not None return filters
def convert_logical_operator(node, state): if node is grammar.LogicOperator.OR: return IR.as_operator("OR") elif node is grammar.LogicOperator.AND: return IR.as_operator("AND")