From 7c9e9730824a1e160fc81779f2bc1c7e29d0c280 Mon Sep 17 00:00:00 2001 From: Andy Li Date: Mon, 26 Nov 2012 21:54:43 +0800 Subject: [PATCH 01/41] Do not detect language if it is a binary file. --- lib/linguist/blob_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linguist/blob_helper.rb b/lib/linguist/blob_helper.rb index d7f56de5..f250b8c8 100644 --- a/lib/linguist/blob_helper.rb +++ b/lib/linguist/blob_helper.rb @@ -305,7 +305,7 @@ module Linguist data = lambda { (binary_mime_type? || binary?) ? "" : self.data } end - @language = Language.detect(name.to_s, data, mode) + @language = binary? ? nil : Language.detect(name.to_s, data, mode) end # Internal: Get the lexer of the blob. From 00de2b011d2859cb9fbec079eb14f9ffa9b1bde7 Mon Sep 17 00:00:00 2001 From: Douglas Adam Smith II Date: Fri, 13 Dec 2013 01:24:34 -0500 Subject: [PATCH 02/41] Updated language list to include HOW, and fixed the lack of lexer problem. Because HOW does not yet have a standardized lexer, I left the "lexer" field as "Text only". --- lib/linguist/languages.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index c737bec3..b653f4fb 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -723,6 +723,15 @@ Haxe: primary_extension: .hx extensions: - .hxsl + +HOW: + type: programming + coloe: "#CC0099" + lexer: Text only + primary_extension: .how + extensions: + - .howmeta + - .howproj INI: type: data From 63cb5aac2072a36491cc69ee291d33b1c2a4ae86 Mon Sep 17 00:00:00 2001 From: "Clinton N. Dreisbach" Date: Sun, 22 Dec 2013 11:54:14 -0500 Subject: [PATCH 03/41] Adding support for Hoplon files See https://github.com/tailrecursion/hoplon-demos/blob/master/todoFRP/src/index.cljs.hl for an example and https://github.com/tailrecursion/hoplon for the full project. --- lib/linguist/languages.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index e0c59c0d..77931d71 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -315,6 +315,7 @@ Clojure: - .cljscm - .cljx - .hic + - .cljs.hl filenames: - riemann.config @@ -663,6 +664,7 @@ HTML: extensions: - .htm - .xhtml + - .html.hl HTML+Django: type: markup From 2770e4e111844936fdfa2f5f9861491cc000eaa6 Mon Sep 17 00:00:00 2001 From: Brandon Date: Sat, 25 Jan 2014 12:09:00 -0500 Subject: [PATCH 04/41] adding ATS and several sample files --- lib/linguist/languages.yml | 13 + samples/ATS/linset.hats | 187 ++++++++++++ samples/ATS/linset_listord.dats | 504 ++++++++++++++++++++++++++++++++ samples/ATS/linset_listord.sats | 51 ++++ samples/C/dynarray.cats | 56 ++++ 5 files changed, 811 insertions(+) create mode 100644 samples/ATS/linset.hats create mode 100644 samples/ATS/linset_listord.dats create mode 100644 samples/ATS/linset_listord.sats create mode 100644 samples/C/dynarray.cats diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 340c7682..4bef750b 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -53,6 +53,18 @@ ASP: - .aspx - .axd +ATS: + type: programming + color: "#1ac620" + primary_extension: .dats + lexer: OCaml + aliases: + - ats2 + extensions: + - .sats + - .hats + - .atxt + ActionScript: type: programming lexer: ActionScript 3 @@ -215,6 +227,7 @@ C: primary_extension: .c extensions: - .w + - .cats C#: type: programming diff --git a/samples/ATS/linset.hats b/samples/ATS/linset.hats new file mode 100644 index 00000000..29e44c44 --- /dev/null +++ b/samples/ATS/linset.hats @@ -0,0 +1,187 @@ +(***********************************************************************) +(* *) +(* Applied Type System *) +(* *) +(***********************************************************************) + +(* +** ATS/Postiats - Unleashing the Potential of Types! +** Copyright (C) 2011-2013 Hongwei Xi, ATS Trustful Software, Inc. +** All rights reserved +** +** ATS is free software; you can redistribute it and/or modify it under +** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the +** Free Software Foundation; either version 3, or (at your option) any +** later version. +** +** ATS is distributed in the hope that it will be useful, but WITHOUT ANY +** WARRANTY; without even the implied warranty of MERCHANTABILITY or +** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +** for more details. +** +** You should have received a copy of the GNU General Public License +** along with ATS; see the file COPYING. If not, please write to the +** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA +** 02110-1301, USA. +*) + +(* ****** ****** *) + +(* Author: Hongwei Xi *) +(* Authoremail: hwxi AT cs DOT bu DOT edu *) +(* Start time: December, 2012 *) + +(* ****** ****** *) +// +// HX: shared by linset_listord (* ordered list *) +// HX: shared by linset_avltree (* AVL-tree-based *) +// +(* ****** ****** *) +// +// HX-2013-02: +// for sets of nonlinear elements +// +absvtype set_vtype (a:t@ype+) = ptr +// +(* ****** ****** *) + +vtypedef set (a:t0p) = set_vtype (a) + +(* ****** ****** *) + +fun{a:t0p} +compare_elt_elt (x1: a, x2: a):<> int + +(* ****** ****** *) + +fun{} linset_nil{a:t0p} ():<> set(a) +fun{} linset_make_nil{a:t0p} ():<> set(a) + +(* ****** ****** *) + +fun{a:t0p} linset_sing (x: a): set(a) +fun{a:t0p} linset_make_sing (x: a): set(a) + +(* ****** ****** *) + +fun{a:t0p} +linset_make_list (xs: List(INV(a))): set(a) + +(* ****** ****** *) + +fun{} +linset_is_nil {a:t0p} (xs: !set(INV(a))):<> bool +fun{} +linset_isnot_nil {a:t0p} (xs: !set(INV(a))):<> bool + +(* ****** ****** *) + +fun{a:t0p} linset_size (!set(INV(a))): size_t + +(* ****** ****** *) + +fun{a:t0p} +linset_is_member (xs: !set(INV(a)), x0: a):<> bool +fun{a:t0p} +linset_isnot_member (xs: !set(INV(a)), x0: a):<> bool + +(* ****** ****** *) + +fun{a:t0p} +linset_copy (!set(INV(a))): set(a) +fun{a:t0p} +linset_free (xs: set(INV(a))): void + +(* ****** ****** *) +// +fun{a:t0p} +linset_insert + (xs: &set(INV(a)) >> _, x0: a): bool +// +(* ****** ****** *) +// +fun{a:t0p} +linset_takeout +( + &set(INV(a)) >> _, a, res: &(a?) >> opt(a, b) +) : #[b:bool] bool(b) // endfun +fun{a:t0p} +linset_takeout_opt (&set(INV(a)) >> _, a): Option_vt(a) +// +(* ****** ****** *) +// +fun{a:t0p} +linset_remove + (xs: &set(INV(a)) >> _, x0: a): bool +// +(* ****** ****** *) +// +// HX: choosing an element in an unspecified manner +// +fun{a:t0p} +linset_choose +( + xs: !set(INV(a)), x: &a? >> opt (a, b) +) : #[b:bool] bool(b) +// +fun{a:t0p} +linset_choose_opt (xs: !set(INV(a))): Option_vt(a) +// +(* ****** ****** *) + +fun{a:t0p} +linset_takeoutmax +( + xs: &set(INV(a)) >> _, res: &a? >> opt(a, b) +) : #[b:bool] bool (b) +fun{a:t0p} +linset_takeoutmax_opt (xs: &set(INV(a)) >> _): Option_vt(a) + +(* ****** ****** *) + +fun{a:t0p} +linset_takeoutmin +( + xs: &set(INV(a)) >> _, res: &a? >> opt(a, b) +) : #[b:bool] bool (b) +fun{a:t0p} +linset_takeoutmin_opt (xs: &set(INV(a)) >> _): Option_vt(a) + +(* ****** ****** *) +// +fun{} +fprint_linset$sep (FILEref): void // ", " +// +fun{a:t0p} +fprint_linset (out: FILEref, xs: !set(INV(a))): void +// +overload fprint with fprint_linset +// +(* ****** ****** *) +// +fun{ +a:t0p}{env:vt0p +} linset_foreach$fwork + (x: a, env: &(env) >> _): void +// +fun{a:t0p} +linset_foreach (set: !set(INV(a))): void +fun{ +a:t0p}{env:vt0p +} linset_foreach_env + (set: !set(INV(a)), env: &(env) >> _): void +// end of [linset_foreach_env] +// +(* ****** ****** *) + +fun{a:t0p} +linset_listize (xs: set(INV(a))): List0_vt (a) + +(* ****** ****** *) + +fun{a:t0p} +linset_listize1 (xs: !set(INV(a))): List0_vt (a) + +(* ****** ****** *) + +(* end of [linset.hats] *) diff --git a/samples/ATS/linset_listord.dats b/samples/ATS/linset_listord.dats new file mode 100644 index 00000000..eb7dd642 --- /dev/null +++ b/samples/ATS/linset_listord.dats @@ -0,0 +1,504 @@ +(***********************************************************************) +(* *) +(* Applied Type System *) +(* *) +(***********************************************************************) + +(* +** ATS/Postiats - Unleashing the Potential of Types! +** Copyright (C) 2011-2013 Hongwei Xi, ATS Trustful Software, Inc. +** All rights reserved +** +** ATS is free software; you can redistribute it and/or modify it under +** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the +** Free Software Foundation; either version 3, or (at your option) any +** later version. +** +** ATS is distributed in the hope that it will be useful, but WITHOUT ANY +** WARRANTY; without even the implied warranty of MERCHANTABILITY or +** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +** for more details. +** +** You should have received a copy of the GNU General Public License +** along with ATS; see the file COPYING. If not, please write to the +** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA +** 02110-1301, USA. +*) + +(* ****** ****** *) + +(* Author: Hongwei Xi *) +(* Authoremail: hwxi AT cs DOT bu DOT edu *) +(* Start time: February, 2013 *) + +(* ****** ****** *) +// +// HX-2013-08: +// a set is represented as a sorted list in descending order; +// note that descending order is chosen to faciliate set comparison +// +(* ****** ****** *) + +staload +UN = "prelude/SATS/unsafe.sats" + +(* ****** ****** *) + +staload "libats/SATS/linset_listord.sats" + +(* ****** ****** *) + +#include "./SHARE/linset.hats" // code reuse +#include "./SHARE/linset_node.hats" // code reuse + +(* ****** ****** *) + +assume +set_vtype (elt:t@ype) = List0_vt (elt) + +(* ****** ****** *) + +implement{} +linset_nil () = list_vt_nil () +implement{} +linset_make_nil () = list_vt_nil () + +(* ****** ****** *) + +implement +{a}(*tmp*) +linset_sing + (x) = list_vt_cons{a}(x, list_vt_nil) +// end of [linset_sing] +implement{a} +linset_make_sing + (x) = list_vt_cons{a}(x, list_vt_nil) +// end of [linset_make_sing] + +(* ****** ****** *) + +implement{} +linset_is_nil (xs) = list_vt_is_nil (xs) +implement{} +linset_isnot_nil (xs) = list_vt_is_cons (xs) + +(* ****** ****** *) + +implement{a} +linset_size (xs) = + let val n = list_vt_length(xs) in i2sz(n) end +// end of [linset_size] + +(* ****** ****** *) + +implement{a} +linset_is_member + (xs, x0) = let +// +fun aux + {n:nat} .. +( + xs: !list_vt (a, n) +) :<> bool = let +in +// +case+ xs of +| list_vt_cons (x, xs) => let + val sgn = compare_elt_elt (x0, x) in + if sgn > 0 then false else (if sgn < 0 then aux (xs) else true) + end // end of [list_vt_cons] +| list_vt_nil ((*void*)) => false +// +end // end of [aux] +// +in + aux (xs) +end // end of [linset_is_member] + +(* ****** ****** *) + +implement{a} +linset_copy (xs) = list_vt_copy (xs) +implement{a} +linset_free (xs) = list_vt_free (xs) + +(* ****** ****** *) + +implement{a} +linset_insert + (xs, x0) = let +// +fun +mynode_cons + {n:nat} .<>. +( + nx: mynode1 (a), xs: list_vt (a, n) +) : list_vt (a, n+1) = let +// +val xs1 = +$UN.castvwtp0{List1_vt(a)}(nx) +val+@list_vt_cons (_, xs2) = xs1 +prval () = $UN.cast2void (xs2); val () = (xs2 := xs) +// +in + fold@ (xs1); xs1 +end // end of [mynode_cons] +// +fun ins + {n:nat} .. // tail-recursive +( + xs: &list_vt (a, n) >> list_vt (a, n1) +) : #[n1:nat | n <= n1; n1 <= n+1] bool = +( +case+ xs of +| @list_vt_cons + (x, xs1) => let + val sgn = + compare_elt_elt (x0, x) + // end of [val] + in + if sgn > 0 then let + prval () = fold@ (xs) + val nx = mynode_make_elt (x0) + val ((*void*)) = xs := mynode_cons (nx, xs) + in + false + end else if sgn < 0 then let + val ans = ins (xs1) + prval () = fold@ (xs) + in + ans + end else let // [x0] is found + prval () = fold@ (xs) + in + true (* [x0] in [xs] *) + end (* end of [if] *) + end // end of [list_vt_cons] +| list_vt_nil () => let + val nx = mynode_make_elt (x0) + val ((*void*)) = xs := mynode_cons (nx, xs) + in + false + end // end of [list_vt_nil] +) (* end of [ins] *) +// +in + $effmask_all (ins (xs)) +end // end of [linset_insert] + +(* ****** ****** *) + +(* +// +HX-2013-08: +[linset_remove] moved up +// +implement{a} +linset_remove + (xs, x0) = let +// +fun rem + {n:nat} .. // tail-recursive +( + xs: &list_vt (a, n) >> list_vt (a, n1) +) : #[n1:nat | n1 <= n; n <= n1+1] bool = +( +case+ xs of +| @list_vt_cons + (x, xs1) => let + val sgn = + compare_elt_elt (x0, x) + // end of [val] + in + if sgn > 0 then let + prval () = fold@ (xs) + in + false + end else if sgn < 0 then let + val ans = rem (xs1) + prval () = fold@ (xs) + in + ans + end else let // x0 = x + val xs1_ = xs1 + val ((*void*)) = free@{a}{0}(xs) + val () = xs := xs1_ + in + true // [x0] in [xs] + end (* end of [if] *) + end // end of [list_vt_cons] +| list_vt_nil () => false +) (* end of [rem] *) +// +in + $effmask_all (rem (xs)) +end // end of [linset_remove] +*) + +(* ****** ****** *) +(* +** By Brandon Barker +*) +implement +{a}(*tmp*) +linset_choose + (xs, x0) = let +in +// +case+ xs of +| list_vt_cons + (x, xs1) => let + val () = x0 := x + prval () = opt_some{a}(x0) + in + true + end // end of [list_vt_cons] +| list_vt_nil () => let + prval () = opt_none{a}(x0) + in + false + end // end of [list_vt_nil] +// +end // end of [linset_choose] + +(* ****** ****** *) + +implement +{a}{env} +linset_foreach_env (xs, env) = let +// +implement +list_vt_foreach$fwork + (x, env) = linset_foreach$fwork (x, env) +// +in + list_vt_foreach_env (xs, env) +end // end of [linset_foreach_env] + +(* ****** ****** *) + +implement{a} +linset_listize (xs) = xs + +(* ****** ****** *) + +implement{a} +linset_listize1 (xs) = list_vt_copy (xs) + +(* ****** ****** *) +// +// HX: functions for processing mynodes +// +(* ****** ****** *) + +implement{ +} mynode_null{a} () = + $UN.castvwtp0{mynode(a,null)}(the_null_ptr) +// end of [mynode_null] + +(* ****** ****** *) + +implement +{a}(*tmp*) +mynode_make_elt + (x) = let +// +val nx = list_vt_cons{a}{0}(x, _ ) +// +in + $UN.castvwtp0{mynode1(a)}(nx) +end // end of [mynode_make_elt] + +(* ****** ****** *) + +implement{ +} mynode_free + {a}(nx) = () where { +val nx = + $UN.castvwtp0{List1_vt(a)}(nx) +// +val+~list_vt_cons (_, nx2) = nx +// +prval ((*void*)) = $UN.cast2void (nx2) +// +} (* end of [mynode_free] *) + +(* ****** ****** *) + +implement +{a}(*tmp*) +mynode_get_elt + (nx) = (x) where { +// +val nx1 = + $UN.castvwtp1{List1_vt(a)}(nx) +// +val+list_vt_cons (x, _) = nx1 +// +prval ((*void*)) = $UN.cast2void (nx1) +// +} (* end of [mynode_get_elt] *) + +(* ****** ****** *) + +implement +{a}(*tmp*) +mynode_set_elt + {l} (nx, x0) = +{ +// +val nx1 = + $UN.castvwtp1{List1_vt(a)}(nx) +// +val+@list_vt_cons (x, _) = nx1 +// +val () = x := x0 +// +prval () = fold@ (nx1) +prval () = $UN.cast2void (nx1) +// +prval () = __assert (nx) where +{ + extern praxi __assert (nx: !mynode(a?, l) >> mynode (a, l)): void +} (* end of [prval] *) +// +} (* end of [mynode_set_elt] *) + +(* ****** ****** *) + +implement +{a}(*tmp*) +mynode_getfree_elt + (nx) = (x) where { +// +val nx = + $UN.castvwtp0{List1_vt(a)}(nx) +// +val+~list_vt_cons (x, nx2) = nx +// +prval ((*void*)) = $UN.cast2void (nx2) +// +} (* end of [mynode_getfree_elt] *) + +(* ****** ****** *) + +(* +fun{a:t0p} +linset_takeout_ngc + (set: &set(INV(a)) >> _, x0: a): mynode0 (a) +// end of [linset_takeout_ngc] +*) +implement +{a}(*tmp*) +linset_takeout_ngc + (set, x0) = let +// +fun takeout +( + xs: &List0_vt (a) >> _ +) : mynode0(a) = let +in +// +case+ xs of +| @list_vt_cons + (x, xs1) => let + prval pf_x = view@x + prval pf_xs1 = view@xs1 + val sgn = + compare_elt_elt (x0, x) + // end of [val] + in + if sgn > 0 then let + prval () = fold@ (xs) + in + mynode_null{a}((*void*)) + end else if sgn < 0 then let + val res = takeout (xs1) + prval ((*void*)) = fold@ (xs) + in + res + end else let // x0 = x + val xs1_ = xs1 + val res = $UN.castvwtp0{mynode1(a)}((pf_x, pf_xs1 | xs)) + val () = xs := xs1_ + in + res // [x0] in [xs] + end (* end of [if] *) + end // end of [list_vt_cons] +| list_vt_nil () => mynode_null{a}((*void*)) +// +end (* end of [takeout] *) +// +in + $effmask_all (takeout (set)) +end // end of [linset_takeout_ngc] + +(* ****** ****** *) + +implement +{a}(*tmp*) +linset_takeoutmax_ngc + (xs) = let +in +// +case+ xs of +| @list_vt_cons + (x, xs1) => let + prval pf_x = view@x + prval pf_xs1 = view@xs1 + val xs_ = xs + val () = xs := xs1 + in + $UN.castvwtp0{mynode1(a)}((pf_x, pf_xs1 | xs_)) + end // end of [list_vt_cons] +| @list_vt_nil () => let + prval () = fold@ (xs) + in + mynode_null{a}((*void*)) + end // end of [list_vt_nil] +// +end // end of [linset_takeoutmax_ngc] + +(* ****** ****** *) + +implement +{a}(*tmp*) +linset_takeoutmin_ngc + (xs) = let +// +fun unsnoc + {n:pos} .. +( + xs: &list_vt (a, n) >> list_vt (a, n-1) +) : mynode1 (a) = let +// +val+@list_vt_cons (x, xs1) = xs +// +prval pf_x = view@x and pf_xs1 = view@xs1 +// +in +// +case+ xs1 of +| list_vt_cons _ => + let val res = unsnoc(xs1) in fold@xs; res end + // end of [list_vt_cons] +| list_vt_nil () => let + val xs_ = xs + val () = xs := list_vt_nil{a}() + in + $UN.castvwtp0{mynode1(a)}((pf_x, pf_xs1 | xs_)) + end // end of [list_vt_nil] +// +end // end of [unsnoc] +// +in +// +case+ xs of +| list_vt_cons _ => unsnoc (xs) +| list_vt_nil () => mynode_null{a}((*void*)) +// +end // end of [linset_takeoutmin_ngc] + +(* ****** ****** *) + +(* end of [linset_listord.dats] *) diff --git a/samples/ATS/linset_listord.sats b/samples/ATS/linset_listord.sats new file mode 100644 index 00000000..468a534f --- /dev/null +++ b/samples/ATS/linset_listord.sats @@ -0,0 +1,51 @@ +(***********************************************************************) +(* *) +(* Applied Type System *) +(* *) +(***********************************************************************) + +(* +** ATS/Postiats - Unleashing the Potential of Types! +** Copyright (C) 2011-2013 Hongwei Xi, ATS Trustful Software, Inc. +** All rights reserved +** +** ATS is free software; you can redistribute it and/or modify it under +** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the +** Free Software Foundation; either version 3, or (at your option) any +** later version. +** +** ATS is distributed in the hope that it will be useful, but WITHOUT ANY +** WARRANTY; without even the implied warranty of MERCHANTABILITY or +** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +** for more details. +** +** You should have received a copy of the GNU General Public License +** along with ATS; see the file COPYING. If not, please write to the +** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA +** 02110-1301, USA. +*) + +(* ****** ****** *) +// +// Author: Hongwei Xi +// Authoremail: hwxiATcsDOTbuDOTedu +// Time: October, 2010 +// +(* ****** ****** *) + +#define ATS_PACKNAME "ATSLIB.libats.linset_listord" +#define ATS_STALOADFLAG 0 // no static loading at run-time + +(* ****** ****** *) + +#include "./SHARE/linset.hats" +#include "./SHARE/linset_node.hats" + +(* ****** ****** *) + +castfn +linset2list {a:t0p} (xs: set (INV(a))):<> List0_vt (a) + +(* ****** ****** *) + +(* end of [linset_listord.sats] *) diff --git a/samples/C/dynarray.cats b/samples/C/dynarray.cats new file mode 100644 index 00000000..95ee54ba --- /dev/null +++ b/samples/C/dynarray.cats @@ -0,0 +1,56 @@ +/* ******************************************************************* */ +/* */ +/* Applied Type System */ +/* */ +/* ******************************************************************* */ + +/* +** ATS/Postiats - Unleashing the Potential of Types! +** Copyright (C) 2011-20?? Hongwei Xi, ATS Trustful Software, Inc. +** All rights reserved +** +** ATS is free software; you can redistribute it and/or modify it under +** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the +** Free Software Foundation; either version 3, or (at your option) any +** later version. +** +** ATS is distributed in the hope that it will be useful, but WITHOUT ANY +** WARRANTY; without even the implied warranty of MERCHANTABILITY or +** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +** for more details. +** +** You should have received a copy of the GNU General Public License +** along with ATS; see the file COPYING. If not, please write to the +** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA +** 02110-1301, USA. +*/ + +/* ****** ****** */ + +/* +(* Author: Hongwei Xi *) +(* Authoremail: hwxi AT cs DOT bu DOT edu *) +(* Start time: March, 2013 *) +*/ + +/* ****** ****** */ + +#ifndef ATSHOME_LIBATS_DYNARRAY_CATS +#define ATSHOME_LIBATS_DYNARRAY_CATS + +/* ****** ****** */ + +#include + +/* ****** ****** */ + +#define atslib_dynarray_memcpy memcpy +#define atslib_dynarray_memmove memmove + +/* ****** ****** */ + +#endif // ifndef ATSHOME_LIBATS_DYNARRAY_CATS + +/* ****** ****** */ + +/* end of [dynarray.cats] */ From 7da9038e7911fd60a964e70da83dc2d5348292d1 Mon Sep 17 00:00:00 2001 From: Brandon Date: Sat, 25 Jan 2014 15:17:52 -0500 Subject: [PATCH 05/41] fixed extension order in languages.yml --- lib/linguist/languages.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index c08d3a1f..3c4fe240 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -61,9 +61,9 @@ ATS: aliases: - ats2 extensions: - - .sats - - .hats - .atxt + - .hats + - .sats ActionScript: type: programming @@ -226,8 +226,8 @@ C: color: "#555" primary_extension: .c extensions: - - .w - .cats + - .w C#: type: programming From 877ee775a37505fd48fe750099f15480990ec185 Mon Sep 17 00:00:00 2001 From: Brandon Date: Sat, 25 Jan 2014 17:55:28 -0500 Subject: [PATCH 06/41] adding more varied examples, including an .atxt file --- samples/ATS/CoYonedaLemma.dats | 110 ++++++++++++++ samples/ATS/DiningPhil2.dats | 178 +++++++++++++++++++++++ samples/ATS/DiningPhil2.sats | 71 +++++++++ samples/ATS/DiningPhil2_fork.dats | 89 ++++++++++++ samples/ATS/DiningPhil2_thread.dats | 43 ++++++ samples/ATS/YonedaLemma.dats | 178 +++++++++++++++++++++++ samples/ATS/main.atxt | 215 ++++++++++++++++++++++++++++ samples/C/readline.cats | 47 ++++++ 8 files changed, 931 insertions(+) create mode 100644 samples/ATS/CoYonedaLemma.dats create mode 100644 samples/ATS/DiningPhil2.dats create mode 100644 samples/ATS/DiningPhil2.sats create mode 100644 samples/ATS/DiningPhil2_fork.dats create mode 100644 samples/ATS/DiningPhil2_thread.dats create mode 100644 samples/ATS/YonedaLemma.dats create mode 100644 samples/ATS/main.atxt create mode 100644 samples/C/readline.cats diff --git a/samples/ATS/CoYonedaLemma.dats b/samples/ATS/CoYonedaLemma.dats new file mode 100644 index 00000000..aeac8bb1 --- /dev/null +++ b/samples/ATS/CoYonedaLemma.dats @@ -0,0 +1,110 @@ +(* ****** ****** *) +// +// HX-2014-01 +// CoYoneda Lemma: +// +(* ****** ****** *) +// +#include +"share/atspre_staload.hats" +// +(* ****** ****** *) + +staload +"libats/ML/SATS/basis.sats" +staload +"libats/ML/SATS/list0.sats" + +(* ****** ****** *) + +staload _ = "libats/ML/DATS/list0.dats" + +(* ****** ****** *) + +sortdef ftype = type -> type + +(* ****** ****** *) + +infixr (->) ->> +typedef ->> (a:type, b:type) = a - b + +(* ****** ****** *) + +typedef +functor(F:ftype) = + {a,b:type} (a ->> b) ->> F(a) ->> F(b) + +(* ****** ****** *) + +typedef +list0 (a:type) = list0 (a) +extern +val functor_list0 : functor (list0) + +(* ****** ****** *) + +implement +functor_list0{a,b} + (f) = lam xs => list0_map (xs, f) + +(* ****** ****** *) + +datatype +CoYoneda + (F:ftype, r:type) = {a:type} CoYoneda of (a ->> r, F(a)) +// end of [CoYoneda] + +(* ****** ****** *) +// +extern +fun CoYoneda_phi + : {F:ftype}functor(F) -> {r:type} (F (r) ->> CoYoneda (F, r)) +extern +fun CoYoneda_psi + : {F:ftype}functor(F) -> {r:type} (CoYoneda (F, r) ->> F (r)) +// +(* ****** ****** *) + +implement +CoYoneda_phi(ftor) = lam (fx) => CoYoneda (lam x => x, fx) +implement +CoYoneda_psi(ftor) = lam (CoYoneda(f, fx)) => ftor (f) (fx) + +(* ****** ****** *) + +datatype int0 = I of (int) +datatype bool = True | False // boxed boolean + +(* ****** ****** *) +// +fun bool2string + (x:bool): string = +( + case+ x of True() => "True" | False() => "False" +) +// +implement +fprint_val (out, x) = fprint (out, bool2string(x)) +// +(* ****** ****** *) + +fun int2bool (i: int0): bool = + let val+I(i) = i in if i > 0 then True else False end + +(* ****** ****** *) + +val myintlist0 = g0ofg1($list{int0}((I)1, (I)0, (I)1, (I)0, (I)0)) +val myboolist0 = CoYoneda{list0,bool}{int0}(lam (i) => int2bool(i), myintlist0) +val myboolist0 = CoYoneda_psi{list0}(functor_list0){bool}(myboolist0) + +(* ****** ****** *) + +val ((*void*)) = fprintln! (stdout_ref, "myboolist0 = ", myboolist0) + +(* ****** ****** *) + +implement main0 () = () + +(* ****** ****** *) + +(* end of [CoYonedaLemma.dats] *) diff --git a/samples/ATS/DiningPhil2.dats b/samples/ATS/DiningPhil2.dats new file mode 100644 index 00000000..55c39654 --- /dev/null +++ b/samples/ATS/DiningPhil2.dats @@ -0,0 +1,178 @@ +(* ****** ****** *) +// +// HX-2013-11 +// +// Implementing a variant of +// the problem of Dining Philosophers +// +(* ****** ****** *) +// +#include +"share/atspre_define.hats" +#include +"share/atspre_staload.hats" +// +(* ****** ****** *) + +staload +UN = "prelude/SATS/unsafe.sats" + +(* ****** ****** *) + +staload "libc/SATS/stdlib.sats" +staload "libc/SATS/unistd.sats" + +(* ****** ****** *) + +staload "{$LIBATSHWXI}/teaching/mythread/SATS/channel.sats" + +(* ****** ****** *) + +staload _ = "libats/DATS/deqarray.dats" +staload _ = "{$LIBATSHWXI}/teaching/mythread/DATS/channel.dats" + +(* ****** ****** *) + +staload "./DiningPhil2.sats" + +(* ****** ****** *) + +implement phil_left (n) = n +implement phil_right (n) = (n+1) \nmod NPHIL + +(* ****** ****** *) +// +extern +fun randsleep (n: intGte(1)): void +// +implement +randsleep (n) = + ignoret (sleep($UN.cast{uInt}(rand() mod n + 1))) +// end of [randsleep] +// +(* ****** ****** *) + +implement +phil_think (n) = +{ +val () = println! ("phil_think(", n, ") starts") +val () = randsleep (6) +val () = println! ("phil_think(", n, ") finishes") +} + +(* ****** ****** *) + +implement +phil_dine (n, lf, rf) = +{ +val () = println! ("phil_dine(", n, ") starts") +val () = randsleep (3) +val () = println! ("phil_dine(", n, ") finishes") +} + +(* ****** ****** *) + +implement +phil_loop (n) = let +// +val () = phil_think (n) +// +val nl = phil_left (n) +val nr = phil_right (n) +// +val ch_lfork = fork_changet (nl) +val ch_rfork = fork_changet (nr) +// +val lf = channel_takeout (ch_lfork) +val () = println! ("phil_loop(", n, ") picks left fork") +// +val () = randsleep (2) // HX: try to actively induce deadlock +// +val rf = channel_takeout (ch_rfork) +val () = println! ("phil_loop(", n, ") picks right fork") +// +val () = phil_dine (n, lf, rf) +// +val ch_forktray = forktray_changet () +val () = channel_insert (ch_forktray, lf) +val () = channel_insert (ch_forktray, rf) +// +in + phil_loop (n) +end // end of [phil_loop] + +(* ****** ****** *) + +implement +cleaner_wash (f) = +{ +val f = fork_get_num (f) +val () = println! ("cleaner_wash(", f, ") starts") +val () = randsleep (1) +val () = println! ("cleaner_wash(", f, ") finishes") +} + +(* ****** ****** *) + +implement +cleaner_return (f) = +{ + val n = fork_get_num (f) + val ch = fork_changet (n) + val () = channel_insert (ch, f) +} + +(* ****** ****** *) + +implement +cleaner_loop () = let +// +val ch = forktray_changet () +val f0 = channel_takeout (ch) +// +val () = cleaner_wash (f0) +val () = cleaner_return (f0) +// +in + cleaner_loop () +end // end of [cleaner_loop] + +(* ****** ****** *) + +dynload "DiningPhil2.sats" +dynload "DiningPhil2_fork.dats" +dynload "DiningPhil2_thread.dats" + +(* ****** ****** *) + +local +// +staload +"{$LIBATSHWXI}/teaching/mythread/SATS/mythread.sats" +// +in (* in of [local] *) +// +val () = mythread_create_cloptr (llam () => phil_loop (0)) +val () = mythread_create_cloptr (llam () => phil_loop (1)) +val () = mythread_create_cloptr (llam () => phil_loop (2)) +val () = mythread_create_cloptr (llam () => phil_loop (3)) +val () = mythread_create_cloptr (llam () => phil_loop (4)) +// +val () = mythread_create_cloptr (llam () => cleaner_loop ()) +// +end // end of [local] + +(* ****** ****** *) + +implement +main0 () = +{ +// +val () = println! ("DiningPhil2: starting") +val ((*void*)) = while (true) ignoret (sleep(1)) +// +} (* end of [main0] *) + +(* ****** ****** *) + +(* end of [DiningPhil2.dats] *) diff --git a/samples/ATS/DiningPhil2.sats b/samples/ATS/DiningPhil2.sats new file mode 100644 index 00000000..bc7e96be --- /dev/null +++ b/samples/ATS/DiningPhil2.sats @@ -0,0 +1,71 @@ +(* ****** ****** *) +// +// HX-2013-11 +// +// Implementing a variant of +// the problem of Dining Philosophers +// +(* ****** ****** *) + +#include +"share/atspre_define.hats" + +(* ****** ****** *) + +staload "{$LIBATSHWXI}/teaching/mythread/SATS/channel.sats" + +(* ****** ****** *) + +%{# +#define NPHIL 5 +%} // end of [%{#] +#define NPHIL 5 + +(* ****** ****** *) + +typedef nphil = natLt(NPHIL) + +(* ****** ****** *) + +fun phil_left (n: nphil): nphil +fun phil_right (n: nphil): nphil + +(* ****** ****** *) +// +fun phil_loop (n: nphil): void +// +(* ****** ****** *) + +fun cleaner_loop ((*void*)): void + +(* ****** ****** *) + +absvtype fork_vtype = ptr +vtypedef fork = fork_vtype + +(* ****** ****** *) + +fun fork_get_num (!fork): nphil + +(* ****** ****** *) + +fun phil_dine + (n: nphil, lf: !fork, rf: !fork): void +// end of [phil_dine] + +fun phil_think (n: nphil): void + +(* ****** ****** *) + +fun cleaner_wash (f: !fork): void +fun cleaner_return (f: fork): void + +(* ****** ****** *) +// +fun fork_changet (n: nphil): channel(fork) +// +fun forktray_changet ((*void*)): channel(fork) +// +(* ****** ****** *) + +(* end of [DiningPhil2.sats] *) diff --git a/samples/ATS/DiningPhil2_fork.dats b/samples/ATS/DiningPhil2_fork.dats new file mode 100644 index 00000000..a6a8d4df --- /dev/null +++ b/samples/ATS/DiningPhil2_fork.dats @@ -0,0 +1,89 @@ +(* ****** ****** *) +// +// HX-2013-11 +// +// Implementing a variant of +// the problem of Dining Philosophers +// +(* ****** ****** *) +// +#include +"share/atspre_define.hats" +#include +"share/atspre_staload.hats" +// +(* ****** ****** *) + +staload +UN = "prelude/SATS/unsafe.sats" + +(* ****** ****** *) + +staload "{$LIBATSHWXI}/teaching/mythread/SATS/channel.sats" + +(* ****** ****** *) + +staload _ = "libats/DATS/deqarray.dats" +staload _ = "{$LIBATSHWXI}/teaching/mythread/DATS/channel.dats" + +(* ****** ****** *) + +staload "./DiningPhil2.sats" + +(* ****** ****** *) + +datavtype fork = FORK of (nphil) + +(* ****** ****** *) + +assume fork_vtype = fork + +(* ****** ****** *) + +implement +fork_get_num (f) = let val FORK(n) = f in n end + +(* ****** ****** *) + +local + +val +the_forkarray = let +// +typedef t = channel(fork) +// +implement +array_tabulate$fopr + (n) = ch where +{ + val n = $UN.cast{nphil}(n) + val ch = channel_create_exn (i2sz(2)) + val () = channel_insert (ch, FORK (n)) +} +// +in + arrayref_tabulate (i2sz(NPHIL)) +end // end of [val] + +in (* in of [local] *) + +implement fork_changet (n) = the_forkarray[n] + +end // end of [local] + +(* ****** ****** *) + +local + +val the_forktray = + channel_create_exn (i2sz(NPHIL+1)) + +in (* in of [local] *) + +implement forktray_changet () = the_forktray + +end // end of [local] + +(* ****** ****** *) + +(* end of [DiningPhil2_fork.dats] *) diff --git a/samples/ATS/DiningPhil2_thread.dats b/samples/ATS/DiningPhil2_thread.dats new file mode 100644 index 00000000..be73840b --- /dev/null +++ b/samples/ATS/DiningPhil2_thread.dats @@ -0,0 +1,43 @@ +(* ****** ****** *) +// +// HX-2013-11 +// +// Implementing a variant of +// the problem of Dining Philosophers +// +(* ****** ****** *) +// +#include "share/atspre_define.hats" +#include "share/atspre_staload.hats" +// +(* ****** ****** *) + +staload "{$LIBATSHWXI}/teaching/mythread/SATS/mythread.sats" + +(* ****** ****** *) + +local +// +#include "{$LIBATSHWXI}/teaching/mythread/DATS/mythread.dats" +// +in (* in of [local] *) +// +// HX: it is intentionally left to be empty +// +end // end of [local] + +(* ****** ****** *) + +local +// +#include "{$LIBATSHWXI}/teaching/mythread/DATS/mythread_posix.dats" +// +in (* in of [local] *) +// +// HX: it is intentionally left to be empty +// +end // end of [local] + +(* ****** ****** *) + +(* end of [DiningPhil2_thread.dats] *) diff --git a/samples/ATS/YonedaLemma.dats b/samples/ATS/YonedaLemma.dats new file mode 100644 index 00000000..cd3c31e6 --- /dev/null +++ b/samples/ATS/YonedaLemma.dats @@ -0,0 +1,178 @@ +(* ****** ****** *) +// +// HX-2014-01 +// Yoneda Lemma: +// The hardest "trivial" theorem :) +// +(* ****** ****** *) +// +#include +"share/atspre_staload.hats" +// +(* ****** ****** *) + +staload +"libats/ML/SATS/basis.sats" +staload +"libats/ML/SATS/list0.sats" +staload +"libats/ML/SATS/option0.sats" + +(* ****** ****** *) + +staload _ = "libats/ML/DATS/list0.dats" +staload _ = "libats/ML/DATS/option0.dats" + +(* ****** ****** *) + +sortdef ftype = type -> type + +(* ****** ****** *) + +infixr (->) ->> +typedef ->> (a:type, b:type) = a - b + +(* ****** ****** *) + +typedef +functor(F:ftype) = + {a,b:type} (a ->> b) ->> F(a) ->> F(b) + +(* ****** ****** *) + +typedef +list0 (a:type) = list0 (a) +extern +val functor_list0 : functor (list0) + +(* ****** ****** *) + +implement +functor_list0{a,b} + (f) = lam xs => list0_map (xs, f) + +(* ****** ****** *) + +typedef +option0 (a:type) = option0 (a) +extern +val functor_option0 : functor (option0) + +(* ****** ****** *) + +implement +functor_option0{a,b} + (f) = lam opt => option0_map (opt, f) + +(* ****** ****** *) + +extern +val functor_homres + : {c:type} functor (lam(r:type) => c ->> r) + +(* ****** ****** *) + +implement +functor_homres{c}{a,b} (f) = lam (r) => lam (x) => f (r(x)) + +(* ****** ****** *) +// +extern +fun Yoneda_phi : {F:ftype}functor(F) -> + {a:type}F(a) ->> ({r:type}(a ->> r) ->> F(r)) +extern +fun Yoneda_psi : {F:ftype}functor(F) -> + {a:type}({r:type}(a ->> r) ->> F(r)) ->> F(a) +// +(* ****** ****** *) +// +implement +Yoneda_phi + (ftor) = lam(fx) => lam (m) => ftor(m)(fx) +// +implement +Yoneda_psi (ftor) = lam(mf) => mf(lam x => x) +// +(* ****** ****** *) + +(* + +(* ****** ****** *) +// +// HX-2014-01-05: +// Another version based on Natural Transformation +// +(* ****** ****** *) + +typedef +natrans(F:ftype, G:ftype) = {x:type} (F(x) ->> G(x)) + +(* ****** ****** *) +// +extern +fun Yoneda_phi_nat : {F:ftype}functor(F) -> + {a:type} F(a) ->> natrans(lam (r:type) => (a ->> r), F) +extern +fun Yoneda_psi_nat : {F:ftype}functor(F) -> + {a:type} natrans(lam (r:type) => (a ->> r), F) ->> F(a) +// +(* ****** ****** *) +// +implement +Yoneda_phi_nat + (ftor) = lam(fx) => lam (m) => ftor(m)(fx) +// +implement +Yoneda_psi_nat (ftor) = lam(mf) => mf(lam x => x) +// +(* ****** ****** *) + +*) + +(* ****** ****** *) + +datatype bool = True | False // boxed boolean + +(* ****** ****** *) +// +fun bool2string + (x:bool): string = +( + case+ x of True() => "True" | False() => "False" +) +// +implement +fprint_val (out, x) = fprint (out, bool2string(x)) +// +(* ****** ****** *) +// +val myboolist0 = + $list_t{bool}(True, False, True, False, False) +val myboolist0 = g0ofg1_list (myboolist0) +// +(* ****** ****** *) +// +extern +val Yoneda_bool_list0 : {r:type} (bool ->> r) ->> list0(r) +// +implement +Yoneda_bool_list0 = + Yoneda_phi(functor_list0){bool}(myboolist0) +// +(* ****** ****** *) +// +val myboolist1 = + Yoneda_psi(functor_list0){bool}(Yoneda_bool_list0) +// +(* ****** ****** *) + +val () = fprintln! (stdout_ref, "myboolist0 = ", myboolist0) +val () = fprintln! (stdout_ref, "myboolist1 = ", myboolist1) + +(* ****** ****** *) + +implement main0 () = () + +(* ****** ****** *) + +(* end of [YonedaLemma.dats] *) diff --git a/samples/ATS/main.atxt b/samples/ATS/main.atxt new file mode 100644 index 00000000..3bba35f0 --- /dev/null +++ b/samples/ATS/main.atxt @@ -0,0 +1,215 @@ +%{ +#include "./../ATEXT/atextfun.hats" +%} + + + + + + +EFFECTIVATS-DiningPhil2 +#patscode_style() + + + + +

