From ATS to PHP

I also wrote a code generator from ATS to PHP:

https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/ATS-parse-emit/PHP

Compared to the code generators for Python and JavaScript, the one for PHP
is much simpler. If you
are interested in writing a code generator from ATS to some language X, I
recommend that you study
this one first.

Here is some generated code:

<?php /* ** The PHP code is generated by atscc2php ** The starting compilation time is: 2014-8-28: 23h:35m */ function fibats($arg0) { /* // $tmpret0 */ __patsflab_fibats: $tmpret0 = loop_1($arg0, 0, 1); return $tmpret0; } // end-of-function function loop_1($arg0, $arg1, $arg2) { /* // $apy0 // $apy1 // $apy2 // $tmpret1 // $tmp2 // $tmp3 // $tmp4 */ __patsflab_loop_1: $tmp2 = ats2phppre_gt_int1_int1($arg0, 0); if($tmp2) { $tmp3 = ats2phppre_sub_int1_int1($arg0, 1); $tmp4 = ats2phppre_add_int1_int1($arg1, $arg2); // ATStailcalseq_beg $apy0 = $tmp3; $apy1 = $arg2; $apy2 = $tmp4; $arg0 = $apy0; $arg1 = $apy1; $arg2 = $apy2; goto __patsflab_loop_1; // ATStailcalseq_end } else { $tmpret1 = $arg1; } // endif return $tmpret1; } // end-of-function /* ****** ****** */ /* end-of-compilation-unit */ ?>

More examples can be found at

https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/ATS-parse-emit/PHP/TEST

ATS is first compiled into a simple subset of C. Then it is just a matter
of interpreting this subset in PHP.
By the way, not all of ATS can be compiled this way. So far, what is
supported includes the functional core
(datatypes + higher-order functions) plus templates.On Sat, Sep 27, 2014 at 10:24 PM, ‘Yannick Duchêne’ via ats-lang-users < ats-lan...@googlegroups.com> wrote:

Le vendredi 29 août 2014 05:39:57 UTC+2, gmhwxi a écrit :

I also wrote a code generator from ATS to PHP:

https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/ATS-parse-emit/PHP

Compared to the code generators for Python and JavaScript, the one for
PHP is much simpler. If you
are interested in writing a code generator from ATS to some language X, I
recommend that you study
this one first.

Please, how do code generation take care of the target language semantic?
Is this based on reasonably safe and predictable subset or average
assumptions? (I mean in the general case, not specifically PHP).


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 http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/e2e02e43-85de-4f20-a9bb-64a781e16e2a%40googlegroups.com
https://groups.google.com/d/msgid/ats-lang-users/e2e02e43-85de-4f20-a9bb-64a781e16e2a%40googlegroups.com?utm_medium=email&utm_source=footer
.

ATS is first compiled into a simple subset of C. Then it is just a matter of
interpreting this subset in PHP. By the way, not all of ATS can be compiled this way.

So, there are also other “kernels” that could be targeted, to give
more/other portability to ATS.

E.g. Shen ; http://shenlanguage.org ;
https://thestrangeloop.com/sessions/shen-a-sufficiently-advanced-lisp

I also wrote a code generator from ATS to PHP:

https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/ATS-parse-emit/PHP

Compared to the code generators for Python and JavaScript, the one for PHP
is much simpler. If you
are interested in writing a code generator from ATS to some language X, I
recommend that you study
this one first.

Please, how do code generation take care of the target language semantic?
Is this based on reasonably safe and predictable subset or average
assumptions? (I mean in the general case, not specifically PHP).

PHP is a very wild language!

After bitten unexpectedly and repeatedly, I have finally managed to support
lists and arrays
for atscc2php. Here is an implementation of Game-of-24:

http://www.ats-lang.org/COMPILED/doc/PROJECT/SMALL/GameOf24/PHP/inputform.html

The ATS source can be found at:

https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/SMALL/GameOf24/PHPOn Friday, August 29, 2014 5:53:50 PM UTC-4, gmhwxi wrote:

Here is an example that makes use of some PHP code generated from ATS
source:

http://www.ats-lang.org/COMPILED/doc/PROJECT/MEDIUM/ATS-parse-emit/PHP/orderform.html

On Thursday, August 28, 2014 11:39:57 PM UTC-4, gmhwxi wrote:

