36 lines
617 B
Plaintext
36 lines
617 B
Plaintext
|
|
:- use_module(library(lineutils),
|
|
[file_filter/3,
|
|
split/3]).
|
|
|
|
:- use_module(library(lists),
|
|
[append/2]).
|
|
|
|
:- initialization(main).
|
|
|
|
:- yap_flag(write_strings,on).
|
|
|
|
main :-
|
|
file_filter('ATOMS','atoms.h',gen_decl).
|
|
|
|
gen_decl(Inp,Out) :-
|
|
split(Inp," ",["A",Atom,String]), !,
|
|
append(["#define ATOM_",Atom," MK_ATOM(",String,")"],Out).
|
|
gen_decl(Inp,Out) :-
|
|
split(Inp," ",["F",Name,Arity]), !,
|
|
counter(I),
|
|
number_codes(I,IS),
|
|
append(["#define FUNCTOR_",Name,Arity," MKFUNCTOR(ATOM_",Name,",",Arity,")"],Out).
|
|
|
|
|
|
:- nb_setval(count,0).
|
|
|
|
counter(I) :-
|
|
nb_getval(count,I),
|
|
I1 is I+1,
|
|
nb_setval(count,I1).
|
|
|
|
|
|
|
|
|