Now ATS code can be compiled into JavaScript and then evaluated:
http://www.ats-lang.org/COMPILED/doc/PROJECT/LARGE/TUTORATS/services/patsopt-atscc2js-trial/inputform.html
If you paste the following code into the input form, you should see two
alerts generated:
(* ****** ****** )
//
#include
“share/atspre_define.hats”
//
( ****** ****** )
//
#define ATS_DYNLOADFLAG 0
//
staload
“{$LIBATSCC2JS}/SATS/integer.sats”
//
( ****** ****** )
//
extern
fun fact : int → int = “mac#fact”
implement
fact (n) =
if n > 0 then n * fact(n-1) else 1
//
extern
fun acker : (int, int) → int = “mac#acker”
//
implement
acker (m, n) =
(
case+
(m, n) of
| (0, ) => n + 1
| (, 0) => acker(m-1, 1)
| (_, _) => acker(m-1, acker(m, n-1))
)
//
( ****** ****** *)
%{$
//
alert("fact(12) = " + fact(12));
alert("acker(3, 8) = " + acker(3, 8));
//
%} // end of [%{$]On Monday, September 8, 2014 2:32:52 PM UTC-4, gmhwxi wrote:
Now there is a service for generating JavaScript from ATS source:
http://www.ats-lang.org/COMPILED/doc/PROJECT/LARGE/TUTORATS/services/patsopt-atscc2js-trial/inputform.html
For instance, you will get some JS code if you paste the following code
into the input form and submit:
(* ****** ****** )
//
#include
“share/atspre_define.hats”
//
( ****** ****** )
//
#define ATS_DYNLOADFLAG 0
//
staload
“{$LIBATSCC2JS}/SATS/integer.sats”
//
( ****** ****** )
//
extern
fun acker : (int, int) → int = “mac#acker”
//
implement
acker (m, n) =
(
case+
(m, n) of
| (0, ) => n + 1
| (, 0) => acker(m-1, 1)
| (_, _) => acker(m-1, acker(m, n-1))
)
//
( ****** ****** *)
Naturally, the next step is to get the generated JS code to run in the
browser.
Cheers!
On Monday, September 8, 2014 1:55:04 AM UTC-4, gmhwxi wrote:
Today I managed to use atscc2php to generate some PHP code to support the
following service:
http://www.ats-lang.org/COMPILED/doc/PROJECT/LARGE/TUTORATS/services/patsopt-trial/inputform.html
It is mostly for fun at this moment. Still, you can use the service to
compile short code, trying to see if there
are type-errors.