%:- auto_table. :- export make_frame/1. :- import build/2 from build. :- import pretty_print/1 from pretty_print. :- import str_cat/3 from string. :- import append/3 from lists. make_frame([]). make_frame([H|T]) :- make_frame(H), make_frame(T). make_frame(files(FileList)) :- make_frame(FileList). make_frame(FileName) :- atom(FileName), build(FileName, Graph), !, % tell('stuff'), pretty_print(Graph). make_graph(FileName, Graph), str_cat(FileName, '.graph', GraphFile), str_cat(FileName, '.facts', FactsFile), load_dyn(GraphFile), tell(FactsFile), make_facts(FileName, Graph), told. make_graph([], Graph). make_graph([H|T], [Head|Tail]) :- make_graph(H, Head), make_graph(T, Tail). make_graph(files(FileList), GraphList) :- make_graph(FileList, GraphList). make_graph(FileName, Graph) :- atom(FileName), str_cat(FileName, '.graph', GraphFile), tell(GraphFile), output_graph(Graph), told. output_graph(graph(L)) :- output_graph(L). output_graph([]). output_graph([t(A,B,C)|T]) :- % write('Thing'), nl, % write(t(A,B,C)), nl, pretty_print(t(A,B,C)),% nl, output_graph(T). output_graph([a(A,B,C)|T]) :- % write('Thing'), nl, output_graph(T). make_facts(FileName, graph(List)) :- make_facts(FileName, List). make_facts(FileName, []). make_facts(FileName, [a(A,B,C)|T]) :- get_text(A, B, Text), Fact =.. [FileName, C, Text], pretty_print(Fact), make_facts(FileName, T). make_facts(FileName, [t(A,B,C)|T]) :- make_facts(FileName, T). get_text(Start, End, Text) :- t(Start, Middle, Prefix), get_text(Middle, End, Rest), str_cat(Prefix, Rest, Text).