Commit 2997a8a2 authored by POGODALLA Sylvain's avatar POGODALLA Sylvain
Browse files

Fixes #21

parent 25820482
......@@ -152,9 +152,10 @@ struct
let l_length=l_length+1 in
(new_pred,l_length)::rhs,l_length,new_tables)
env
([],0,(prog,var_gen,type_to_var_map) ) in
([],length,(prog,var_gen,type_to_var_map) ) in
Log.debug (fun m -> m "Correctly set the number of intensional predi in rhs: %d" (let () = assert (length=List.length i_rhs) in length));
let new_rule = AbstractSyntax.Rule.({id=rule_id;lhs;e_rhs;i_rhs;i_rhs_num=length}) in
Log.debug (fun m -> m "The following rule was generated: %s" (AbstractSyntax.Rule.to_string new_rule ~with_position:true (prog.Datalog.Program.pred_table) prog.Datalog.Program.const_table));
new_rule,Datalog.Program.add_rule ~intensional:true new_rule prog
(** [edb_and_query ~obj_term ~obj_type ~obj_typing_env ~dist_type
......
......@@ -105,10 +105,15 @@ module AbstractSyntax =
arity *)
}
let to_string predicate (*{p_id=p_id;arguments=parameters}*) pred_id_table cst_id_table=
Printf.sprintf "%s(%s)"
let to_string predicate ?position pred_id_table cst_id_table=
let position_info =
match position with
| None -> ""
| Some i -> Printf.sprintf " (* position: %d*)" i in
Printf.sprintf "%s(%s)%s"
(PredIdTable.find_sym_from_id predicate.p_id pred_id_table)
(string_of_list "," (fun p -> term_to_string p cst_id_table) predicate.arguments)
position_info
let compare ({p_id=id1;arity=a1;arguments=l1}:predicate) ({p_id=id2;arity=a2;arguments=l2}:predicate) =
let res = compare id1 id2 in
......@@ -175,16 +180,23 @@ module AbstractSyntax =
i_rhs_num:int;
}
let to_string r pred_id_table cst_id_table =
let to_string r ?(with_position=false) pred_id_table cst_id_table =
let head=Predicate.to_string r.lhs pred_id_table cst_id_table in
let string_of_predicate_list lst = string_of_list "," (fun p -> Predicate.to_string p pred_id_table cst_id_table) lst in
(* let string_of_predicate_list lst = string_of_list "," (fun p -> Predicate.to_string p pred_id_table cst_id_table) lst in *)
let vdash,e_i_sep =
match r.e_rhs,r.i_rhs with
| [],[] -> "",""
| [],_ -> ":- "," "
| _,[] -> ":- "," "
| _,_ -> ":- "," , " in
Printf.sprintf "%s%s%s%s%s." head vdash ((string_of_predicate_list >> fst >> List.split) r.e_rhs) e_i_sep ((string_of_predicate_list >> fst >> List.split) r.i_rhs)
(*
Printf.sprintf "%s%s%s%s%s." head vdash ((string_of_predicate_list >> fst >> List.split) r.e_rhs) e_i_sep ((string_of_predicate_list >> fst >> List.split) r.i_rhs) *)
let string_of_pred (pred,pos) =
match with_position with
| false -> Predicate.to_string pred pred_id_table cst_id_table
| true -> Predicate.to_string pred ~position:pos pred_id_table cst_id_table in
Printf.sprintf "%s%s%s%s%s." head vdash (string_of_list "," string_of_pred r.e_rhs) e_i_sep (string_of_list "," string_of_pred r.i_rhs)
module Rules=Set.Make(struct
type t=rule
......
......@@ -29,7 +29,7 @@ sig
arity *)
}
val to_string : predicate -> PredIdTable.table -> ConstGen.Table.table -> string
val to_string : predicate-> ?position:int -> PredIdTable.table -> ConstGen.Table.table -> string
val compare : predicate -> predicate -> int
val fake_pred_id : pred_id
......@@ -65,7 +65,7 @@ sig
(* stores the number of intensional predicates occurring in the
rule *)
}
val to_string : rule -> Predicate.PredIdTable.table -> ConstGen.Table.table -> string
val to_string : rule -> ?with_position:bool -> Predicate.PredIdTable.table -> ConstGen.Table.table -> string
val proto_rule_to_rule : Proto_Rule.t -> Predicate.PredIds.t -> rule
module Rules : Set.S with type elt=rule
......
......@@ -217,6 +217,7 @@ let main =
let () =
let () = Log.set_level ~app:"acgc" Logs.Warning in
(* let () = Log.set_level ~app:"acgc" Logs.Debug in *)
Term.(exit @@ eval main)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment