I would also like to point out one potential use of atscc2scm. Note the C code generated by patsopt from ATS source is somewhat difficult to read/comprehend. In contrast, the scheme code generated from atscc2scm seems a lot cleaner and more accessible. So if you ever want to write a compiler from ATS to a language, say, XYZ, you could try to use the output of atscc2scm, which is straightforward to parse.
Cheers! On Tuesday, May 31, 2016 at 12:43:27 AM UTC-4, gmhwxi wrote: > > > The library code for atscc2scm is at: > > > https://github.com/githwxi/ATS-Postiats-contrib/tree/master/contrib/libatscc/libatscc2scm > > On Tuesday, May 31, 2016 at 12:40:34 AM UTC-4, gmhwxi wrote: >> >> >> It is not yet fully functioning. Here is the code for the compiler: >> >> >> https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/CATS-atsccomp/CATS-atscc2scm >> >> As an example, the following code is generated based on >> >> https://github.com/githwxi/ATS-Postiats-contrib/blob/master/projects/MEDIUM/CATS-atsccomp/CATS-atscc2scm/TEST/acker.dats >> >> (define >> (acker arg0 arg1) >> (let( >> ;; knd = 0 >> (tmpret0 #f) >> (tmp1 #f) >> (tmp2 #f) >> (tmp3 #f) >> (tmp4 #f) >> ;; var Tmplab, Tmplab_scm >> ) ;; in-of-let >> ;; __patsflab_acker >> (letrec( >> (casefnx >> (lambda(Tmplab) >> (case Tmplab >> ;; ATSbranchseq_beg >> ((1) >> (if (not (ATSCKpat_int arg0 0)) >> (casefnx 3) >> (begin >> (casefnx 2) >> ) >> ) >> ) ;; end-of-branch >> ((2) >> (ats2scmpre_add_int0_int0 arg1 1) >> ) ;; end-of-branch >> ;; ATSbranchseq_end >> ;; ATSbranchseq_beg >> ((3) >> (if (not (ATSCKpat_int arg1 0)) >> (casefnx 5) >> (begin >> (casefnx 4) >> ) >> ) >> ) ;; end-of-branch >> ((4) >> (set! tmp1 (ats2scmpre_sub_int0_int0 arg0 1)) >> (acker tmp1 1) >> ) ;; end-of-branch >> ;; ATSbranchseq_end >> ;; ATSbranchseq_beg >> ((5) >> (set! tmp2 (ats2scmpre_sub_int0_int0 arg0 1)) >> (set! tmp4 (ats2scmpre_sub_int0_int0 arg1 1)) >> (set! tmp3 (acker arg0 tmp4)) >> (acker tmp2 tmp3) >> ) ;; end-of-branch >> ;; ATSbranchseq_end >> ;; _ -> atscc2scm_caseof_deadcode(?FILE, ?LINE) >> ) ;; end-of-case >> ) ;; end-of-lambda >> ) ;; end-of-casefnx >> ) (casefnx 1) >> ) ;; end-of-letrec >> ) ;; end-of-let >> ) ;; end-of-fun >> >> When using atscc2scm, one should disable tail-call optimization on the >> ATS side. >> >> I am on my way to write atscc2clj (ATS to Clojure), and atscc2scm is a >> convenient >> by-product. >> >> With atscc2clj, we can generate JVM code by going the route: ATS -> >> Clojure -> JVM. >> Then with lein-droid, we shall be able to write Android apps (partly) in >> ATS. >> >> Cheers! >> >> -- 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 [email protected]. To post to this group, send email to [email protected]. 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/db92ce9b-259e-41bd-8035-5320da5db5c3%40googlegroups.com.
