1. Georg Brandl
  2. pygments-main
  3. Issues
Issue #419 resolved

MATLAB lexer: functions without return values generate an error

Anonymous created an issue

A function definition without return arguments generates an error.

The following patch works for me:



Index: pygments/lexers/math.py

--- pygments/lexers/math.py.orig 2009-06-25 17:37:55.000000000 +0200 +++ pygments/lexers/math.py 2009-06-25 17:27:15.000000000 +0200 @@ -184,7 +184,7 @@ (r'[^\']\'', String, '#pop') ], 'deffunc': [ - (r'(\s)(.+)(\s)(=)(\s)(.+)(\()(.)(\))(\s)', + (r'(\s)(?:(.+)(\s)(=)(\s))?(.+)(\()(.)(\))(\s*)', bygroups(Text.Whitespace, Text, Text.Whitespace, Punctuation, Text.Whitespace, Name.Function, Punctuation, Text, Punctuation, Text.Whitespace), '#pop'), }}}

Reported by fmarc

Comments (7)

  1. Anonymous

    Replying to [comment:1 thatch]:

    Patch looks okay. Can you provide an example of what it fixes though, so I can add it to the test suite?

    Sure: This piece of code generates an error without the patch, but not with it:

    function myfunc(s)
        a = 1;
  2. Log in to comment