diff options
author | Gaurav Jain <gaurav@gauravjain.org> | 2014-05-16 22:54:11 -0400 |
---|---|---|
committer | Gaurav Jain <gaurav@gauravjain.org> | 2014-05-16 22:54:11 -0400 |
commit | 2af9819f9c0b308852a79a59ca0390de7a6eabe0 (patch) | |
tree | 31f4d72b3f28c1dc4673654c715573b8f8d1d84d | |
parent | 778edd1d5ff974b1d4084af964151d9f87f05efd (diff) | |
download | pygments-2af9819f9c0b308852a79a59ca0390de7a6eabe0.tar.gz |
Add shebang support to Groovy lexer
-rw-r--r-- | pygments/lexers/jvm.py | 8 | ||||
-rwxr-xr-x | tests/examplefiles/example.groovy | 2 |
2 files changed, 10 insertions, 0 deletions
diff --git a/pygments/lexers/jvm.py b/pygments/lexers/jvm.py index 4633c66f..259905e9 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), + (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" |