Skip to content

Commit

Permalink
Language Support for ATS (XAMPPRocky#840)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
pykenny authored and CIAvash committed Aug 14, 2022
1 parent 1473058 commit 4cc2865
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ Asp
AspNet
Assembly
AssemblyGAS
ATS
Autoconf
AutoHotKey
Automake
Expand Down
12 changes: 12 additions & 0 deletions languages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
42 changes: 42 additions & 0 deletions tests/data/ats.dats
Original file line number Diff line number Diff line change
@@ -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<int>(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 *)

0 comments on commit 4cc2865

Please sign in to comment.