From ATS to PHP

91 vues
Accéder directement au premier message non lu

gmhwxi

non lue,
28 août 2014, 23:39:5728/08/2014
à ats-lan...@googlegroups.com
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

gmhwxi

non lue,
29 août 2014, 17:53:5029/08/2014
à ats-lan...@googlegroups.com
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

gmhwxi

non lue,
2 sept. 2014, 19:55:0702/09/2014
à ats-lan...@googlegroups.com
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/PHP

Yannick Duchêne

non lue,
27 sept. 2014, 22:24:1427/09/2014
à ats-lan...@googlegroups.com


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).

Hongwei Xi

non lue,
28 sept. 2014, 11:03:2128/09/2014
à ats-lan...@googlegroups.com
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.


--
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.

Raoul Duke

non lue,
29 sept. 2014, 02:21:3929/09/2014
à ats-lang-users
> 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

Hongwei Xi

non lue,
29 sept. 2014, 13:21:1829/09/2014
à ats-lan...@googlegroups.com
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.


--
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.
Répondre à tous
Répondre à l'auteur
Transférer
0 nouveau message