From 4cc2865365db626c31d87c931a2b8f8838c81a34 Mon Sep 17 00:00:00 2001 From: Po-Yu Hsieh Date: Fri, 19 Nov 2021 23:56:26 +0800 Subject: [PATCH] Language Support for ATS (#840) * Adding spec and test for ATS * Update language support list * Corrects language spec and test assertions Details: - Specifies quotation format - Correct key for specifying line comment - Correct expected test assertions (passed) * Fix inconsistent JSON formatting in languages.json * Update extension list Details: - To make it comply with github's linguist def --- README.md | 1 + languages.json | 12 ++++++++++++ tests/data/ats.dats | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 tests/data/ats.dats diff --git a/README.md b/README.md index a2e320ff9..9f72f3da8 100644 --- a/README.md +++ b/README.md @@ -314,6 +314,7 @@ Asp AspNet Assembly AssemblyGAS +ATS Autoconf AutoHotKey Automake diff --git a/languages.json b/languages.json index 20b277a03..dc95c2992 100644 --- a/languages.json +++ b/languages.json @@ -82,6 +82,18 @@ "webinfo" ] }, + "Ats": { + "name": "ATS", + "line_comment": ["//"], + "multi_line_comments": [["(*", "*)"], ["/*", "*/"]], + "quotes": [["\\\"", "\\\""]], + "extensions": [ + "dats", + "hats", + "sats", + "atxt" + ] + }, "Autoconf": { "line_comment": ["#", "dnl"], "extensions": ["in"] diff --git a/tests/data/ats.dats b/tests/data/ats.dats new file mode 100644 index 000000000..e5594acd6 --- /dev/null +++ b/tests/data/ats.dats @@ -0,0 +1,42 @@ +//! 42 lines 25 code 9 comments 8 blanks + +(************* + Reference: + https://github.com/ats-lang/ats-lang.github.io/blob/master/DOCUMENT/ATS2TUTORIAL/CODE/chap_stream_vt.dats +**************) +#include "share/atspre_staload.hats" + +/* Lazy-evaluated integer iterator */ +fun from +(n: int): stream_vt(int) = + $ldelay(stream_vt_cons(n, from(n + 1))) + +// Lazy-evaluated prime finder +fun sieve +(ns: stream_vt(int)) +: stream_vt(int) = $ldelay( + let + val ns_con = !ns + val- @stream_vt_cons(n0, ns1) = ns_con + val n0_val = n0 + val ns1_val = ns1 + + val () = + (ns1 := sieve(stream_vt_filter_cloptr(ns1_val, lam x => x mod n0_val > 0))) + + prval () = fold@(ns_con) + in + ns_con + end + , + ~ns +) + +// Test run for finding the 1000-th prime number +val thePrimes = sieve(from(2)) +val p1000 = (steam_vt_drop_exn(thePrimes, 1000)).head() +val () = println!("p1000 = ", p1000) + +implement main0 () = {} + +(* End of file *)