Added detection for the new M (aka MUMPS) language.

This commit is contained in:
Laurent Parenteau
2012-03-27 11:47:52 -04:00
parent 3b7b2020d2
commit e0190a5a6e
4 changed files with 20 additions and 0 deletions

View File

@@ -457,6 +457,9 @@ module Linguist
# * Leading function keyword # * Leading function keyword
# * "%" comments # * "%" comments
# #
# M heuristics:
# * ";" comments
#
# Returns a Language. # Returns a Language.
def guess_m_language def guess_m_language
# Objective-C keywords # Objective-C keywords
@@ -471,6 +474,10 @@ module Linguist
elsif lines.grep(/^%/).any? elsif lines.grep(/^%/).any?
Language['Matlab'] Language['Matlab']
# M comment
elsif lines.grep(/^[ \t]*;/).any?
Language['M']
# Fallback to Objective-C, don't want any Matlab false positives # Fallback to Objective-C, don't want any Matlab false positives
else else
Language['Objective-C'] Language['Objective-C']

View File

@@ -627,6 +627,14 @@ Lua:
- .lua - .lua
- .nse - .nse
M:
type: programming
lexer: Text only
aliases:
- mumps
extensions:
- .m
Makefile: Makefile:
extensions: extensions:
- .mak - .mak

4
test/fixtures/m_simple.m vendored Normal file
View File

@@ -0,0 +1,4 @@
fox
; The quick brown fox jumps over the lazy dog
write "The quick brown fox jumps over the lazy dog",!
quit

View File

@@ -307,6 +307,7 @@ class TestBlob < Test::Unit::TestCase
assert_equal Language['Objective-C'], blob("hello.m").language assert_equal Language['Objective-C'], blob("hello.m").language
assert_equal Language['Matlab'], blob("matlab_function.m").language assert_equal Language['Matlab'], blob("matlab_function.m").language
assert_equal Language['Matlab'], blob("matlab_script.m").language assert_equal Language['Matlab'], blob("matlab_script.m").language
assert_equal Language['M'], blob("m_simple.m").language
# .r disambiguation # .r disambiguation
assert_equal Language['R'], blob("hello-r.R").language assert_equal Language['R'], blob("hello-r.R").language