Great! This is a very important step to partially/gradually rewriting existing C code.
On Saturday, September 17, 2016 at 10:30:13 PM UTC-4, Kiwamu Okabe wrote: > > Hi all, > > I create an utility to generate ATS interface from C code. It's useful > to create application rapidly. > > http://metasepi.org/en/posts/2016-09-17-c2ats.html > > The utility generates ATS's sats file importing from C language > header, semi-automatically. > > If you have following header: > > ``` > $ vi example.h > #include <stdio.h> > ``` > > then you can get the sats file using c2ats: > > ``` > $ c2ats gen example.h > example.sats > $ wc -l example.sats > 318 example.sats > $ grep _printf example.sats > fun fun_c2ats_printf: {l1:addr} (!ptr_v_1(char, l1) | ptr l1) -> int = > "mac#printf" > ``` > > Now you can create ATS application using the example.sats: > > ``` > $ vi main.dats > #include "share/atspre_define.hats" > #include "share/atspre_staload.hats" > > staload UN = "prelude/SATS/unsafe.sats" > > staload "example.sats" > > fun my_printf (s: string): void = { > val p = string2ptr s > val (pfat, fpfat | p) = $UN.ptr_vtake p > val ret = fun_c2ats_printf (pfat | p) > prval () = fpfat pfat > } > > implement main0 () = { > val s = "Hello, world!\n" > val () = my_printf s > } > $ patscc main.dats > $ ./a.out > Hello, world! > ``` > > More detail and usage is found at following: > > https://github.com/metasepi/c2ats > > Best regards, > -- > Kiwamu Okabe at METASEPI DESIGN > -- You received this message because you are subscribed to the Google Groups "ats-lang-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to ats-lang-users+unsubscr...@googlegroups.com. To post to this group, send email to ats-lang-users@googlegroups.com. Visit this group at https://groups.google.com/group/ats-lang-users. To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/50c52438-eedb-4fc6-b5bf-f823e34f38e8%40googlegroups.com.