2009-02-12 21:35:14 +00:00
|
|
|
|
|
|
|
:- use_module(library(lineutils),
|
2015-06-19 00:56:24 +01:00
|
|
|
[file_filter_with_init/5,
|
2015-12-15 09:28:43 +00:00
|
|
|
file_filter_with_initialization/5,
|
|
|
|
split_unquoted/3]).
|
2009-02-12 21:35:14 +00:00
|
|
|
|
|
|
|
:- use_module(library(lists),
|
|
|
|
[append/2]).
|
|
|
|
|
|
|
|
:- initialization(main).
|
|
|
|
|
|
|
|
:- yap_flag(write_strings,on).
|
|
|
|
|
|
|
|
main :-
|
2010-04-18 21:48:20 +01:00
|
|
|
warning(Warning),
|
2016-04-26 15:33:16 +01:00
|
|
|
file_filter_with_init('H/ATOMS','H/generated/tatoms.h',gen_fields, Warning, ['tatoms.h']),
|
|
|
|
file_filter_with_init('H/ATOMS','H/generated/iatoms.h',gen_decl, Warning, ['iatoms.h']),
|
|
|
|
file_filter_with_init('H/ATOMS','H/generated/ratoms.h',gen_rcov, Warning, ['ratoms.h']).
|
2009-06-01 21:37:01 +01:00
|
|
|
|
2016-03-16 23:57:41 +00:00
|
|
|
warning('~n /* This file, ~a, was generated automatically by \"yap -L misc/buildatoms\"~n {lease do not update, update misc/ATOMS instead */~n~n').
|
2009-02-12 21:35:14 +00:00
|
|
|
|
|
|
|
gen_fields(Inp,Out) :-
|
2015-12-15 09:28:43 +00:00
|
|
|
split_unquoted(Inp," ",["A",Atom,_,_]), !,
|
2016-03-16 23:57:41 +00:00
|
|
|
( Atom = [C|_], code_type(C, alpha), Atom \= "Trail"
|
|
|
|
->
|
2016-07-31 16:27:18 +01:00
|
|
|
append(["EXTERNAL Atom Atom",Atom,"; EXTERNAL Term Term",Atom,";"], Out)
|
2016-03-16 23:57:41 +00:00
|
|
|
;
|
2016-07-31 16:27:18 +01:00
|
|
|
append(["EXTERNAL Atom Atom",Atom,";"], Out)
|
2016-03-16 23:57:41 +00:00
|
|
|
).
|
2009-02-12 21:35:14 +00:00
|
|
|
gen_fields(Inp,Out) :-
|
2015-12-15 09:28:43 +00:00
|
|
|
split_unquoted(Inp," ",["F",Name,_,_]), !,
|
2016-07-31 16:27:18 +01:00
|
|
|
append(["EXTERNAL Functor Functor",Name,";\n"],Out).
|
2009-02-12 21:35:14 +00:00
|
|
|
|
|
|
|
gen_rcov(Inp,Out) :-
|
2015-12-15 09:28:43 +00:00
|
|
|
split_unquoted(Inp," ",["A",Atom,_,_]), !,
|
2016-03-16 23:57:41 +00:00
|
|
|
( Atom = [C|_], code_type(C, alpha), Atom \= "Trail"
|
|
|
|
->
|
|
|
|
append([" Atom",Atom," = AtomAdjust(Atom",Atom,"); Term",Atom," = MkAtomTerm(Atom",Atom,");"],Out)
|
|
|
|
;
|
|
|
|
append([" Atom",Atom," = AtomAdjust(Atom",Atom,");"],Out)
|
|
|
|
).
|
2009-06-01 21:37:01 +01:00
|
|
|
%gen_rcov(Inp,Out) :-
|
2015-12-15 09:28:43 +00:00
|
|
|
% split_unquoted(Inp," ",["A",Atom,_]), !,
|
2009-06-01 21:37:01 +01:00
|
|
|
% append([" Atom_",Atom," = AtomAdjust(Atom_",Atom,");"],Out).
|
2009-02-12 21:35:14 +00:00
|
|
|
gen_rcov(Inp,Out) :-
|
2015-12-15 09:28:43 +00:00
|
|
|
split_unquoted(Inp," ",["F",Functor,_,_]), !,
|
2009-02-12 21:35:14 +00:00
|
|
|
append([" Functor",Functor," = FuncAdjust(Functor",Functor,");"],Out).
|
2009-06-01 21:37:01 +01:00
|
|
|
%gen_rcov(Inp,Out) :-
|
2015-12-15 09:28:43 +00:00
|
|
|
% split_unquoted(Inp," ",["F",Functor,Arity]), !,
|
2009-06-01 21:37:01 +01:00
|
|
|
% append([" Functor_",Functor,Arity," = FuncAdjust(Functor_",Functor,Arity,");"],Out).
|
2009-02-12 21:35:14 +00:00
|
|
|
|
|
|
|
gen_decl(Inp,Out) :-
|
2015-12-15 09:28:43 +00:00
|
|
|
split_unquoted(Inp," ",["A",Atom,"N",String]), !,
|
2016-03-16 23:57:41 +00:00
|
|
|
( Atom = [C|_], code_type(C, alpha), Atom \= "Trail"
|
|
|
|
->
|
|
|
|
append([" Atom",Atom," = Yap_LookupAtom(",String,"); Term",Atom," = MkAtomTerm(Atom",Atom,");"],Out)
|
|
|
|
;
|
|
|
|
append([" Atom",Atom," = Yap_LookupAtom(",String,");"],Out)
|
|
|
|
).
|
2009-02-12 21:35:14 +00:00
|
|
|
gen_decl(Inp,Out) :-
|
2015-12-15 09:28:43 +00:00
|
|
|
split_unquoted(Inp," ",["A",Atom,"F",String]), !,
|
2016-03-16 23:57:41 +00:00
|
|
|
( Atom = [C|_], code_type(C, alpha), Atom \= "Trail"
|
|
|
|
->
|
|
|
|
append([" Atom",Atom," = Yap_FullLookupAtom(",String,"); Term",Atom," = MkAtomTerm(Atom",Atom,");"],Out)
|
|
|
|
;
|
|
|
|
append([" Atom",Atom," = Yap_FullLookupAtom(",String,");"],Out)
|
|
|
|
).
|
2009-06-01 21:37:01 +01:00
|
|
|
%gen_decl(Inp,Out) :-
|
2015-12-15 09:28:43 +00:00
|
|
|
% split_unquoted(Inp," ",["A",Atom,String]), String = [0'",0'$|_], !,
|
2009-06-01 21:37:01 +01:00
|
|
|
% append([" Atom_",Atom," = Yap_FullLookupAtom(",String,");"],Out).
|
|
|
|
%gen_decl(Inp,Out) :-
|
2015-12-15 09:28:43 +00:00
|
|
|
% split_unquoted(Inp," ",["A",Atom,String]), !,
|
2009-06-01 21:37:01 +01:00
|
|
|
% append([" Atom_",Atom," = Yap_LookupAtom(",String,");"],Out).
|
2009-02-12 21:35:14 +00:00
|
|
|
gen_decl(Inp,Out) :-
|
2015-12-15 09:28:43 +00:00
|
|
|
split_unquoted(Inp," ",["F",Name,Atom,Arity]), !,
|
2009-02-12 21:35:14 +00:00
|
|
|
append([" Functor",Name," = Yap_MkFunctor(Atom",Atom,",",Arity,");"],Out).
|
2009-06-01 21:37:01 +01:00
|
|
|
%gen_decl(Inp,Out) :-
|
2015-12-15 09:28:43 +00:00
|
|
|
% split_unquoted(Inp," ",["F",Name,Arity]), !,
|
2009-06-01 21:37:01 +01:00
|
|
|
% append([" Functor_",Name,Arity," = Yap_MkFunctor(Atom_",Name,",",Arity,");"],Out).
|