Atscc2scm: from ATS to Scheme

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!

I am gradually building the libatscc2scm library. Just made the
GameOf24 example work:

Note that the scheme implementation used is Guile-scheme.

Now we have the possibility to compile ATS into C and also in Guile; the
generated C code and
Guile code can actually make direct use of each other :)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!

But I know next to nothing about Shen.

I implemented atscc2scm because I would like to use it in many ways.
I had been wanting to have it for a long time. For instance, when I taught
programming with continuations, I had to fake it in ATS. With atscc2scm,
I will be able to implement callcc in ATS based on the callcc in Scheme,
which I find to be very satisfying.On Wednesday, June 1, 2016 at 1:14:43 PM UTC-4, Raoul Duke wrote:

If you can generate Shen, then the cycle will be complete and the universe
will cease to exist!

The code generated by atscc2scm lives in a very small fragment of Scheme,
which I assume is supported by all R*RS.On Sun, Jun 5, 2016 at 10:25 PM, Raoul Duke rao...@gmail.com wrote:

Would R{4,5,6,7,…}RS not/be a good goal?


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-user...@googlegroups.com.
To post to this group, send email to ats-lan...@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/CAJ7XQb6uKRh%3Day-6sNOT2Pvn5GXEOL6RXbbrmyb34EU-KDr7nQ%40mail.gmail.com
https://groups.google.com/d/msgid/ats-lang-users/CAJ7XQb6uKRh%3Day-6sNOT2Pvn5GXEOL6RXbbrmyb34EU-KDr7nQ%40mail.gmail.com?utm_medium=email&utm_source=footer
.

If you can generate Shen, then the cycle will be complete and the universe
will cease to exist!

Would R{4,5,6,7,…}RS not/be a good goal?

The library code for atscc2scm is at:

https://github.com/githwxi/ATS-Postiats-contrib/tree/master/contrib/libatscc/libatscc2scmOn 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!

I managed to tidy up a few things to make atscc2scm easier
to use. Now atscc2scm is functioning. If you have been using
atsccomp-compilers, then this one is not much different from the
others (atscc2js, atscc2py3, etc.); it is actually easier to use.

The code generated by atscc2scm targets GUILE specifically.
For other scheme implementations, you may need define some
macros of your own (see the libatscc2scm library mentioned in
a previous message) in order to use the generated code.

Cheers!

–HongweiOn 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!

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!