+Effective ATS: Dining Philosophers +

+ +In this article, I present an implementation of a slight variant of the +famous problem of 5-Dining-Philosophers by Dijkstra that makes simple but +convincing use of linear types. + +

+The Original Problem +

+ +There are five philosophers sitting around a table and there are also 5 +forks placed on the table such that each fork is located between the left +hand of a philosopher and the right hand of another philosopher. Each +philosopher does the following routine repeatedly: thinking and dining. In +order to dine, a philosopher needs to first acquire two forks: one located +on his left-hand side and the other on his right-hand side. After +finishing dining, a philosopher puts the two acquired forks onto the table: +one on his left-hand side and the other on his right-hand side. + +

+A Variant of the Original Problem +

+ +The following twist is added to the original version: + +

+ +After a fork is used, it becomes a "dirty" fork and needs to be put in a +tray for dirty forks. There is a cleaner who cleans dirty forks and then +puts them back on the table. + +

+Channels for Communication +

+ +A channel is just a shared queue of fixed capacity. The following two +functions are for inserting an element into and taking an element out of a +given channel: + +
+#pats2xhtml_sats("\
+fun{a:vt0p} channel_insert (channel (a), a): void
+fun{a:vt0p} channel_takeout (chan: channel (a)): (a) 
+")
+ +If [channel_insert] is called on a channel that is full, then the caller is +blocked until an element is taken out of the channel. If [channel_takeout] +is called on a channel that is empty, then the caller is blocked until an +element is inserted into the channel. + +

