I also wrote a code generator from ATS to PHP:
https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/ATS-parse-emit/PHPCompared 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