Add support for Cool

This change includes a brief (non-sensical) sample program I wrote to
illustrate many of Cool's language constructs, as well as a simple rule
to distinguish Cool files from Common Lisp or OpenCL (it has a line that
starts with the word 'class'). Further, it includes a second example
program adapted from an example contained in the Cool distribution
(list.cl), which contains a few further language constructs and captures
the style of a Cool program.
This commit is contained in:
Trey Deitch
2014-05-08 13:21:57 -07:00
parent 9873157076
commit 913cd6c309
5 changed files with 203 additions and 4 deletions

View File

@@ -25,7 +25,7 @@ module Linguist
if languages.all? { |l| ["TypeScript", "XML"].include?(l) }
disambiguate_ts(data, languages)
end
if languages.all? { |l| ["Common Lisp", "OpenCL"].include?(l) }
if languages.all? { |l| ["Common Lisp", "Cool", "OpenCL"].include?(l) }
disambiguate_cl(data, languages)
end
if languages.all? { |l| ["Rebol", "R"].include?(l) }
@@ -72,6 +72,7 @@ module Linguist
def self.disambiguate_cl(data, languages)
matches = []
matches << Language["Common Lisp"] if data.include?("(defun ")
matches << Language["Cool"] if /^class/x.match(data)
matches << Language["OpenCL"] if /\/\* |\/\/ |^\}/.match(data)
matches
end

View File

@@ -429,6 +429,12 @@ Common Lisp:
- clisp
- ecl
Cool:
type: programming
lexer: Text only
extensions:
- .cl
Coq:
type: programming
extensions:

View File

@@ -91,6 +91,9 @@
".cl",
".lisp"
],
"Cool": [
".cl"
],
"Coq": [
".v"
],
@@ -702,8 +705,8 @@
".gemrc"
]
},
"tokens_total": 607168,
"languages_total": 739,
"tokens_total": 607535,
"languages_total": 741,
"tokens": {
"ABAP": {
"*/**": 1,
@@ -15134,6 +15137,96 @@
"line": 2,
"After": 1
},
"Cool": {
"class": 7,
"List": 8,
"{": 27,
"isNil": 2,
"(": 30,
")": 30,
"Bool": 5,
"true": 2,
"}": 27,
";": 40,
"head": 2,
"Int": 15,
"abort": 2,
"tail": 2,
"self": 3,
"cons": 1,
"i": 7,
"new": 3,
"Cons": 2,
".init": 1,
"inherits": 4,
"car": 3,
"-": 19,
"The": 2,
"element": 1,
"in": 3,
"this": 1,
"list": 2,
"cell": 1,
"cdr": 3,
"rest": 3,
"of": 2,
"the": 1,
"false": 3,
"init": 1,
"<": 9,
"Exhibit": 1,
"various": 1,
"language": 1,
"constructs": 1,
"Sample": 5,
"testCondition": 1,
"x": 3,
"if": 3,
"then": 3,
"else": 3,
"+": 1,
"*": 3,
"fi": 2,
"testLoop": 1,
"y": 7,
"while": 1,
"loop": 1,
"not": 1,
"condition": 1,
"/": 2,
"pool": 1,
"testAssign": 1,
"z": 2,
"testCase": 1,
"var": 2,
"SELF_TYPE": 2,
"io": 1,
"IO": 3,
"<->": 1,
"case": 1,
"a": 4,
"A": 3,
"io.out_string": 4,
"b": 3,
"B": 2,
"s": 1,
"o": 1,
"Object": 1,
"esac": 1,
"testLet": 1,
"let": 2,
"c": 2,
"Used": 1,
"to": 1,
"test": 1,
"subclasses": 1,
"C": 1,
"main": 2,
".testLet": 1,
"example": 1,
"Main": 1,
"out_string": 1
},
"Coq": {
"Inductive": 41,
"day": 9,
@@ -65508,6 +65601,7 @@
"COBOL": 90,
"CoffeeScript": 2951,
"Common Lisp": 2186,
"Cool": 367,
"Coq": 18259,
"Creole": 134,
"Crystal": 1506,
@@ -65689,6 +65783,7 @@
"COBOL": 4,
"CoffeeScript": 9,
"Common Lisp": 3,
"Cool": 2,
"Coq": 12,
"Creole": 1,
"Crystal": 3,
@@ -65845,5 +65940,5 @@
"YAML": 2,
"Zephir": 2
},
"md5": "dfced8ef9ddd9813d2982dc25a5468fa"
"md5": "ee1f12dec040474f3864dfc0af301d17"
}