I also wrote a code generator from ATS to PHP:

https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/ATS-parse-emit/PHP

Compared to the code generators for Python and JavaScript, the one for
PHP is much simpler. If you
are interested in writing a code generator from ATS to some language X, I
recommend that you study
this one first.

Here is some generated code:

<?php /* ** ** The PHP code is generated by atscc2php ** The starting compilation time is: 2014-8-28: 23h:35m ** */ function fibats($arg0) { /* // $tmpret0 */ __patsflab_fibats: $tmpret0 = loop_1($arg0, 0, 1); return $tmpret0; } // end-of-function function loop_1($arg0, $arg1, $arg2) { /* // $apy0 // $apy1 // $apy2 // $tmpret1 // $tmp2 // $tmp3 // $tmp4 */ __patsflab_loop_1: $tmp2 = ats2phppre_gt_int1_int1($arg0, 0); if($tmp2) { $tmp3 = ats2phppre_sub_int1_int1($arg0, 1); $tmp4 = ats2phppre_add_int1_int1($arg1, $arg2); // ATStailcalseq_beg $apy0 = $tmp3; $apy1 = $arg2; $apy2 = $tmp4; $arg0 = $apy0; $arg1 = $apy1; $arg2 = $apy2; goto __patsflab_loop_1; // ATStailcalseq_end } else { $tmpret1 = $arg1; } // endif return $tmpret1; } // end-of-function /* ****** ****** */ /* end-of-compilation-unit */ ?>

More examples can be found at

https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/ATS-parse-emit/PHP/TEST

Here is an example that makes use of some PHP code generated from ATS
source:

http://www.ats-lang.org/COMPILED/doc/PROJECT/MEDIUM/ATS-parse-emit/PHP/orderform.htmlOn Thursday, August 28, 2014 11:39:57 PM UTC-4, gmhwxi wrote:

I also wrote a code generator from ATS to PHP:

https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/ATS-parse-emit/PHP

Compared to the code generators for Python and JavaScript, the one for PHP
is much simpler. If you
are interested in writing a code generator from ATS to some language X, I
recommend that you study
this one first.

Here is some generated code:

<?php /* ** ** The PHP code is generated by atscc2php ** The starting compilation time is: 2014-8-28: 23h:35m ** */ function fibats($arg0) { /* // $tmpret0 */ __patsflab_fibats: $tmpret0 = loop_1($arg0, 0, 1); return $tmpret0; } // end-of-function function loop_1($arg0, $arg1, $arg2) { /* // $apy0 // $apy1 // $apy2 // $tmpret1 // $tmp2 // $tmp3 // $tmp4 */ __patsflab_loop_1: $tmp2 = ats2phppre_gt_int1_int1($arg0, 0); if($tmp2) { $tmp3 = ats2phppre_sub_int1_int1($arg0, 1); $tmp4 = ats2phppre_add_int1_int1($arg1, $arg2); // ATStailcalseq_beg $apy0 = $tmp3; $apy1 = $arg2; $apy2 = $tmp4; $arg0 = $apy0; $arg1 = $apy1; $arg2 = $apy2; goto __patsflab_loop_1; // ATStailcalseq_end } else { $tmpret1 = $arg1; } // endif return $tmpret1; } // end-of-function /* ****** ****** */ /* end-of-compilation-unit */ ?>

More examples can be found at

https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/ATS-parse-emit/PHP/TEST

Indeed. However, this should probably be done by someone who wants to use
such a code generator.

I did atscc2js and atscc2php because I wanted to use them to add some
dynamic
content to the ATS webpage.On Mon, Sep 29, 2014 at 2:21 AM, Raoul Duke rao...@gmail.com wrote:

ATS is first compiled into a simple subset of C. Then it is just a
matter of
interpreting this subset in PHP. By the way, not all of ATS can be
compiled this way.

So, there are also other “kernels” that could be targeted, to give
more/other portability to ATS.

E.g. Shen ; http://shenlanguage.org ;
https://thestrangeloop.com/sessions/shen-a-sufficiently-advanced-lisp


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 http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/CAJ7XQb6YOPLo19%2B4HToA0fPYUw9ZYJQ%2BCcD_tkFRuWjXW2BXAA%40mail.gmail.com
.