+A Channel for Each Fork +

+ +Forks are resources given a linear type. Each fork is initially stored in a +channel, which can be obtained by calling the following function: + +
+#pats2xhtml_sats("\
+fun fork_changet (n: nphil): channel(fork)
+")
+ +where the type [nphil] is defined to be [natLt(5)] (for natural numbers +less than 5). The channels for storing forks are chosen to be of capacity +2. The reason that channels of capacity 2 are chosen to store at most one +element (in each of them) is to guarantee that these channels can never be +full (so that there is no attempt made to send signals to awake callers +supposedly being blocked due to channels being full). + + +

+A Channel for the Fork Tray +

+ +A tray for storing "dirty" forks is also a channel, which can be obtained +by calling the following function: + +
+#pats2xhtml_sats("\
+fun forktray_changet ((*void*)): channel(fork)
+")
+ +The capacity chosen for the channel is 6 (instead of 5) so that it can +never become full (as there are only 5 forks in total). + +

+Philosopher Loop +

+ +Each philosopher is implemented as a loop: + +
+#pats2xhtml_dats('\
+implement
+phil_loop (n) = let
+//
+val () = phil_think (n)
+//
+val nl = phil_left (n) // = n
+val nr = phil_right (n) // = (n+1) % 5
+//
+val ch_lfork = fork_changet (nl)
+val ch_rfork = fork_changet (nr)
+//
+val lf = channel_takeout (ch_lfork)
+val () = println! ("phil_loop(", n, ") picks left fork")
+//
+val () = randsleep (2) // sleep up to 2 seconds
+//
+val rf = channel_takeout (ch_rfork)
+val () = println! ("phil_loop(", n, ") picks right fork")
+//
+val () = phil_dine (n, lf, rf)
+//
+val ch_forktray = forktray_changet ()
+val () = channel_insert (ch_forktray, lf) // left fork to dirty tray
+val () = channel_insert (ch_forktray, rf) // right fork to dirty tray
+//
+in
+  phil_loop (n)
+end // end of [phil_loop]
+')
+ +It should be straighforward to follow the code for [phil_loop]. + +

+Fork Cleaner Loop +

+ +A cleaner is implemented as a loop: + +
+#pats2xhtml_dats('\
+implement
+cleaner_loop () = let
+//
+val ch = forktray_changet ()
+val f0 = channel_takeout (ch) // [f0] is dirty
+//
+val () = cleaner_wash (f0) // washes dirty [f0]
+val () = cleaner_return (f0) // puts back cleaned [f0]
+//
+in
+  cleaner_loop ()
+end // end of [cleaner_loop]
+')
+ +The function [cleaner_return] first finds out the number of a given fork +and then uses the number to locate the channel for storing the fork. Its +actual implementation is given as follows: + +
+#pats2xhtml_dats('\
+implement
+cleaner_return (f) =
+{
+  val n = fork_get_num (f)
+  val ch = fork_changet (n)
+  val () = channel_insert (ch, f)
+}
+')
+ +It should now be straighforward to follow the code for [cleaner_loop]. + +

+Testing +

