This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/LGPL/PLStream/buildatoms
2008-12-23 01:53:52 +00:00

33 lines
618 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','../H/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).