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