+ +The entire code of this implementation is stored in the following files: + +
+DiningPhil2.sats
+DiningPhil2.dats
+DiningPhil2_fork.dats
+DiningPhil2_thread.dats
+
+ +There is also a Makefile available for compiling the ATS source code into +an excutable for testing. One should be able to encounter a deadlock after +running the simulation for a while. + +
+ +This article is written by
Hongwei Xi. + + + + +%{ +implement main () = fprint_filsub (stdout_ref, "main_atxt.txt") +%} diff --git a/samples/C/readline.cats b/samples/C/readline.cats new file mode 100644 index 00000000..3fad326b --- /dev/null +++ b/samples/C/readline.cats @@ -0,0 +1,47 @@ +/* +** API in ATS for GNU-readline +*/ + +/* ****** ****** */ + +/* +** Permission to use, copy, modify, and distribute this software for any +** purpose with or without fee is hereby granted, provided that the above +** copyright notice and this permission notice appear in all copies. +** +** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +** WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +** MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +** ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +** WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +** ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +** OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +/* ****** ****** */ + +#ifndef READLINE_READLINE_CATS +#define READLINE_READLINE_CATS + +/* ****** ****** */ + +#include + +/* ****** ****** */ +// +#define \ +atscntrb_readline_rl_library_version() ((char*)rl_library_version) +// +#define atscntrb_readline_rl_readline_version() (rl_readline_version) +// +/* ****** ****** */ + +#define atscntrb_readline_readline readline + +/* ****** ****** */ + +#endif // ifndef READLINE_READLINE_CATS + +/* ****** ****** */ + +/* end of [readline.cats] */ From f78ce5389eb82332724a021d8e419576f6cfbe08 Mon Sep 17 00:00:00 2001 From: Paul Chaignon Date: Sat, 1 Feb 2014 15:47:51 +0100 Subject: [PATCH 07/41] Support of the .ecl file extension for Prolog. --- lib/linguist/heuristics.rb | 10 ++++ lib/linguist/languages.yml | 1 + samples/Prolog/or-constraint.ecl | 90 ++++++++++++++++++++++++++++++++ test/test_heuristics.rb | 12 +++++ 4 files changed, 113 insertions(+) create mode 100644 samples/Prolog/or-constraint.ecl diff --git a/lib/linguist/heuristics.rb b/lib/linguist/heuristics.rb index 8ef2f41c..a3de46e9 100644 --- a/lib/linguist/heuristics.rb +++ b/lib/linguist/heuristics.rb @@ -19,6 +19,9 @@ module Linguist if languages.all? { |l| ["Perl", "Prolog"].include?(l) } disambiguate_pl(data, languages) end + if languages.all? { |l| ["ECL", "Prolog"].include?(l) } + disambiguate_ecl(data, languages) + end if languages.all? { |l| ["TypeScript", "XML"].include?(l) } disambiguate_ts(data, languages) end @@ -46,6 +49,13 @@ module Linguist matches end + def self.disambiguate_ecl(data, languages) + matches = [] + matches << Language["Prolog"] if data.include?(":-") + matches << Language["ECL"] if data.include?(":=") + matches + end + def self.disambiguate_ts(data, languages) matches = [] if (data.include?("")) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 302ffe14..6c692b9b 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -1323,6 +1323,7 @@ Prolog: color: "#74283c" primary_extension: .prolog extensions: + - .ecl - .pl Protocol Buffer: diff --git a/samples/Prolog/or-constraint.ecl b/samples/Prolog/or-constraint.ecl new file mode 100644 index 00000000..02748be0 --- /dev/null +++ b/samples/Prolog/or-constraint.ecl @@ -0,0 +1,90 @@ +:- lib(ic). + +/** + * Question 1.11 + * vabs(?Val, ?AbsVal) + */ +vabs(Val, AbsVal):- + AbsVal #> 0, + ( + Val #= AbsVal + ; + Val #= -AbsVal + ), + labeling([Val, AbsVal]). + +/** + * vabsIC(?Val, ?AbsVal) + */ +vabsIC(Val, AbsVal):- + AbsVal #> 0, + Val #= AbsVal or Val #= -AbsVal, + labeling([Val, AbsVal]). + +/** + * Question 1.12 + */ +% X #:: -10..10, vabs(X, Y). +% X #:: -10..10, vabsIC(X, Y). + +/** + * Question 1.13 + * faitListe(?ListVar, ?Taille, +Min, +Max) + */ +faitListe([], 0, _, _):-!. +faitListe([First|Rest], Taille, Min, Max):- + First #:: Min..Max, + Taille1 #= Taille - 1, + faitListe(Rest, Taille1, Min, Max). + +/** + * Question 1.14 + * suite(?ListVar) + */ +suite([Xi, Xi1, Xi2]):- + checkRelation(Xi, Xi1, Xi2). +suite([Xi, Xi1, Xi2|Rest]):- + checkRelation(Xi, Xi1, Xi2), + suite([Xi1, Xi2|Rest]). + +/** + * checkRelation(?Xi, ?Xi1, ?Xi2) + */ +checkRelation(Xi, Xi1, Xi2):- + vabs(Xi1, VabsXi1), + Xi2 #= VabsXi1 - Xi. + +/** + * Question 1.15 + * checkPeriode(+ListVar). + */ +% TODO Any better solution? +checkPeriode(ListVar):- + length(ListVar, Length), + Length < 10. +checkPeriode([X1, X2, X3, X4, X5, X6, X7, X8, X9, X10|Rest]):- + X1 =:= X10, + checkPeriode([X2, X3, X4, X5, X6, X7, X8, X9, X10|Rest]). +% faitListe(ListVar, 18, -9, 9), suite(ListVar), checkPeriode(ListVar). => 99 solutions + + +/** + * Tests + */ +/* +vabs(5, 5). => Yes +vabs(5, -5). => No +vabs(-5, 5). => Yes +vabs(X, 5). +vabs(X, AbsX). +vabsIC(5, 5). => Yes +vabsIC(5, -5). => No +vabsIC(-5, 5). => Yes +vabsIC(X, 5). +vabsIC(X, AbsX). + +faitListe(ListVar, 5, 1, 3). => 243 solutions +faitListe([_, _, _, _, _], Taille, 1, 3). => Taille = 5 !!!!!!!!!!!!!!!! + +faitListe(ListVar, 18, -9, 9), suite(ListVar). => 99 solutions +*/ \ No newline at end of file diff --git a/test/test_heuristics.rb b/test/test_heuristics.rb index 3d063dd3..0c1a07ff 100644 --- a/test/test_heuristics.rb +++ b/test/test_heuristics.rb @@ -50,6 +50,18 @@ class TestHeuristcs < Test::Unit::TestCase results = Heuristics.disambiguate_pl(fixture("Perl/perl-test.t"), languages) assert_equal Language["Perl"], results.first end + + def test_ecl_prolog_by_heuristics + languages = ["ECL", "Prolog"] + results = Heuristics.disambiguate_ecl(fixture("Prolog/or-constraint.ecl"), languages) + assert_equal Language["Prolog"], results.first + end + + def test_ecl_ecl_by_heuristics + languages = ["ECL", "Prolog"] + results = Heuristics.disambiguate_ecl(fixture("ECL/sample.ecl"), languages) + assert_equal Language["ECL"], results.first + end def test_ts_typescript_by_heuristics languages = ["TypeScript", "XML"] From 03ce24221ec2e6929fa5c579db7b3ea7b5931131 Mon Sep 17 00:00:00 2001 From: Christopher Kaster Date: Tue, 4 Feb 2014 19:00:33 +0100 Subject: [PATCH 08/41] add haxelib run.n neko bytecode file to vendor list --- lib/linguist/vendor.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/linguist/vendor.yml b/lib/linguist/vendor.yml index ca00b057..68c37da7 100644 --- a/lib/linguist/vendor.yml +++ b/lib/linguist/vendor.yml @@ -47,6 +47,9 @@ # Debian packaging - ^debian/ +# Haxelib projects often contain a neko bytecode file named run.n +- run\.n + ## Commonly Bundled JavaScript frameworks ## # jQuery From 0cfcb6917ba6af585a1b8e4c19e548db45c71893 Mon Sep 17 00:00:00 2001 From: Ted Nyman Date: Thu, 6 Feb 2014 13:18:02 -0800 Subject: [PATCH 09/41] Minor README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 958df8d5..1ff2ed8f 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ The actual syntax highlighting is handled by our Pygments wrapper, [pygments.rb] ### Stats -The Language stats bar that you see on every repository is built by aggregating the languages of each file in that repository. The top language in the graph determines the project's primary language. Collectively, these stats make up the [Top Languages](https://github.com/languages) page. +The Language stats bar that you see on every repository is built by aggregating the languages of each file in that repository. The top language in the graph determines the project's primary language. The repository stats API, accessed through `#languages`, can be used on a directory: From 0eaaa2baccd120a686206a21b73f2149444ebf1d Mon Sep 17 00:00:00 2001 From: Paul Chaignon Date: Tue, 11 Feb 2014 13:39:50 +0100 Subject: [PATCH 10/41] Support of the .sld file extension for Scheme. --- lib/linguist/languages.yml | 1 + samples/Scheme/basic.sld | 7 +++++++ 2 files changed, 8 insertions(+) create mode 100644 samples/Scheme/basic.sld diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 6c692b9b..6806efef 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -1552,6 +1552,7 @@ Scheme: color: "#1e4aec" primary_extension: .scm extensions: + - .sld - .sls - .ss interpreters: diff --git a/samples/Scheme/basic.sld b/samples/Scheme/basic.sld new file mode 100644 index 00000000..85dc75c6 --- /dev/null +++ b/samples/Scheme/basic.sld @@ -0,0 +1,7 @@ +(define-library (libs basic) + (export list2 x) + (begin + (define (list2 . objs) objs) + (define x 'libs-basic) + (define not-exported 'should-not-be-exported) + )) From bb754d884934dd966ae49dc8ab44c50c19efd69b Mon Sep 17 00:00:00 2001 From: Alex Kit Date: Wed, 12 Feb 2014 20:37:47 +0100 Subject: [PATCH 11/41] .mask support for Mask --- lib/linguist/languages.yml | 7 +++++ samples/Mask/view.mask | 61 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 samples/Mask/view.mask diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 6c692b9b..0ae56cd6 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -1020,6 +1020,13 @@ Markdown: - .mkdown - .ron +Mask: + type: markup + lexer: SCSS + color: "#f97732" + ace_mode: scss + primary_extension: .mask + Matlab: type: programming color: "#bb92ac" diff --git a/samples/Mask/view.mask b/samples/Mask/view.mask new file mode 100644 index 00000000..521273e6 --- /dev/null +++ b/samples/Mask/view.mask @@ -0,0 +1,61 @@ + +// HTML Elements +header { + + img .logo src='/images/~[currentLogo].png' alt=logo; + + h4 > 'Bar View' + + if (currentUser) { + + .account > + a href='/acount' > + 'Hello, ~[currentUser.username]' + } +} + +.view { + ul { + + // Iteration + for ((user, index) of users) { + + li.user data-id='~[user.id]' { + + // interpolation + .name > '~[ user.username ]' + + // expression + .count > '~[: user.level.toFixed(2) ]' + + // util + /* Localization sample + * lastActivity: "Am {0:dd. MM} war der letzte Eintrag" + */ + .date > '~[ L: "lastActivity", user.date]' + } + } + } + + // Component + :countdownComponent { + input type = text > + :dualbind value='number'; + + button x-signal='click: countdownStart' > 'Start'; + + h5 { + '~[bind: number]' + + :animation x-slot='countdownStart' { + @model > 'transition | scale(0) > scale(1) | 500ms' + @next > 'background-color | red > blue | 2s linear' + } + } + } +} + +footer > :bazCompo { + + 'Component generated at ~[: $u.format($c.date, "HH-mm") ]' +} \ No newline at end of file From 9f3ee8dff6e64d83354fe49ec035324c1e4a38f9 Mon Sep 17 00:00:00 2001 From: Guillermo Federico Olmedo Date: Fri, 14 Feb 2014 13:42:18 -0200 Subject: [PATCH 12/41] added .rsx extension to R. When we write R extensions for QGIS we have to end the files in .rsx [1]. But the code its pure R. It would be great if github acknowledge those scripts as R scripts. [1] http://www.qgis.org/es/docs/user_manual/processing/3rdParty.html#r-creating-r-scripts --- lib/linguist/languages.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index a9c347e4..15ece00e 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -1401,6 +1401,7 @@ R: primary_extension: .r extensions: - .R + - .rsx filenames: - .Rprofile interpreters: From fdbfd8b806d51ff0e9c66a3e34c087a373f183e3 Mon Sep 17 00:00:00 2001 From: Guillermo Federico Olmedo Date: Fri, 14 Feb 2014 14:53:14 -0200 Subject: [PATCH 13/41] Added sample of R qgis script --- samples/R/R-qgis-extension.rsx | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 samples/R/R-qgis-extension.rsx diff --git a/samples/R/R-qgis-extension.rsx b/samples/R/R-qgis-extension.rsx new file mode 100644 index 00000000..adf59e67 --- /dev/null +++ b/samples/R/R-qgis-extension.rsx @@ -0,0 +1,5 @@ +##polyg=vector +##numpoints=number 10 +##output=output vector +##[Example scripts]=group +pts=spsample(polyg,numpoints,type="regular") From 3429ddeaa12f7ce0c752a0e039aa739e9cdb027e Mon Sep 17 00:00:00 2001 From: Ted Nyman Date: Sun, 16 Feb 2014 19:41:45 -0800 Subject: [PATCH 14/41] Standard regex --- lib/linguist/vendor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linguist/vendor.yml b/lib/linguist/vendor.yml index 68c37da7..3609b466 100644 --- a/lib/linguist/vendor.yml +++ b/lib/linguist/vendor.yml @@ -48,7 +48,7 @@ - ^debian/ # Haxelib projects often contain a neko bytecode file named run.n -- run\.n +- run.n$ ## Commonly Bundled JavaScript frameworks ## From 69bfe731659c90b8f13d9486ca08ccb7ed0ec518 Mon Sep 17 00:00:00 2001 From: Ted Nyman Date: Sun, 16 Feb 2014 19:43:33 -0800 Subject: [PATCH 15/41] Not yet on the additional binary check --- lib/linguist/blob_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linguist/blob_helper.rb b/lib/linguist/blob_helper.rb index f3a6d5de..37793a36 100644 --- a/lib/linguist/blob_helper.rb +++ b/lib/linguist/blob_helper.rb @@ -291,7 +291,7 @@ module Linguist data = lambda { (binary_mime_type? || binary?) ? "" : self.data } end - @language = binary? ? nil : Language.detect(name.to_s, data, mode) + @language = Language.detect(name.to_s, data, mode) end # Internal: Get the lexer of the blob. From c60328383d3f6cd5ee9480dbce5c56cdbfdc9ae5 Mon Sep 17 00:00:00 2001 From: Ivan Zuzak Date: Mon, 17 Feb 2014 17:04:47 +0100 Subject: [PATCH 16/41] add interpreter for javascript --- lib/linguist/languages.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 15ece00e..3ed169d5 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -887,6 +887,8 @@ JavaScript: - .ssjs filenames: - Jakefile + interpreters: + - node Julia: type: programming From 8afe123084ef361576c1d50ae2b0df27b227e51e Mon Sep 17 00:00:00 2001 From: Ivan Zuzak Date: Mon, 17 Feb 2014 17:08:51 +0100 Subject: [PATCH 17/41] add interpreter for applescript --- lib/linguist/languages.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 15ece00e..5d37923d 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -104,6 +104,8 @@ AppleScript: primary_extension: .applescript extensions: - .scpt + interpreters: + - osascript Arc: type: programming From e437cf749d8c0fcb530205aa9630a82c79a578c6 Mon Sep 17 00:00:00 2001 From: Arfon Smith Date: Tue, 18 Feb 2014 15:28:22 -0600 Subject: [PATCH 18/41] Adding support for JSONLD: http://json-ld.org/ --- lib/linguist/languages.yml | 7 + lib/linguist/samples.json | 752 +++++++++++++++++++++++++++++++++-- samples/JSONLD/sample.jsonld | 30 ++ 3 files changed, 757 insertions(+), 32 deletions(-) create mode 100644 samples/JSONLD/sample.jsonld diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 5d37923d..e94b0906 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -847,6 +847,13 @@ JSON5: lexer: JavaScript primary_extension: .json5 +JSONLD: + type: data + group: JavaScript + ace_mode: json + lexer: JavaScript + primary_extension: .jsonld + Jade: group: HTML type: markup diff --git a/lib/linguist/samples.json b/lib/linguist/samples.json index ed92145a..67f6e90e 100644 --- a/lib/linguist/samples.json +++ b/lib/linguist/samples.json @@ -20,6 +20,12 @@ ".asc", ".asciidoc" ], + "ATS": [ + ".atxt", + ".dats", + ".hats", + ".sats" + ], "AutoHotkey": [ ".ahk" ], @@ -37,6 +43,7 @@ ], "C": [ ".c", + ".cats", ".h" ], "C#": [ @@ -52,6 +59,9 @@ "Ceylon": [ ".ceylon" ], + "Cirru": [ + ".cirru" + ], "Clojure": [ ".cl2", ".clj", @@ -176,6 +186,9 @@ "JSON5": [ ".json5" ], + "JSONLD": [ + ".jsonld" + ], "Julia": [ ".jl" ], @@ -330,6 +343,7 @@ ".pde" ], "Prolog": [ + ".ecl", ".pl", ".prolog" ], @@ -342,6 +356,7 @@ ], "R": [ ".R", + ".rsx", ".script!" ], "Racket": [ @@ -535,8 +550,8 @@ ".gemrc" ] }, - "tokens_total": 445429, - "languages_total": 523, + "tokens_total": 450519, + "languages_total": 547, "tokens": { "ABAP": { "*/**": 1, @@ -2032,6 +2047,561 @@ ".Section": 1, "list": 1 }, + "ATS": { + "//": 211, + "#include": 16, + "staload": 25, + "_": 25, + "sortdef": 2, + "ftype": 13, + "type": 30, + "-": 49, + "infixr": 2, + "(": 562, + ")": 567, + "typedef": 10, + "a": 200, + "b": 26, + "": 2, + "functor": 12, + "F": 34, + "{": 142, + "}": 141, + "list0": 9, + "extern": 13, + "val": 95, + "functor_list0": 7, + "implement": 55, + "f": 22, + "lam": 20, + "xs": 82, + "list0_map": 2, + "": 14, + "": 3, + "datatype": 4, + "CoYoneda": 7, + "r": 25, + "of": 59, + "fun": 56, + "CoYoneda_phi": 2, + "CoYoneda_psi": 3, + "ftor": 9, + "fx": 8, + "x": 48, + "int0": 4, + "I": 8, + "int": 2, + "bool": 27, + "True": 7, + "|": 22, + "False": 8, + "boxed": 2, + "boolean": 2, + "bool2string": 4, + "string": 2, + "case": 9, + "+": 20, + "fprint_val": 2, + "": 2, + "out": 8, + "fprint": 3, + "int2bool": 2, + "i": 6, + "let": 34, + "in": 48, + "if": 7, + "then": 11, + "else": 7, + "end": 73, + "myintlist0": 2, + "g0ofg1": 1, + "list": 1, + "myboolist0": 9, + "fprintln": 3, + "stdout_ref": 4, + "main0": 3, + "UN": 3, + "phil_left": 3, + "n": 51, + "phil_right": 3, + "nmod": 1, + "NPHIL": 6, + "randsleep": 6, + "intGte": 1, + "void": 14, + "ignoret": 2, + "sleep": 2, + "UN.cast": 2, + "uInt": 1, + "rand": 1, + "mod": 1, + "phil_think": 3, + "println": 9, + "phil_dine": 3, + "lf": 5, + "rf": 5, + "phil_loop": 10, + "nl": 2, + "nr": 2, + "ch_lfork": 2, + "fork_changet": 5, + "ch_rfork": 2, + "channel_takeout": 4, + "HX": 1, + "try": 1, + "to": 16, + "actively": 1, + "induce": 1, + "deadlock": 2, + "ch_forktray": 3, + "forktray_changet": 4, + "channel_insert": 5, + "[": 49, + "]": 48, + "cleaner_wash": 3, + "fork_get_num": 4, + "cleaner_return": 4, + "ch": 7, + "cleaner_loop": 6, + "f0": 3, + "dynload": 3, + "local": 10, + "mythread_create_cloptr": 6, + "llam": 6, + "while": 1, + "true": 5, + "%": 7, + "#": 7, + "#define": 4, + "nphil": 13, + "natLt": 2, + "absvtype": 2, + "fork_vtype": 3, + "ptr": 2, + "vtypedef": 2, + "fork": 16, + "channel": 11, + "datavtype": 1, + "FORK": 3, + "assume": 2, + "the_forkarray": 2, + "t": 1, + "array_tabulate": 1, + "fopr": 1, + "": 2, + "where": 6, + "channel_create_exn": 2, + "": 2, + "i2sz": 4, + "arrayref_tabulate": 1, + "the_forktray": 2, + "set_vtype": 3, + "t@ype": 2, + "set": 34, + "t0p": 31, + "compare_elt_elt": 4, + "x1": 1, + "x2": 1, + "<": 14, + "linset_nil": 2, + "linset_make_nil": 2, + "linset_sing": 2, + "": 16, + "linset_make_sing": 2, + "linset_make_list": 1, + "List": 1, + "INV": 24, + "linset_is_nil": 2, + "linset_isnot_nil": 2, + "linset_size": 2, + "size_t": 1, + "linset_is_member": 3, + "x0": 22, + "linset_isnot_member": 1, + "linset_copy": 2, + "linset_free": 2, + "linset_insert": 3, + "&": 17, + "linset_takeout": 1, + "res": 9, + "opt": 6, + "endfun": 1, + "linset_takeout_opt": 1, + "Option_vt": 4, + "linset_remove": 2, + "linset_choose": 3, + "linset_choose_opt": 1, + "linset_takeoutmax": 1, + "linset_takeoutmax_opt": 1, + "linset_takeoutmin": 1, + "linset_takeoutmin_opt": 1, + "fprint_linset": 3, + "sep": 1, + "FILEref": 2, + "overload": 1, + "with": 1, + "env": 11, + "vt0p": 2, + "linset_foreach": 3, + "fwork": 3, + "linset_foreach_env": 3, + "linset_listize": 2, + "List0_vt": 5, + "linset_listize1": 2, + "code": 6, + "reuse": 2, + "elt": 2, + "list_vt_nil": 16, + "list_vt_cons": 17, + "list_vt_is_nil": 1, + "list_vt_is_cons": 1, + "list_vt_length": 1, + "aux": 4, + "nat": 4, + ".": 14, + "": 3, + "list_vt": 7, + "sgn": 9, + "false": 6, + "list_vt_copy": 2, + "list_vt_free": 1, + "mynode_cons": 4, + "nx": 22, + "mynode1": 6, + "xs1": 15, + "UN.castvwtp0": 8, + "List1_vt": 5, + "@list_vt_cons": 5, + "xs2": 3, + "prval": 20, + "UN.cast2void": 5, + ";": 4, + "fold@": 8, + "ins": 3, + "tail": 1, + "recursive": 1, + "n1": 4, + "<=>": 1, + "1": 3, + "mynode_make_elt": 4, + "ans": 2, + "is": 26, + "found": 1, + "effmask_all": 3, + "free@": 1, + "xs1_": 3, + "rem": 1, + "*": 2, + "opt_some": 1, + "opt_none": 1, + "list_vt_foreach": 1, + "": 3, + "list_vt_foreach_env": 1, + "mynode_null": 5, + "mynode": 3, + "null": 1, + "the_null_ptr": 1, + "mynode_free": 1, + "nx2": 4, + "mynode_get_elt": 1, + "nx1": 7, + "UN.castvwtp1": 2, + "mynode_set_elt": 1, + "l": 3, + "__assert": 2, + "praxi": 1, + "mynode_getfree_elt": 1, + "linset_takeout_ngc": 2, + "takeout": 3, + "mynode0": 1, + "pf_x": 6, + "view@x": 3, + "pf_xs1": 6, + "view@xs1": 3, + "linset_takeoutmax_ngc": 2, + "xs_": 4, + "@list_vt_nil": 1, + "linset_takeoutmin_ngc": 2, + "unsnoc": 4, + "pos": 1, + "and": 10, + "fold@xs": 1, + "ATS_PACKNAME": 1, + "ATS_STALOADFLAG": 1, + "no": 2, + "static": 1, + "loading": 1, + "at": 2, + "run": 1, + "time": 1, + "castfn": 1, + "linset2list": 1, + "": 1, + "html": 1, + "PUBLIC": 1, + "W3C": 1, + "DTD": 2, + "XHTML": 1, + "EN": 1, + "http": 2, + "www": 1, + "w3": 1, + "org": 1, + "TR": 1, + "xhtml11": 2, + "dtd": 1, + "": 1, + "xmlns=": 1, + "": 1, + "": 1, + "equiv=": 1, + "content=": 1, + "": 1, + "EFFECTIVATS": 1, + "DiningPhil2": 1, + "": 1, + "#patscode_style": 1, + "": 1, + "": 1, + "

