diff options
author | Georg Brandl <georg@python.org> | 2014-10-07 16:10:08 +0200 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2014-10-07 16:10:08 +0200 |
commit | 68dfb127bc105ba9b2bcadac476220ab30161da4 (patch) | |
tree | 968e28b0b29f84d8d2736eecb2829b665ddbb77d | |
parent | c009209e777e41f987bfccc9914f6615ec6b3553 (diff) | |
download | pygments-68dfb127bc105ba9b2bcadac476220ab30161da4.tar.gz |
Closes #1030: recognize functions with no args in Matlab related lexers
-rw-r--r-- | pygments/lexers/matlab.py | 12 | ||||
-rw-r--r-- | tests/examplefiles/matlab_sample | 4 |
2 files changed, 13 insertions, 3 deletions
diff --git a/pygments/lexers/matlab.py b/pygments/lexers/matlab.py index badc1fa3..b7436cd1 100644 --- a/pygments/lexers/matlab.py +++ b/pygments/lexers/matlab.py @@ -112,7 +112,7 @@ class MatlabLexer(RegexLexer): (r'\d+', Number.Integer), (r'(?<![\w\)\].])\'', String, 'string'), - ('[a-zA-Z_]\w*', Name), + (r'[a-zA-Z_]\w*', Name), (r'.', Text), ], 'string': [ @@ -128,6 +128,8 @@ class MatlabLexer(RegexLexer): bygroups(Whitespace, Text, Whitespace, Punctuation, Whitespace, Name.Function, Punctuation, Text, Punctuation, Whitespace), '#pop'), + # function with no args + (r'(\s*)([a-zA-Z_]\w*)', bygroups(Text, Name.Function), '#pop'), ], } @@ -576,7 +578,7 @@ class OctaveLexer(RegexLexer): (r'(?<=[\w\)\].])\'+', Operator), (r'(?<![\w\)\].])\'', String, 'string'), - ('[a-zA-Z_]\w*', Name), + (r'[a-zA-Z_]\w*', Name), (r'.', Text), ], 'string': [ @@ -587,6 +589,8 @@ class OctaveLexer(RegexLexer): bygroups(Whitespace, Text, Whitespace, Punctuation, Whitespace, Name.Function, Punctuation, Text, Punctuation, Whitespace), '#pop'), + # function with no args + (r'(\s*)([a-zA-Z_]\w*)', bygroups(Text, Name.Function), '#pop'), ], } @@ -641,7 +645,7 @@ class ScilabLexer(RegexLexer): (r'\d+[eEf][+-]?[0-9]+', Number.Float), (r'\d+', Number.Integer), - ('[a-zA-Z_]\w*', Name), + (r'[a-zA-Z_]\w*', Name), (r'.', Text), ], 'string': [ @@ -653,5 +657,7 @@ class ScilabLexer(RegexLexer): bygroups(Whitespace, Text, Whitespace, Punctuation, Whitespace, Name.Function, Punctuation, Text, Punctuation, Whitespace), '#pop'), + # function with no args + (r'(\s*)([a-zA-Z_]\w*)', bygroups(Text, Name.Function), '#pop'), ], } diff --git a/tests/examplefiles/matlab_sample b/tests/examplefiles/matlab_sample index 4f61afe8..bb00b517 100644 --- a/tests/examplefiles/matlab_sample +++ b/tests/examplefiles/matlab_sample @@ -28,3 +28,7 @@ y = exp(x); {% a block comment %} + +function no_arg_func +fprintf('%s\n', 'function with no args') +end |