MATLAB lexer: support for new OOP syntax

Issue #521 resolved
Former user created an issue

As of MATLAB r2008a, there is a new class definition scheme in MATLAB that is not properly highlighted by the lexer. The keywords classdef, properties, methods, 'events', and enumerated (as of 2010b) should be highlighted the same as the function keyword. Documentation on MATLAB class definitions can be found [ here].

A demo is posted [ demo:5994].

I'm using release 1.3.1 of Pygments on Trac 0.11.7.

Reported by guest

Comments (6)

  1. Anonymous

    I was just looking at where you made the change and noticed that the comment says: # from 'iskeyword' on version (R2007a):.

    I checked the full list of keywords on ''' (R2010b Prerelease)''', and thought I'd pass that along in case you'd want to update the comment.

    Actually, and probably not of too much interest to you, is that MATLAB's iskeyword function does not appear to have been updated for the new classdef syntax. Again, from R2010b Prerelease:

    >> iskeyword
    ans = 

    and yet,

    >> classdef = 'abc'
    ??? classdef = 'abc'
    Error: Illegal use of reserved keyword "classdef".

    So, classdef is definitely a keyword, as are the others that I listed.

  2. Anonymous

    Actually, classdef is in that list ... I'm not sure how I missed that.

    But there actually is one missing from '''spmd'''. I'm not even sure what that keyword is for, and I'm a long time MATLAB user.

    The other four I listed (properties, methods, events, and enumerated) are not returned by iskeyword, but I think we still want them highlighted the same way as keywords. So the only issue is that the comment # from 'iskeyword' on version (R2007a) is not 100% correct.

    I've probably made way too much out of this already. Sorry for the lengthy post!

  3. Log in to comment