": 1, + "Effective": 1, + "ATS": 2, + "Dining": 2, + "Philosophers": 2, + "

": 1, + "In": 2, + "this": 2, + "article": 2, + "present": 1, + "an": 6, + "implementation": 3, + "slight": 1, + "variant": 1, + "the": 30, + "famous": 1, + "problem": 1, + "by": 4, + "Dijkstra": 1, + "that": 8, + "makes": 1, + "simple": 1, + "but": 1, + "convincing": 1, + "use": 1, + "linear": 2, + "types.": 1, + "

": 8, + "The": 8, + "Original": 2, + "Problem": 2, + "

": 8, + "There": 3, + "are": 7, + "five": 1, + "philosophers": 1, + "sitting": 1, + "around": 1, + "table": 3, + "there": 3, + "also": 3, + "forks": 7, + "placed": 1, + "on": 8, + "such": 1, + "each": 2, + "located": 2, + "between": 1, + "left": 3, + "hand": 6, + "philosopher": 5, + "right": 3, + "another": 1, + "philosopher.": 1, + "Each": 4, + "does": 1, + "following": 6, + "routine": 1, + "repeatedly": 1, + "thinking": 1, + "dining.": 1, + "order": 1, + "dine": 1, + "needs": 2, + "first": 2, + "acquire": 1, + "two": 3, + "one": 3, + "his": 4, + "side": 2, + "other": 2, + "side.": 2, + "After": 2, + "finishing": 1, + "dining": 1, + "puts": 2, + "acquired": 1, + "onto": 1, + "A": 6, + "Variant": 1, + "twist": 1, + "added": 1, + "original": 1, + "version": 1, + "

": 1, + "used": 1, + "it": 2, + "becomes": 1, + "be": 9, + "put": 1, + "tray": 2, + "for": 15, + "dirty": 2, + "forks.": 1, + "cleaner": 2, + "who": 1, + "cleans": 1, + "them": 2, + "back": 1, + "table.": 1, + "Channels": 1, + "Communication": 1, + "just": 1, + "shared": 1, + "queue": 1, + "fixed": 1, + "capacity.": 1, + "functions": 1, + "inserting": 1, + "element": 5, + "into": 3, + "taking": 1, + "given": 4, + "

