test/souffle/convert.py
def process_rule(rule, files, preprocess):
    """Convert a rule and emit the output"""
    head = getField(rule, "Head")
    tail = getField(rule, "Tail")
    headClauses = getListField(head, "Clause", "ClauseList")
    tails = normalize_tail(tail)

    if not has_relations(tail) and preprocess:
        # If there are no clauses in the tail we
        # mark all input relations as input relations
        for clause in headClauses:
            name = getField(clause, "Identifier")
            relations[relation_name(name.value)] = True
        # TODO: we should also emit the facts as data...
    else:
        heads = map(convert_head_clause, headClauses)
        convertedTails = map(convert_conjunction, tails)
        for ct in convertedTails:
            files.output(",\n\t".join(heads) + " :- " + ct + ".")
Convert a rule and emit the output
Convert a rule and emit the output
Convert a rule and emit the output
def process_rule(rule, files, preprocess):
    head = getField(rule, "Head")
    tail = getField(rule, "Tail")
    headClauses = getListField(head, "Clause", "ClauseList")
    tails = normalize_tail(tail)
    if not has_relations(tail) and preprocess:
        for clause in headClauses:
            name = getField(clause, "Identifier")
            relations[relation_name(name.value)] = True
    else:
        heads = map(convert_head_clause, headClauses)
        convertedTails = map(convert_conjunction, tails)
        for ct in convertedTails:
            files.output(",\n\t".join(heads) + " :- " + ct + ".")
def process_rule ( rule , files , preprocess ) : head = getField ( rule , "Head" ) tail = getField ( rule , "Tail" ) headClauses = getListField ( head , "Clause" , "ClauseList" ) tails = normalize_tail ( tail ) if not has_relations ( tail ) and preprocess : for clause in headClauses : name = getField ( clause , "Identifier" ) relations [ relation_name ( name . value ) ] = True else : heads = map ( convert_head_clause , headClauses ) convertedTails = map ( convert_conjunction , tails ) for ct in convertedTails : files . output ( ",\n\t" . join ( heads ) + " :- " + ct + "." )
Convert a rule and emit the output
Convert a rule and emit the output
"""Convert a rule and emit the output""" # If there are no clauses in the tail we # mark all input relations as input relations # TODO: we should also emit the facts as data...
rule
files
preprocess