summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Hatch <tim@timhatch.com>2014-05-17 09:13:14 -0700
committerTim Hatch <tim@timhatch.com>2014-05-17 09:13:14 -0700
commitff12540907fe9d98bf02c9508a171659457b14b2 (patch)
treed20a3538c3757a1cc4b05c6fd6804504ebe41c75
parent0bf931830db86644b28f6fae9e66f16f21406b56 (diff)
parent08efa68bf22fd1e9d4eddabdbee9818ebe066973 (diff)
downloadpygments-ff12540907fe9d98bf02c9508a171659457b14b2.tar.gz
Merged in jaingaurav2/pygments-main-993 (pull request #359)
Add shebang support to Groovy lexer
-rw-r--r--pygments/lexers/jvm.py8
-rwxr-xr-xtests/examplefiles/example.groovy2
2 files changed, 10 insertions, 0 deletions
diff --git a/pygments/lexers/jvm.py b/pygments/lexers/jvm.py
index 4633c66f..51f17ae0 100644
--- a/pygments/lexers/jvm.py
+++ b/pygments/lexers/jvm.py
@@ -437,6 +437,11 @@ class GroovyLexer(RegexLexer):
tokens = {
'root': [
+ # Groovy allows a file to start with a shebang
+ (r'#!(.*?)$', Comment.Preproc, 'base'),
+ (r'', Text, 'base'),
+ ],
+ 'base': [
# method names
(r'^(\s*(?:[a-zA-Z_][\w\.\[\]]*\s+)+?)' # return arguments
r'([a-zA-Z_]\w*)' # method name
@@ -481,6 +486,9 @@ class GroovyLexer(RegexLexer):
],
}
+ def analyse_text(text):
+ return shebang_matches(text, r'groovy')
+
class IokeLexer(RegexLexer):
"""
diff --git a/tests/examplefiles/example.groovy b/tests/examplefiles/example.groovy
new file mode 100755
index 00000000..25ef2eab
--- /dev/null
+++ b/tests/examplefiles/example.groovy
@@ -0,0 +1,2 @@
+#!/usr/bin/env groovy
+println "Hello World"