": 7,
+      "class=": 6,
+      "#pats2xhtml_sats": 3,
+      "
": 7, + "If": 2, + "called": 2, + "full": 4, + "caller": 2, + "blocked": 3, + "until": 2, + "taken": 1, + "channel.": 2, + "empty": 1, + "inserted": 1, + "Channel": 2, + "Fork": 3, + "Forks": 1, + "resources": 1, + "type.": 1, + "initially": 1, + "stored": 2, + "which": 2, + "can": 4, + "obtained": 2, + "calling": 2, + "function": 3, + "defined": 1, + "natural": 1, + "numbers": 1, + "less": 1, + "than": 1, + "channels": 4, + "storing": 3, + "chosen": 3, + "capacity": 3, + "reason": 1, + "store": 1, + "most": 1, + "guarantee": 1, + "these": 1, + "never": 2, + "so": 2, + "attempt": 1, + "made": 1, + "send": 1, + "signals": 1, + "awake": 1, + "callers": 1, + "supposedly": 1, + "being": 2, + "due": 1, + "Tray": 1, + "instead": 1, + "become": 1, + "as": 4, + "only": 1, + "total": 1, + "Philosopher": 1, + "Loop": 2, + "implemented": 2, + "loop": 2, + "#pats2xhtml_dats": 3, + "It": 2, + "should": 3, + "straighforward": 2, + "follow": 2, + "Cleaner": 1, + "finds": 1, + "number": 2, + "uses": 1, + "locate": 1, + "fork.": 1, + "Its": 1, + "actual": 1, + "follows": 1, + "now": 1, + "Testing": 1, + "entire": 1, + "files": 1, + "DiningPhil2.sats": 1, + "DiningPhil2.dats": 1, + "DiningPhil2_fork.dats": 1, + "DiningPhil2_thread.dats": 1, + "Makefile": 1, + "available": 1, + "compiling": 1, + "source": 1, + "excutable": 1, + "testing.": 1, + "One": 1, + "able": 1, + "encounter": 1, + "after": 1, + "running": 1, + "simulation": 1, + "while.": 1, + "
": 1, + "size=": 1, + "This": 1, + "written": 1, + "href=": 1, + "Hongwei": 1, + "Xi": 1, + "
": 1, + "": 1, + "": 1, + "main": 1, + "fprint_filsub": 1, + "option0": 3, + "functor_option0": 2, + "option0_map": 1, + "functor_homres": 2, + "c": 3, + "Yoneda_phi": 3, + "Yoneda_psi": 3, + "m": 4, + "mf": 4, + "natrans": 3, + "G": 2, + "Yoneda_phi_nat": 2, + "Yoneda_psi_nat": 2, + "list_t": 1, + "g0ofg1_list": 1, + "Yoneda_bool_list0": 3, + "myboolist1": 2 + }, "AutoHotkey": { "MsgBox": 1, "Hello": 1, @@ -2961,7 +3531,7 @@ "buttons": 1 }, "C": { - "#include": 152, + "#include": 154, "const": 358, "char": 530, "*blob_type": 2, @@ -2969,10 +3539,10 @@ "struct": 360, "blob": 6, "*lookup_blob": 2, - "(": 6238, + "(": 6243, "unsigned": 140, "*sha1": 16, - ")": 6240, + ")": 6245, "{": 1531, "object": 41, "*obj": 9, @@ -3001,11 +3571,11 @@ "size": 120, "item": 24, "object.parsed": 4, - "#ifndef": 87, + "#ifndef": 89, "BLOB_H": 2, - "#define": 913, + "#define": 920, "extern": 38, - "#endif": 241, + "#endif": 243, "BOOTSTRAP_H": 2, "": 8, "__GNUC__": 8, @@ -3086,7 +3656,7 @@ "hash": 12, "*node": 2, "*result": 1, - "memcpy": 34, + "memcpy": 35, "oid": 17, "id": 13, "git_mutex_lock": 2, @@ -3885,6 +4455,13 @@ "diff_delta__merge_like_cgit": 1, "git_vector_swap": 1, "git_pool_swap": 1, + "ATSHOME_LIBATS_DYNARRAY_CATS": 3, + "": 5, + "atslib_dynarray_memcpy": 1, + "atslib_dynarray_memmove": 1, + "memmove": 2, + "//": 262, + "ifndef": 2, "git_usage_string": 2, "git_more_info_string": 2, "N_": 1, @@ -4121,7 +4698,6 @@ "": 2, "": 3, "": 3, - "": 4, "": 2, "ULLONG_MAX": 10, "MIN": 3, @@ -4817,6 +5393,15 @@ "rb_define_class": 1, "rb_cObject": 1, "rb_define_method": 2, + "READLINE_READLINE_CATS": 3, + "": 1, + "atscntrb_readline_rl_library_version": 1, + "char*": 167, + "rl_library_version": 1, + "atscntrb_readline_rl_readline_version": 1, + "rl_readline_version": 1, + "atscntrb_readline_readline": 1, + "readline": 1, "": 1, "": 1, "": 1, @@ -5072,7 +5657,6 @@ "key": 9, "dictGenHashFunction": 5, "dictSdsHash": 4, - "char*": 166, "dictSdsCaseHash": 2, "dictGenCaseHashFunction": 1, "dictEncObjKeyCompare": 4, @@ -5695,7 +6279,6 @@ "": 1, "": 2, "": 2, - "//": 257, "rfUTF8_IsContinuationbyte": 1, "e.t.c.": 1, "rfFReadLine_UTF8": 5, @@ -6172,7 +6755,6 @@ "use": 1, "determine": 1, "backs": 1, - "memmove": 1, "by": 1, "contiuing": 1, "make": 3, @@ -12715,6 +13297,43 @@ "<=>": 1, "other.name": 1 }, + "Cirru": { + "print": 38, + "array": 14, + "int": 36, + "string": 7, + "set": 12, + "f": 3, + "block": 1, + "(": 20, + "a": 22, + "b": 7, + "c": 9, + ")": 20, + "call": 1, + "bool": 6, + "true": 1, + "false": 1, + "yes": 1, + "no": 1, + "map": 8, + "m": 3, + "float": 1, + "require": 1, + "./stdio.cr": 1, + "self": 2, + "child": 1, + "under": 2, + "parent": 1, + "get": 4, + "x": 2, + "just": 4, + "-": 4, + "code": 4, + "eval": 2, + "nothing": 1, + "container": 3 + }, "Clojure": { "(": 83, "defn": 4, @@ -25467,6 +26086,13 @@ "type": 1, "url": 1 }, + "JSONLD": { + "{": 7, + "}": 7, + "[": 1, + "null": 2, + "]": 1 + }, "Julia": { "##": 5, "Test": 1, @@ -39026,12 +39652,56 @@ "TWO_PI": 1 }, "Prolog": { - "-": 38, + "-": 52, + "lib": 1, + "(": 49, + "ic": 1, + ")": 49, + ".": 25, + "vabs": 2, + "Val": 8, + "AbsVal": 10, + "#": 9, + ";": 1, + "labeling": 2, + "[": 21, + "]": 21, + "vabsIC": 1, + "or": 1, + "faitListe": 3, + "_": 2, + "First": 2, + "|": 12, + "Rest": 6, + "Taille": 2, + "Min": 2, + "Max": 2, + "Min..Max": 1, + "Taille1": 2, + "suite": 3, + "Xi": 5, + "Xi1": 7, + "Xi2": 7, + "checkRelation": 3, + "VabsXi1": 2, + "Xi.": 1, + "checkPeriode": 3, + "ListVar": 2, + "length": 1, + "Length": 2, + "<": 1, + "X1": 2, + "X2": 2, + "X3": 2, + "X4": 2, + "X5": 2, + "X6": 2, + "X7": 2, + "X8": 2, + "X9": 2, + "X10": 3, "male": 3, - "(": 29, "john": 2, - ")": 29, - ".": 17, "peter": 3, "female": 2, "vick": 2, @@ -39047,8 +39717,6 @@ "Tape": 2, "perform": 4, "q0": 1, - "[": 12, - "]": 12, "Ls": 12, "Rs": 16, "reverse": 1, @@ -39067,7 +39735,6 @@ "NewSym": 2, "Action": 2, "action": 4, - "|": 7, "Rs1": 2, "b": 2, "left": 4, @@ -40070,9 +40737,9 @@ "<": 12, "-": 12, "function": 3, - "(": 28, + "(": 29, "lines": 4, - ")": 28, + ")": 29, "{": 3, "dates": 3, "matrix": 2, @@ -40082,8 +40749,8 @@ "byrow": 2, "TRUE": 3, "days": 2, - "[": 3, - "]": 3, + "[": 4, + "]": 4, "times": 2, "hours": 2, "all.days": 2, @@ -40118,7 +40785,22 @@ "width": 1, "height": 1, "hello": 2, - "print": 1 + "print": 1, + "##polyg": 1, + "vector": 2, + "##numpoints": 1, + "number": 1, + "##output": 1, + "output": 1, + "##": 1, + "Example": 1, + "scripts": 1, + "group": 1, + "pts": 1, + "spsample": 1, + "polyg": 1, + "numpoints": 1, + "type": 1 }, "Racket": { ";": 3, @@ -47790,15 +48472,17 @@ "AppleScript": 1862, "Arduino": 20, "AsciiDoc": 103, + "ATS": 4558, "AutoHotkey": 3, "Awk": 544, "BlitzBasic": 2065, "Bluespec": 1298, "Brightscript": 579, - "C": 59004, + "C": 59053, "C#": 278, "C++": 31181, "Ceylon": 50, + "Cirru": 244, "Clojure": 510, "COBOL": 90, "CoffeeScript": 2951, @@ -47834,6 +48518,7 @@ "JavaScript": 76934, "JSON": 183, "JSON5": 57, + "JSONLD": 18, "Julia": 247, "Kotlin": 155, "KRL": 25, @@ -47880,10 +48565,10 @@ "PostScript": 107, "PowerShell": 12, "Processing": 74, - "Prolog": 267, + "Prolog": 468, "Protocol Buffer": 63, "Python": 5715, - "R": 175, + "R": 195, "Racket": 331, "Ragel in Ruby Host": 593, "RDoc": 279, @@ -47932,15 +48617,17 @@ "AppleScript": 7, "Arduino": 1, "AsciiDoc": 3, + "ATS": 10, "AutoHotkey": 1, "Awk": 1, "BlitzBasic": 3, "Bluespec": 2, "Brightscript": 1, - "C": 27, + "C": 29, "C#": 2, "C++": 27, "Ceylon": 1, + "Cirru": 9, "Clojure": 7, "COBOL": 4, "CoffeeScript": 9, @@ -47976,6 +48663,7 @@ "JavaScript": 20, "JSON": 4, "JSON5": 2, + "JSONLD": 1, "Julia": 1, "Kotlin": 1, "KRL": 1, @@ -48022,10 +48710,10 @@ "PostScript": 1, "PowerShell": 2, "Processing": 1, - "Prolog": 2, + "Prolog": 3, "Protocol Buffer": 1, "Python": 7, - "R": 2, + "R": 3, "Racket": 2, "Ragel in Ruby Host": 3, "RDoc": 1, @@ -48066,5 +48754,5 @@ "Xtend": 2, "YAML": 1 }, - "md5": "a46f14929a6e9e4356fda95beb035439" + "md5": "8815515b1699aba1650cc4e4b81587fd" } \ No newline at end of file diff --git a/samples/JSONLD/sample.jsonld b/samples/JSONLD/sample.jsonld new file mode 100644 index 00000000..dbae017a --- /dev/null +++ b/samples/JSONLD/sample.jsonld @@ -0,0 +1,30 @@ +{ + "@context": { + "property": "http://example.com/vocab#property" + }, + "@id": "../document-relative", + "@type": "#document-relative", + "property": { + "@context": { + "@base": "http://example.org/test/" + }, + "@id": "../document-base-overwritten", + "@type": "#document-base-overwritten", + "property": [ + { + "@context": null, + "@id": "../document-relative", + "@type": "#document-relative", + "property": "context completely reset, drops property" + }, + { + "@context": { + "@base": null + }, + "@id": "../document-relative", + "@type": "#document-relative", + "property": "only @base is cleared" + } + ] + } +} From 3bea39eb104f7485005af1ccc6a2e6f45c6b1c83 Mon Sep 17 00:00:00 2001 From: Andrew Couch Date: Thu, 20 Feb 2014 21:52:28 -0500 Subject: [PATCH 19/41] Add React library to vendor.yml React is a library quickly growing in popularity. Let's exclude it from language stats. --- lib/linguist/vendor.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/linguist/vendor.yml b/lib/linguist/vendor.yml index 3609b466..0470fcab 100644 --- a/lib/linguist/vendor.yml +++ b/lib/linguist/vendor.yml @@ -98,6 +98,9 @@ # AngularJS - (^|/)angular([^.]*)(\.min)?\.js$ +# React +- (^|/)react(-[^.]*)?(\.min)?\.js$ + ## Python ## # django From 92e1b1eb40d55f7a99be120c798a0c4539a17946 Mon Sep 17 00:00:00 2001 From: Miro Bezjak Date: Fri, 21 Feb 2014 11:27:47 +0100 Subject: [PATCH 20/41] Add gradle wrapper files to vendor.yml --- lib/linguist/vendor.yml | 7 +++++++ test/test_blob.rb | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/lib/linguist/vendor.yml b/lib/linguist/vendor.yml index 3609b466..135f367c 100644 --- a/lib/linguist/vendor.yml +++ b/lib/linguist/vendor.yml @@ -117,6 +117,13 @@ # Sparkle - (^|/)Sparkle/ +## Groovy ## + +# Gradle +- (^|/)gradlew$ +- (^|/)gradlew\.bat$ +- (^|/)gradle/wrapper/ + ## .NET ## # Visual Studio IntelliSense diff --git a/test/test_blob.rb b/test/test_blob.rb index 9f56265b..4ce248b0 100644 --- a/test/test_blob.rb +++ b/test/test_blob.rb @@ -343,6 +343,14 @@ class TestBlob < Test::Unit::TestCase # Vagrant assert blob("Vagrantfile").vendored? + + # Gradle + assert blob("gradlew").vendored? + assert blob("gradlew.bat").vendored? + assert blob("gradle/wrapper/gradle-wrapper.properties").vendored? + assert blob("subproject/gradlew").vendored? + assert blob("subproject/gradlew.bat").vendored? + assert blob("subproject/gradle/wrapper/gradle-wrapper.properties").vendored? end def test_language From 28a2b39a559a0c6f1b8b04816e4ee9fc8841c007 Mon Sep 17 00:00:00 2001 From: Paul Chaignon Date: Fri, 21 Feb 2014 17:48:24 +0100 Subject: [PATCH 21/41] Support of SystemVerilog --- lib/linguist/languages.yml | 8 + .../SystemVerilog/endpoint_phy_wrapper.svh | 216 ++++++++++++++++++ samples/SystemVerilog/fifo.sv | 7 + samples/SystemVerilog/priority_encoder.sv | 18 ++ 4 files changed, 249 insertions(+) create mode 100644 samples/SystemVerilog/endpoint_phy_wrapper.svh create mode 100644 samples/SystemVerilog/fifo.sv create mode 100644 samples/SystemVerilog/priority_encoder.sv diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 53dbce8c..1e9fb727 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -1653,6 +1653,14 @@ SuperCollider: lexer: Text only primary_extension: .scd +SystemVerilog: + type: programming + color: "#" + lexer: systemverilog + primary_extension: .sv + extensions: + - .svh + TOML: type: data primary_extension: .toml diff --git a/samples/SystemVerilog/endpoint_phy_wrapper.svh b/samples/SystemVerilog/endpoint_phy_wrapper.svh new file mode 100644 index 00000000..e7ab790b --- /dev/null +++ b/samples/SystemVerilog/endpoint_phy_wrapper.svh @@ -0,0 +1,216 @@ +module endpoint_phy_wrapper + ( + input clk_sys_i, + input clk_ref_i, + input clk_rx_i, + input rst_n_i, + + IWishboneMaster.master src, + IWishboneSlave.slave snk, + IWishboneMaster.master sys, + + output [9:0] td_o, + input [9:0] rd_i, + + output txn_o, + output txp_o, + + input rxn_i, + input rxp_i + ); + + wire rx_clock; + + parameter g_phy_type = "GTP"; + + wire[15:0] gtx_data; + wire [1:0]gtx_k; + wire gtx_disparity; + wire gtx_enc_error; + wire [15:0] grx_data; + wire grx_clk; + wire [1:0]grx_k; + wire grx_enc_error; + wire [3:0] grx_bitslide; + wire gtp_rst; + wire tx_clock; + + generate + if(g_phy_type == "TBI") begin + + assign rx_clock = clk_ref_i; + assign tx_clock = clk_rx_i; + + + wr_tbi_phy U_Phy + ( + .serdes_rst_i (gtp_rst), + .serdes_loopen_i(1'b0), + .serdes_prbsen_i(1'b0), + .serdes_enable_i(1'b1), + .serdes_syncen_i(1'b1), + + .serdes_tx_data_i (gtx_data[7:0]), + .serdes_tx_k_i (gtx_k[0]), + .serdes_tx_disparity_o (gtx_disparity), + .serdes_tx_enc_err_o (gtx_enc_error), + + .serdes_rx_data_o (grx_data[7:0]), + .serdes_rx_k_o (grx_k[0]), + .serdes_rx_enc_err_o (grx_enc_error), + .serdes_rx_bitslide_o (grx_bitslide), + + + .tbi_refclk_i (clk_ref_i), + .tbi_rbclk_i (clk_rx_i), + + .tbi_td_o (td_o), + .tbi_rd_i (rd_i), + .tbi_syncen_o (), + .tbi_loopen_o (), + .tbi_prbsen_o (), + .tbi_enable_o () + ); + + end else if (g_phy_type == "GTX") begin // if (g_phy_type == "TBI") + wr_gtx_phy_virtex6 + #( + .g_simulation(1) + ) U_PHY + ( + .clk_ref_i(clk_ref_i), + + .tx_clk_o (tx_clock), + .tx_data_i (gtx_data), + .tx_k_i (gtx_k), + .tx_disparity_o (gtx_disparity), + .tx_enc_err_o(gtx_enc_error), + .rx_rbclk_o (rx_clock), + .rx_data_o (grx_data), + .rx_k_o (grx_k), + .rx_enc_err_o (grx_enc_error), + .rx_bitslide_o (), + + .rst_i (!rst_n_i), + .loopen_i (1'b0), + + .pad_txn_o (txn_o), + .pad_txp_o (txp_o), + + .pad_rxn_i (rxn_i), + .pad_rxp_i (rxp_i) + ); + + end else if (g_phy_type == "GTP") begin // if (g_phy_type == "TBI") + assign #1 tx_clock = clk_ref_i; + + wr_gtp_phy_spartan6 + #( + .g_simulation(1) + ) U_PHY + ( + .gtp_clk_i(clk_ref_i), + .ch0_ref_clk_i(clk_ref_i), + + .ch0_tx_data_i (gtx_data[7:0]), + .ch0_tx_k_i (gtx_k[0]), + .ch0_tx_disparity_o (gtx_disparity), + .ch0_tx_enc_err_o(gtx_enc_error), + .ch0_rx_rbclk_o (rx_clock), + .ch0_rx_data_o (grx_data[7:0]), + .ch0_rx_k_o (grx_k[0]), + .ch0_rx_enc_err_o (grx_enc_error), + .ch0_rx_bitslide_o (), + + .ch0_rst_i (!rst_n_i), + .ch0_loopen_i (1'b0), + + .pad_txn0_o (txn_o), + .pad_txp0_o (txp_o), + + .pad_rxn0_i (rxn_i), + .pad_rxp0_i (rxp_i) + ); + + end // else: !if(g_phy_type == "TBI") + endgenerate + + wr_endpoint + #( + .g_simulation (1), + .g_pcs_16bit(g_phy_type == "GTX" ? 1: 0), + .g_rx_buffer_size (1024), + .g_with_rx_buffer(0), + .g_with_timestamper (1), + .g_with_dmtd (0), + .g_with_dpi_classifier (1), + .g_with_vlans (0), + .g_with_rtu (0) + ) DUT ( + .clk_ref_i (clk_ref_i), + .clk_sys_i (clk_sys_i), + .clk_dmtd_i (clk_ref_i), + .rst_n_i (rst_n_i), + .pps_csync_p1_i (1'b0), + + .phy_rst_o (), + .phy_loopen_o (), + .phy_enable_o (), + .phy_syncen_o (), + + .phy_ref_clk_i (tx_clock), + .phy_tx_data_o (gtx_data), + .phy_tx_k_o (gtx_k), + .phy_tx_disparity_i (gtx_disparity), + .phy_tx_enc_err_i (gtx_enc_error), + + .phy_rx_data_i (grx_data), + .phy_rx_clk_i (rx_clock), + .phy_rx_k_i (grx_k), + .phy_rx_enc_err_i (grx_enc_error), + .phy_rx_bitslide_i (5'b0), + + .src_dat_o (snk.dat_i), + .src_adr_o (snk.adr), + .src_sel_o (snk.sel), + .src_cyc_o (snk.cyc), + .src_stb_o (snk.stb), + .src_we_o (snk.we), + .src_stall_i (snk.stall), + .src_ack_i (snk.ack), + .src_err_i(1'b0), + + .snk_dat_i (src.dat_o[15:0]), + .snk_adr_i (src.adr[1:0]), + .snk_sel_i (src.sel[1:0]), + .snk_cyc_i (src.cyc), + .snk_stb_i (src.stb), + .snk_we_i (src.we), + .snk_stall_o (src.stall), + .snk_ack_o (src.ack), + .snk_err_o (src.err), + .snk_rty_o (src.rty), + + .txtsu_ack_i (1'b1), + + .rtu_full_i (1'b0), + .rtu_almost_full_i (1'b0), + .rtu_rq_strobe_p1_o (), + .rtu_rq_smac_o (), + .rtu_rq_dmac_o (), + .rtu_rq_vid_o (), + .rtu_rq_has_vid_o (), + .rtu_rq_prio_o (), + .rtu_rq_has_prio_o (), + + .wb_cyc_i(sys.cyc), + .wb_stb_i (sys.stb), + .wb_we_i (sys.we), + .wb_sel_i(sys.sel), + .wb_adr_i(sys.adr[7:0]), + .wb_dat_i(sys.dat_o), + .wb_dat_o(sys.dat_i), + .wb_ack_o (sys.ack) + ); + +endmodule // endpoint_phy_wrapper diff --git a/samples/SystemVerilog/fifo.sv b/samples/SystemVerilog/fifo.sv new file mode 100644 index 00000000..6406bc32 --- /dev/null +++ b/samples/SystemVerilog/fifo.sv @@ -0,0 +1,7 @@ +module fifo ( + input clk_50, + input clk_2, + input reset_n, + output [7:0] data_out, + output empty +); diff --git a/samples/SystemVerilog/priority_encoder.sv b/samples/SystemVerilog/priority_encoder.sv new file mode 100644 index 00000000..614b11d5 --- /dev/null +++ b/samples/SystemVerilog/priority_encoder.sv @@ -0,0 +1,18 @@ +// http://hdlsnippets.com/parameterized_priority_encoder +module priority_encoder #(parameter INPUT_WIDTH=8,OUTPUT_WIDTH=3) +( + input logic [INPUT_WIDTH-1:0] input_data, + output logic [OUTPUT_WIDTH-1:0] output_data +); + +int ii; + +always_comb +begin + output_data = 'b0; + for(ii=0;ii Date: Fri, 21 Feb 2014 18:13:42 +0100 Subject: [PATCH 22/41] CSS color added to SystemVerilog --- lib/linguist/languages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 1e9fb727..9b62cb7a 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -1655,7 +1655,7 @@ SuperCollider: SystemVerilog: type: programming - color: "#" + color: "#343761" lexer: systemverilog primary_extension: .sv extensions: From 86364da07e3c77a9f9f589fb8a53ad4a67643b0d Mon Sep 17 00:00:00 2001 From: Ted Nyman Date: Fri, 21 Feb 2014 13:50:54 -0800 Subject: [PATCH 23/41] Regenerate samples --- lib/linguist/samples.json | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/lib/linguist/samples.json b/lib/linguist/samples.json index 67f6e90e..6d26388a 100644 --- a/lib/linguist/samples.json +++ b/lib/linguist/samples.json @@ -400,6 +400,7 @@ ".scaml" ], "Scheme": [ + ".sld", ".sps" ], "Scilab": [ @@ -550,8 +551,8 @@ ".gemrc" ] }, - "tokens_total": 450519, - "languages_total": 547, + "tokens_total": 450556, + "languages_total": 548, "tokens": { "ABAP": { "*/**": 1, @@ -43089,26 +43090,26 @@ "World": 1 }, "Scheme": { - "(": 359, + "(": 366, "import": 1, "rnrs": 1, - ")": 373, + ")": 380, "only": 1, "surfage": 4, "s1": 1, "lists": 1, "filter": 4, - "-": 188, + "-": 192, "map": 4, "gl": 12, "glut": 2, "dharmalab": 2, "records": 1, - "define": 27, + "define": 30, "record": 5, "type": 5, "math": 1, - "basic": 1, + "basic": 2, "agave": 4, "glu": 1, "compat": 1, @@ -43128,7 +43129,7 @@ ";": 1684, "utilities": 1, "say": 9, - ".": 1, + ".": 2, "args": 2, "for": 7, "each": 7, @@ -43137,7 +43138,7 @@ "translate": 6, "p": 6, "glTranslated": 1, - "x": 8, + "x": 10, "y": 3, "radians": 8, "/": 7, @@ -43250,7 +43251,7 @@ "when": 5, "<=>": 3, "distance": 3, - "begin": 1, + "begin": 2, "1": 2, "f": 1, "append": 4, @@ -43275,7 +43276,16 @@ "s": 1, "space": 1, "cons": 1, - "glutMainLoop": 1 + "glutMainLoop": 1, + "library": 1, + "libs": 1, + "export": 1, + "list2": 2, + "objs": 2, + "should": 1, + "not": 1, + "be": 1, + "exported": 1 }, "Scilab": { "function": 1, @@ -48580,7 +48590,7 @@ "Sass": 56, "Scala": 750, "Scaml": 4, - "Scheme": 3478, + "Scheme": 3515, "Scilab": 69, "SCSS": 39, "Shell": 3744, @@ -48725,7 +48735,7 @@ "Sass": 2, "Scala": 4, "Scaml": 1, - "Scheme": 1, + "Scheme": 2, "Scilab": 3, "SCSS": 1, "Shell": 37, @@ -48754,5 +48764,5 @@ "Xtend": 2, "YAML": 1 }, - "md5": "8815515b1699aba1650cc4e4b81587fd" + "md5": "cfe1841f5e4b2ab14a1ad53ad64523b8" } \ No newline at end of file From 78217e1cee942a84ca14eb25f5a1e4dcdb02e95f Mon Sep 17 00:00:00 2001 From: saarin Date: Sun, 23 Feb 2014 05:22:39 +0100 Subject: [PATCH 24/41] Add shen language in linguist --- lib/linguist/languages.yml | 6 + samples/Shen/graph.shen | 321 +++++++++++++++++++++++++++++++++++++ samples/Shen/html.shen | 102 ++++++++++++ samples/Shen/json.shen | 39 +++++ 4 files changed, 468 insertions(+) create mode 100644 samples/Shen/graph.shen create mode 100644 samples/Shen/html.shen create mode 100644 samples/Shen/json.shen diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 53dbce8c..b666d4a1 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -1614,6 +1614,12 @@ Shell: filenames: - Dockerfile +Shen: + type: programming + color: "#120F14" + lexer: Text only + primary_extension: .shen + Slash: type: programming color: "#007eff" diff --git a/samples/Shen/graph.shen b/samples/Shen/graph.shen new file mode 100644 index 00000000..1c42bb55 --- /dev/null +++ b/samples/Shen/graph.shen @@ -0,0 +1,321 @@ +\* graph.shen --- a library for graph definition and manipulation + +Copyright (C) 2011, Eric Schulte + +*** License: + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*** Commentary: + +Graphs are represented as two dictionaries one for vertices and one +for edges. It is important to note that the dictionary implementation +used is able to accept arbitrary data structures as keys. This +structure technically encodes hypergraphs (a generalization of graphs +in which each edge may contain any number of vertices). Examples of a +regular graph G and a hypergraph H with the corresponding data +structure are given below. + + +--G=------------------------------------------------ + Vertices Edges + ---------- ------- + +----Graph G-----+ hash | key -> value hash | key -> value + | | -----+------>-------- -----+-------->--------- + | a---b---c g | 1 | a -> [1] 1 | [a b] -> [1 2] + | | | | 2 | b -> [1 2 3] 2 | [b c] -> [2 3] + | d---e---f | 3 | c -> [2 4] 3 | [b d] -> [2 4] + | | 4 | d -> [3 5] 4 | [c e] -> [3 5] + +----------------+ 5 | e -> [4 5 6] 5 | [d e] -> [4 5] + 6 | f -> [6] 6 | [e f] -> [5 6] + 7 | g -> [] + + +--H=------------------------------------------------ + Vertices Edges + ---------- ------- + hash | key -> value hash | key -> value + +-- Hypergraph H----+ -----+------>-------- -----+-------->--------- + | | 1 | a -> [1] 1 | [a b [1 2 + | +------+ | 2 | b -> [1] | c d -> 3 4 + | +------+------+ | 3 | c -> [1] | e f] 5 6] + | |a b c |d e f | | 4 | d -> [1 2] | + | +------+------+ | 5 | e -> [1 2] 2 | [d e [4 5 + | |g h i | j | 6 | f -> [1 2] | f g -> 6 7 + | +------+ | 7 | g -> [2] | h i] 8 9] + | | 8 | h -> [2] + +-------------------+ 9 | i -> [2] + 10 | j -> [] + + +--G=-------Graph with associated edge/vertex data--------- + Vertices Edges + ---------- ------- + +----Graph G-----+ hash | key -> value hash | key -> value + | 4 6 7 | -----+------>-------- -----+-------->--------- + |0a---b---c g | 1 | a -> (@p 0 [1]) 1 | [a b] -> (@p 4 [1 2]) + | 1| 3| | 2 | b -> [1 2 3] 2 | [b c] -> (@p 6 [2 3]) + | d---e---f | 3 | c -> [2 4] 3 | [b d] -> (@p 1 [2 4]) + | 2 5 | 4 | d -> [3 5] 4 | [c e] -> (@p 3 [3 5]) + +----------------+ 5 | e -> [4 5 6] 5 | [d e] -> (@p 2 [4 5]) + 6 | f -> [6] 6 | [e f] -> (@p 5 [5 6]) + 7 | g -> (@p 7 []) + +V = # of vertices +E = # of edges +M = # of vertex edge associations + +size = size of all vertices + all vertices stored in Vertices dict + M * sizeof(int) * 4 + indices into Vertices & Edge dicts + V * sizeof(dict entry) + storage in the Vertex dict + E * sizeof(dict entry) + storage in the Edge dict + 2 * sizeof(dict) the Vertices and Edge dicts + +*** Code: *\ +(require dict) +(require sequence) + +(datatype graph + Vertices : dictionary; + Edges : dictoinary; + =================== + (vector symbol Vertices Edges);) + +(package graph- [graph graph? vertices edges add-vertex + add-edge has-edge? has-vertex? edges-for + neighbors connected-to connected? connected-components + vertex-partition bipartite? + \* included from the sequence library\ *\ + take drop take-while drop-while range flatten + filter complement seperate zip indexed reduce + mapcon partition partition-with unique frequencies + shuffle pick remove-first interpose subset? + cartesian-product + \* included from the dict library\ *\ + dict? dict dict-> <-dict contents key? keys vals + dictionary make-dict] + +(define graph? + X -> (= graph (<-address X 0))) + +(define make-graph + \* create a graph with specified sizes for the vertex dict and edge dict *\ + {number --> number --> graph} + Vertsize Edgesize -> + (let Graph (absvector 3) + (do (address-> Graph 0 graph) + (address-> Graph 1 (make-dict Vertsize)) + (address-> Graph 2 (make-dict Edgesize)) + Graph))) + +(defmacro graph-macro + \* return a graph taking optional sizes for the vertex and edge dicts *\ + [graph] -> [make-graph 1024 1024] + [graph N] -> [make-graph N 1024] + [graph N M] -> [make-graph N M]) + +(define vert-dict Graph -> (<-address Graph 1)) + +(define edge-dict Graph -> (<-address Graph 2)) + +(define vertices + {graph --> (list A)} + Graph -> (keys (vert-dict Graph))) + +(define edges + {graph --> (list (list A))} + Graph -> (keys (edge-dict Graph))) + +(define get-data + Value V -> (if (tuple? Value) + (fst Value) + (error (make-string "no data for ~S~%" V)))) + +(define vertex-data + Graph V -> (get-data (<-dict (vert-dict Graph) V) V)) + +(define edge-data + Graph V -> (get-data (<-dict (edge-dict Graph) V) V)) + +(define resolve + {(vector (list A)) --> (@p number number) --> A} + Vector (@p Index Place) -> (nth (+ 1 Place) (<-vector Vector Index))) + +(define resolve-vert + {graph --> (@p number number) --> A} + Graph Place -> (resolve (<-address (vert-dict Graph) 2) Place)) + +(define resolve-edge + {graph --> (@p number number) --> A} + Graph Place -> (resolve (<-address (edge-dict Graph) 2) Place)) + +(define edges-for + {graph --> A --> (list (list A))} + Graph Vert -> (let Val (trap-error (<-dict (vert-dict Graph) Vert) (/. E [])) + Edges (if (tuple? Val) (snd Val) Val) + (map (lambda X (fst (resolve-edge Graph X))) Val))) + +(define add-vertex-w-data + \* add a vertex to a graph *\ + {graph --> A --> B --> A} + G V Data -> (do (dict-> (vert-dict G) V (@p Data (edges-for G V))) V)) + +(define add-vertex-w/o-data + \* add a vertex to a graph *\ + {graph --> A --> B --> A} + G V -> (do (dict-> (vert-dict G) V (edges-for G V)) V)) + +(defmacro add-vertex-macro + [add-vertex G V] -> [add-vertex-w/o-data G V] + [add-vertex G V D] -> [add-vertex-w-data G V D]) + +(define update-vert + \* in a dict, add an edge to a vertex's edge list *\ + {vector --> (@p number number) --> A --> number} + Vs Edge V -> (let Store (<-address Vs 2) + N (hash V (limit Store)) + VertLst (trap-error (<-vector Store N) (/. E [])) + Contents (trap-error (<-dict Vs V) (/. E [])) + (do (dict-> Vs V (if (tuple? Contents) + (@p (fst Contents) + (adjoin Edge (snd Contents))) + (adjoin Edge Contents))) + (@p N (length VertLst))))) + +(define update-edges-vertices + \* add an edge to a graph *\ + {graph --> (list A) --> (list A)} + Graph Edge -> + (let Store (<-address (edge-dict Graph) 2) + EdgeID (hash Edge (limit Store)) + EdgeLst (trap-error (<-vector Store EdgeID) (/. E [])) + (map (update-vert (vert-dict Graph) (@p EdgeID (length EdgeLst))) Edge))) + +(define add-edge-w-data + G E D -> (do (dict-> (edge-dict G) E (@p D (update-edges-vertices G E))) E)) + +(define add-edge-w/o-data + G E -> (do (dict-> (edge-dict G) E (update-edges-vertices G E)) E)) + +(defmacro add-edge-macro + [add-edge G E] -> [add-edge-w/o-data G E] + [add-edge G E V] -> [add-edge-w-data G E V]) + +(define has-edge? + {graph --> (list A) --> boolean} + Graph Edge -> (key? (edge-dict Graph) Edge)) + +(define has-vertex? + {graph --> A --> boolean} + Graph Vertex -> (key? (vert-dict Graph) Vertex)) + +(define neighbors + \* Return the neighbors of a vertex *\ + {graph --> A --> (list A)} + Graph Vert -> (unique (mapcon (remove-first Vert) (edges-for Graph Vert)))) + +(define connected-to- + {graph --> (list A) --> (list A) --> (list A)} + Graph [] Already -> Already + Graph New Already -> + (let Reachable (unique (mapcon (neighbors Graph) New)) + New (difference Reachable Already) + (connected-to- Graph New (append New Already)))) + +(define connected-to + \* return all vertices connected to the given vertex, including itself *\ + {graph --> A --> (list A)} + Graph V -> (connected-to- Graph [V] [V])) + +(define connected? + \* return if a graph is fully connected *\ + {graph --> boolean} + Graph -> (reduce (/. V Acc + (and Acc + (subset? (vertices Graph) (connected-to Graph V)))) + true (vertices Graph))) + +(define connected-components- + \* given a graph return a list of connected components *\ + {graph --> (list A) --> (list (list A)) --> (list graph)} + Graph [] _ -> [] + Graph VS [] -> (map (/. V (let Component (graph 1 0) + (do (add-vertex Component V) Component))) + VS) + Graph [V|VS] ES -> + (let Con-verts (connected-to Graph V) + Con-edges (filter (/. E (subset? E Con-verts)) ES) + Component (graph (length Con-verts) (length Con-edges)) + (do (map (add-edge-w/o-data Component) Con-edges) + (cons Component (connected-components- Graph + (difference VS Con-verts) + (difference ES Con-edges)))))) + +(define connected-components + {graph --> (list graph)} + Graph -> (connected-components- Graph (vertices Graph) (edges Graph))) + +(define place-vertex + \* given a graph, vertex and list of partitions, partition the vertex *\ + {graph --> A --> (list (list A)) --> (list (list A))} + Graph V [] -> (if (element? V (neighbors Graph V)) + (simple-error + (make-string "self-loop ~S, no vertex partition" V)) + [[V]]) + Graph V [C|CS] -> (let Neighbors (neighbors Graph V) + (if (element? V Neighbors) + (simple-error + (make-string "self-loop ~S, no vertex partition" V)) + (if (empty? (intersection C Neighbors)) + [[V|C]|CS] + [C|(place-vertex Graph V CS)])))) + +(define vertex-partition + \* partition the vertices of a graph *\ + {graph --> (list (list A))} + Graph -> (reduce (place-vertex Graph) [] (vertices Graph))) + +(define bipartite? + \* check if a graph is bipartite *\ + {graph --> boolean} + Graph -> (= 2 (length (vertex-partition Graph)))) + +) + +\* simple tests + +(set g (graph)) +(add-edge (value g) [chris patton]) +(add-edge (value g) [eric chris]) +(add-vertex (value g) nobody) +(has-edge? (value g) [patton chris]) +(edges-for (value g) chris) +(neighbors (value g) chris) +(neighbors (value g) nobody) +(connected-to (value g) chris) +(connected? (value g)) +(connected-components (value g)) <- fail when package wrapper is used +(map (function vertices) (connected-components (value g))) + +*\ \ No newline at end of file diff --git a/samples/Shen/html.shen b/samples/Shen/html.shen new file mode 100644 index 00000000..62d93c30 --- /dev/null +++ b/samples/Shen/html.shen @@ -0,0 +1,102 @@ +\* html.shen --- html generation functions for shen + +Copyright (C) 2011, Eric Schulte + +*** License: + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*** Commentary: + +The standard lisp-to-html conversion tool suite. Follows some of +the convertions of Clojure's hiccup. + + an example... + +(8-) (html [ul#todo1.tasks.stuff [: [title "today"]] + (map (lambda Str [li Str]) ["get milk" "dishes"])]) +"
    +
  • get milk
  • dishes
" + +*** Code: *\ +(trap-error + (require string) + (/. E (load "../string/string.shen"))) + +(package string- [html + \* symbols included from string *\ + takestr dropstr substr length-str index-str + reverse-str starts-with substr? replace-str + join split trim-left trim-right chomp trim] + +(define to-str + \* return argument as a string, if already a string do not change *\ + X -> X where (string? X) + X -> (str X)) + +(define gassoc + X Y -> (hd (tl (assoc X Y)))) + +(define dassoc + X Y -> (remove (assoc X Y) Y)) + +(define passoc + [] Y -> Y + [X XV] Y -> (let Orig (gassoc X Y) + New (if (cons? Orig) [XV|Orig] XV) + [[X New]|(dassoc X Y)])) + +(define html + X -> X where (string? X) + [Tag [: |Attrs] |Body] -> + (let Tag-comps (css-parse-symbol Tag) + Tag (gassoc tag Tag-comps) + New-attrs (passoc (assoc class Tag-comps) + (passoc (assoc id Tag-comps) Attrs)) + (@s (make-string "<~S" Tag) (attributes New-attrs) ">" + (html Body) + (make-string "" Tag))) where (symbol? Tag) + [Tag|Body] -> (html [Tag [:] Body]) where (symbol? Tag) + [H|HS] -> (@s (html H) (html HS)) + [] -> "") + +(define css-parse-symbol + {symbol --> [[symbol A]]} + Symbol -> (let String (str Symbol) + Class-split (split (str .) String) + Class (map (function intern) (tl Class-split)) + Id-split (split (str #) (hd Class-split)) + Tag (hd Id-split) + Id (tl Id-split) + ((if (= [] Id) (/. X X) (cons [id (intern (hd Id))])) + ((if (= [] Class) (/. X X) (cons [class Class])) + [[tag (intern Tag)]])))) + +(define attributes + [] -> "" + [[K V]|AS] -> (@s " " (to-str K) "='" + (if (cons? V) (join " " (map (function str) V)) (to-str V)) + "'" (attributes AS))) + +) \ No newline at end of file diff --git a/samples/Shen/json.shen b/samples/Shen/json.shen new file mode 100644 index 00000000..b330c5c6 --- /dev/null +++ b/samples/Shen/json.shen @@ -0,0 +1,39 @@ +(load "grammar.shen") + +\* + +JSON Lexer + +1. Read a stream of characters +2. Whitespace characters not in strings should be discarded. +3. Whitespace characters in strings should be preserved +4. Strings can contain escaped double quotes. e.g. "\"" + +*\ + +(define whitespacep + \* e.g. ASCII 32 == #\Space. *\ + \* All the others are whitespace characters from an ASCII table. *\ + Char -> (member Char ["c#9;" "c#10;" "c#11;" "c#12;" "c#13;" "c#32;"])) + +(define replace-whitespace + "" -> "" + (@s Whitespace Suffix) -> (@s "" (replace-whitespace Suffix)) where (whitespacep Whitespace) + (@s Prefix Suffix) -> (@s Prefix (replace-whitespace Suffix))) + +(define fetch-until-unescaped-doublequote + [] -> [] + ["\" "c#34;" | Chars] -> ["\" "c#34;" | (fetch-until-unescaped-doublequote Chars)] + ["c#34;" | Chars] -> [] + [Char | Chars] -> [Char | (fetch-until-unescaped-doublequote Chars)]) + +\* (define strip-whitespace-chars *\ +\* [] -> [] *\ +\* ["c#34;" | Chars] -> ["c#34;" | ( *\ +\* [WhitespaceChar | Chars] -> (strip-whitespace-chars Chars) where (whitespace? WhitespaceChar) *\ +\* [Char | Chars] -> [Char | (strip-whitespace-chars Chars)]) *\ + +(define tokenise + JSONString -> + (let CharList (explode JSONString) + CharList)) \ No newline at end of file From ee370cbf436b426614afb7705f480140714794cc Mon Sep 17 00:00:00 2001 From: Paul Chaignon Date: Tue, 25 Feb 2014 11:22:28 +0100 Subject: [PATCH 25/41] Support of AspectJ language --- lib/linguist/languages.yml | 6 +++ samples/AspectJ/CacheAspect.aj | 41 +++++++++++++++++++ samples/AspectJ/OptimizeRecursionCache.aj | 50 +++++++++++++++++++++++ test/test_language.rb | 1 + 4 files changed, 98 insertions(+) create mode 100644 samples/AspectJ/CacheAspect.aj create mode 100644 samples/AspectJ/OptimizeRecursionCache.aj diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 53dbce8c..12eac5c9 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -129,6 +129,12 @@ AsciiDoc: - .adoc - .asc +AspectJ: + type: programming + lexer: AspectJ + color: "#1957b0" + primary_extension: .aj + Assembly: type: programming lexer: NASM diff --git a/samples/AspectJ/CacheAspect.aj b/samples/AspectJ/CacheAspect.aj new file mode 100644 index 00000000..bfab7bc4 --- /dev/null +++ b/samples/AspectJ/CacheAspect.aj @@ -0,0 +1,41 @@ +package com.blogspot.miguelinlas3.aspectj.cache; + +import java.util.Map; +import java.util.WeakHashMap; + +import org.aspectj.lang.JoinPoint; + +import com.blogspot.miguelinlas3.aspectj.cache.marker.Cachable; + +/** + * This simple aspect simulates the behaviour of a very simple cache + * + * @author migue + * + */ +public aspect CacheAspect { + + public pointcut cache(Cachable cachable): execution(@Cachable * * (..)) && @annotation(cachable); + + Object around(Cachable cachable): cache(cachable){ + + String evaluatedKey = this.evaluateKey(cachable.scriptKey(), thisJoinPoint); + + if(cache.containsKey(evaluatedKey)){ + System.out.println("Cache hit for key " + evaluatedKey); + return this.cache.get(evaluatedKey); + } + + System.out.println("Cache miss for key " + evaluatedKey); + Object value = proceed(cachable); + cache.put(evaluatedKey, value); + return value; + } + + protected String evaluateKey(String key, JoinPoint joinPoint) { + // TODO add some smart staff to allow simple scripting in @Cachable annotation + return key; + } + + protected Map cache = new WeakHashMap(); +} diff --git a/samples/AspectJ/OptimizeRecursionCache.aj b/samples/AspectJ/OptimizeRecursionCache.aj new file mode 100644 index 00000000..ed1e8695 --- /dev/null +++ b/samples/AspectJ/OptimizeRecursionCache.aj @@ -0,0 +1,50 @@ +package aspects.caching; + +import java.util.Map; + +/** + * Cache aspect for optimize recursive functions. + * + * @author Migueli + * @date 05/11/2013 + * @version 1.0 + * + */ +public abstract aspect OptimizeRecursionCache { + + @SuppressWarnings("rawtypes") + private Map _cache; + + public OptimizeRecursionCache() { + _cache = getCache(); + } + + @SuppressWarnings("rawtypes") + abstract public Map getCache(); + + abstract public pointcut operation(Object o); + + pointcut topLevelOperation(Object o): operation(o) && !cflowbelow(operation(Object)); + + before(Object o) : topLevelOperation(o) { + System.out.println("Seeking value for " + o); + } + + Object around(Object o) : operation(o) { + Object cachedValue = _cache.get(o); + if (cachedValue != null) { + System.out.println("Found cached value for " + o + ": " + cachedValue); + return cachedValue; + } + return proceed(o); + } + + @SuppressWarnings("unchecked") + after(Object o) returning(Object result) : topLevelOperation(o) { + _cache.put(o, result); + } + + after(Object o) returning(Object result) : topLevelOperation(o) { + System.out.println("cache size: " + _cache.size()); + } +} diff --git a/test/test_language.rb b/test/test_language.rb index 41ee2a72..8415e6eb 100644 --- a/test/test_language.rb +++ b/test/test_language.rb @@ -10,6 +10,7 @@ class TestLanguage < Test::Unit::TestCase def test_lexer assert_equal Lexer['ActionScript 3'], Language['ActionScript'].lexer + assert_equal Lexer['AspectJ'], Language['AspectJ'].lexer assert_equal Lexer['Bash'], Language['Gentoo Ebuild'].lexer assert_equal Lexer['Bash'], Language['Gentoo Eclass'].lexer assert_equal Lexer['Bash'], Language['Shell'].lexer From 8b00872d368cbcfb957d97d4e8ecf78b9873160c Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Wed, 26 Feb 2014 02:15:08 -0800 Subject: [PATCH 26/41] Added Gemfile.lock to the list of Ruby filenames --- lib/linguist/languages.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index b666d4a1..6ad19ada 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -1524,6 +1524,7 @@ Ruby: - Appraisals - Berksfile - Gemfile + - Gemfile.lock - Guardfile - Podfile - Thorfile From 4c500e1fb2fd4efd3675d06f145938c6b4657265 Mon Sep 17 00:00:00 2001 From: David Whitten Date: Fri, 28 Feb 2014 10:34:14 -0500 Subject: [PATCH 27/41] Comment.m : routine with comments but no commands The routine Comment.m has most of the rules for comments and tags. --- samples/M/Comment.m | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 samples/M/Comment.m diff --git a/samples/M/Comment.m b/samples/M/Comment.m new file mode 100644 index 00000000..6ddd7653 --- /dev/null +++ b/samples/M/Comment.m @@ -0,0 +1,36 @@ +Comment ; + ; this is a comment block + ; comments always start with a semicolon + ; the next line, while not a comment, is a legal blank line + + ;whitespace alone is a valid line in a routine + ;** Comments can have any graphic character, but no "control" + ;** characters + + ;graphic characters such as: !@#$%^&*()_+=-{}[]|\:"?/>.<, + ;the space character is considered a graphic character, even + ;though you can't see it. + ; ASCII characters whose numeric code is above 128 and below 32 + ; are NOT allowed on a line in a routine. + ;; multiple semicolons are okay + ; a line that has a tag must have whitespace after the tag, bug + ; does not have to have a comment or a command on it +Tag1 + ; + ;Tags can start with % or an uppercase or lowercase alphabetic + ; or can be a series of numeric characters +%HELO ; + ; +0123 ; + ; +%987 ; + ; the most common label is uppercase alphabetic +LABEL ; + ; + ; Tags can be followed directly by an open parenthesis and a + ; formal list of variables, and a close parenthesis +ANOTHER(X) ; + ; + ;Normally, a subroutine would be ended by a QUIT command, but we + ; are taking advantage of the rule that the END of routine is an + ; implicit QUIT From cb9bef43a5556df70d49adf041030a4db8c6bed5 Mon Sep 17 00:00:00 2001 From: Paul Chaignon Date: Tue, 4 Mar 2014 10:44:23 +0100 Subject: [PATCH 28/41] Support of the .vh file extension for SystemVerilog --- lib/linguist/languages.yml | 1 + samples/SystemVerilog/util.vh | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 samples/SystemVerilog/util.vh diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 9b62cb7a..5124e2b8 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -1660,6 +1660,7 @@ SystemVerilog: primary_extension: .sv extensions: - .svh + - .vh TOML: type: data diff --git a/samples/SystemVerilog/util.vh b/samples/SystemVerilog/util.vh new file mode 100644 index 00000000..d7c510b3 --- /dev/null +++ b/samples/SystemVerilog/util.vh @@ -0,0 +1,8 @@ +function integer log2; + input integer x; + begin + x = x-1; + for (log2 = 0; x > 0; log2 = log2 + 1) + x = x >> 1; + end +endfunction From 210ca9a86f9ad502dcf9b2f686bae50807ca1ecf Mon Sep 17 00:00:00 2001 From: Nayeem Syed Date: Thu, 6 Mar 2014 12:00:54 +0000 Subject: [PATCH 29/41] added VCR Cassette to the 'generated' list so they get suppressed --- lib/linguist/generated.rb | 11 ++++++++++- samples/YAML/vcr_cassette.yml | 20 ++++++++++++++++++++ test/test_blob.rb | 3 +++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 samples/YAML/vcr_cassette.yml diff --git a/lib/linguist/generated.rb b/lib/linguist/generated.rb index 14c64444..f02e9b20 100644 --- a/lib/linguist/generated.rb +++ b/lib/linguist/generated.rb @@ -62,7 +62,8 @@ module Linguist generated_protocol_buffer? || generated_jni_header? || composer_lock? || - node_modules? + node_modules? || + vcr_cassette? end # Internal: Is the blob an XCode project file? @@ -235,5 +236,13 @@ module Linguist def composer_lock? !!name.match(/composer.lock/) end + + # Is the blob a VCR Cassette file? + # + # Returns true or false + def vcr_cassette? + # VCR Cassettes have "recorded_with: VCR" in the second last line. + return lines[-2].include?("recorded_with: VCR") + end end end diff --git a/samples/YAML/vcr_cassette.yml b/samples/YAML/vcr_cassette.yml new file mode 100644 index 00000000..cf21a3fb --- /dev/null +++ b/samples/YAML/vcr_cassette.yml @@ -0,0 +1,20 @@ +--- +http_interactions: +- request: + method: get + uri: http://example.com/ + body: '' + headers: {} + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/html;charset=utf-8 + Content-Length: + - '26' + body: This is the response body + http_version: '1.1' + recorded_at: Tue, 01 Nov 2011 04:58:44 GMT +recorded_with: VCR 2.0.0 diff --git a/test/test_blob.rb b/test/test_blob.rb index 9f56265b..a9d6e524 100644 --- a/test/test_blob.rb +++ b/test/test_blob.rb @@ -211,6 +211,9 @@ class TestBlob < Test::Unit::TestCase assert !blob("CSS/bootstrap.css").generated? assert blob("CSS/bootstrap.min.css").generated? + # Generated VCR + assert blob("YAML/vcr_cassette.yml").generated? + assert Linguist::Generated.generated?("node_modules/grunt/lib/grunt.js", nil) end From 3a19ba452305eccdbd3b41c8af413b7d7e86fcaf Mon Sep 17 00:00:00 2001 From: Max Ogden Date: Thu, 6 Mar 2014 23:10:05 -0800 Subject: [PATCH 30/41] dramatically enhance colors for javascript and css --- lib/linguist/languages.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 9bd6450d..f8732596 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -299,7 +299,7 @@ COBOL: CSS: ace_mode: css - color: "#1f085e" + color: "#563d7c" primary_extension: .css Ceylon: @@ -878,7 +878,7 @@ Java Server Pages: JavaScript: type: programming ace_mode: javascript - color: "#f15501" + color: "#f7df1e" aliases: - js - node From 54c1d7c9d90ec227dc75e77e0c56a6fa455145c5 Mon Sep 17 00:00:00 2001 From: Max Ogden Date: Thu, 6 Mar 2014 23:38:59 -0800 Subject: [PATCH 31/41] update improved javascript color in test_language --- test/test_language.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_language.rb b/test/test_language.rb index 41ee2a72..a7747983 100644 --- a/test/test_language.rb +++ b/test/test_language.rb @@ -322,7 +322,7 @@ class TestLanguage < Test::Unit::TestCase def test_color assert_equal '#701516', Language['Ruby'].color assert_equal '#3581ba', Language['Python'].color - assert_equal '#f15501', Language['JavaScript'].color + assert_equal '#f7df1e', Language['JavaScript'].color assert_equal '#31859c', Language['TypeScript'].color end From 68793b1f0f514c388055b21372eafa1eb183d861 Mon Sep 17 00:00:00 2001 From: Nayeem Syed Date: Sat, 8 Mar 2014 08:12:18 +0000 Subject: [PATCH 32/41] added check for extension and line count on vcr_cassette? in generated --- lib/linguist/generated.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/linguist/generated.rb b/lib/linguist/generated.rb index f02e9b20..5c3de141 100644 --- a/lib/linguist/generated.rb +++ b/lib/linguist/generated.rb @@ -241,6 +241,8 @@ module Linguist # # Returns true or false def vcr_cassette? + return false unless extname == '.yml' + return false unless lines.count > 2 # VCR Cassettes have "recorded_with: VCR" in the second last line. return lines[-2].include?("recorded_with: VCR") end From 83234509580007013aafb93e3f723349d93200dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eXerigumo=20Clanjor=20=28=E5=93=86=E5=95=A6=E6=AF=94?= =?UTF-8?q?=E7=8C=AB/=E5=85=B0=E5=A8=81=E4=B8=BE=29?= Date: Sun, 9 Mar 2014 16:12:30 +0800 Subject: [PATCH 33/41] add extension .cc for c++ --- lib/linguist/languages.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 9bd6450d..2b4c355c 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -254,6 +254,7 @@ C++: extensions: - .C - .c++ + - .cc - .cxx - .H - .h++ From 7c85c1194406d50f4d733f82d7ba1921f7f1d714 Mon Sep 17 00:00:00 2001 From: Douglas Adam Smith II Date: Tue, 11 Mar 2014 13:38:10 -0400 Subject: [PATCH 34/41] Updated How language to FLUX (name change) --- lib/linguist/languages.yml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index b653f4fb..2f928326 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -562,6 +562,16 @@ Fantom: type: programming color: "#dbded5" primary_extension: .fan + +FLUX: + type: programming + color: "#33CCFF" + primary_extension: .fx + lexer: Text only + extensions: + - .flux + - .FLUX + - .FX Forth: type: programming @@ -723,15 +733,6 @@ Haxe: primary_extension: .hx extensions: - .hxsl - -HOW: - type: programming - coloe: "#CC0099" - lexer: Text only - primary_extension: .how - extensions: - - .howmeta - - .howproj INI: type: data From e4c1cc572be2606c4007688782e96440c63cba0a Mon Sep 17 00:00:00 2001 From: Douglas Adam Smith II Date: Tue, 11 Mar 2014 13:51:16 -0400 Subject: [PATCH 35/41] Fixed order of languages. Forgot how ASCI works. This will (hopefully) fix the build. --- lib/linguist/languages.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 2f928326..edc10596 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -558,20 +558,20 @@ Fancy: filenames: - Fakefile -Fantom: - type: programming - color: "#dbded5" - primary_extension: .fan - FLUX: type: programming color: "#33CCFF" primary_extension: .fx lexer: Text only extensions: - - .flux - - .FLUX - .FX + - .FLUX + - .flux + +Fantom: + type: programming + color: "#dbded5" + primary_extension: .fan Forth: type: programming From 29510b26e00bed1207b430106cb16ae8edd49cd3 Mon Sep 17 00:00:00 2001 From: Douglas Adam Smith II Date: Tue, 11 Mar 2014 14:00:49 -0400 Subject: [PATCH 36/41] Fix --- lib/linguist/languages.yml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index edc10596..a41c0f59 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -541,6 +541,14 @@ FORTRAN: - .for - .fpp +FLUX: + type: programming + color: "#33CCFF" + primary_extension: .fx + lexer: Text only + extensions: + - .flux + Factor: type: programming color: "#636746" @@ -557,16 +565,6 @@ Fancy: - .fancypack filenames: - Fakefile - -FLUX: - type: programming - color: "#33CCFF" - primary_extension: .fx - lexer: Text only - extensions: - - .FX - - .FLUX - - .flux Fantom: type: programming From 645411e2566ff0706e3d474ad049e71ffc7b6928 Mon Sep 17 00:00:00 2001 From: Douglas Adam Smith II Date: Tue, 11 Mar 2014 14:23:28 -0400 Subject: [PATCH 37/41] Testing... --- lib/linguist/languages.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index a41c0f59..08437d86 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -519,6 +519,14 @@ F#: - .fsi - .fsx +FLUX: + type: programming + color: "#33CCFF" + primary_extension: .fx + lexer: Text only + extensions: + - .flux + FORTRAN: type: programming lexer: Fortran @@ -541,14 +549,6 @@ FORTRAN: - .for - .fpp -FLUX: - type: programming - color: "#33CCFF" - primary_extension: .fx - lexer: Text only - extensions: - - .flux - Factor: type: programming color: "#636746" From 957dd15d5b2bafda0884f60899166feed580bf6c Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Fri, 14 Mar 2014 22:03:31 +0700 Subject: [PATCH 38/41] Add .lid and .intr extensions for Dylan. --- lib/linguist/languages.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 01f4b4cd..6eb2a378 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -492,6 +492,9 @@ Dylan: type: programming color: "#3ebc27" primary_extension: .dylan + extensions: + - .intr + - .lid Ecere Projects: type: data From a1641f2ffae9675850cee0ccd203794223c70d98 Mon Sep 17 00:00:00 2001 From: Shrayas Rajagopal Date: Mon, 7 Apr 2014 11:35:28 +0530 Subject: [PATCH 39/41] Fixing cache vendor regex * Fixes #1051 * Any folder with "cache" in it was being ignored. This fixes it. --- lib/linguist/vendor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linguist/vendor.yml b/lib/linguist/vendor.yml index 135f367c..5a9f9e18 100644 --- a/lib/linguist/vendor.yml +++ b/lib/linguist/vendor.yml @@ -10,7 +10,7 @@ ## Vendor Conventions ## # Caches -- cache/ +- (^|/)cache/ # Dependencies - ^[Dd]ependencies/ From 3f96bcc32beb57109a543536be206bf155a41e1e Mon Sep 17 00:00:00 2001 From: Lucas Werkmeister Date: Sat, 12 Apr 2014 01:55:29 +0200 Subject: [PATCH 40/41] Add .osm extension for XML The OpenStreetMap project (openstreetmap.org) uses the .osm extension for the OSM XML format (http://wiki.openstreetmap.org/wiki/OSM_XML). --- lib/linguist/languages.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 6eb2a378..95b94f20 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -1858,6 +1858,7 @@ XML: - .kml - .launch - .mxml + - .osm - .plist - .pluginspec - .ps1xml From 97908204a385940e47251af9ecb689e8f6515c48 Mon Sep 17 00:00:00 2001 From: Rick Bradley Date: Thu, 17 Apr 2014 11:28:15 -0500 Subject: [PATCH 41/41] 2.10.12 --- github-linguist.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github-linguist.gemspec b/github-linguist.gemspec index f10f8d1f..ca7647b8 100644 --- a/github-linguist.gemspec +++ b/github-linguist.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = 'github-linguist' - s.version = '2.10.11' + s.version = '2.10.12' s.summary = "GitHub Language detection" s.description = 'We use this library at GitHub to detect blob languages, highlight code, ignore binary files, suppress generated files in diffs, and generate language breakdown graphs.'