mathworks / MATLAB-Language-grammar

This repository contains a regular expression based language grammar for MATLAB to be used by GitHub Linguist for highlighting MATLAB code on GitHub
50 stars 17 forks source link

Syntax Highlighting - While loop EOL comment highlighting situationally incorrect. #78

Closed psmskelton closed 4 months ago

psmskelton commented 7 months ago

Describe the bug Syntax highlighting has a few quirky bugs. One I've come across in dealing with other people's code (shudder) is EOL comments on while loops. These only appear to be highlighted if they are preceded by a semicolon, which isn't great.

To Reproduce Try something bad, like putting EOL comments on while loops. That being said, GitHub's Linguist model is completely broken for comments in MATLAB code, as this demonstrates, so look at the VSCode screenshot below.

    while test % test
        % test
    end

    while (test) % test
        % test
    end

    while test; % test
        % test
    end

    for i = 1:10 % test
        % test
    end

    if i == 10 % test
        % test
    end

Expected behavior Consistent highlighting of EOL comments.

Screenshots Screenshot 2024-03-07 095739

Useful Information

dklilley commented 7 months ago

Thanks for reporting this! Moving the issue over to MATLAB-Language-grammar

psmskelton commented 7 months ago

@dklilley - Apologies for incorrect repo.

There's a discussion on the Linguist repo about issues with other languages, and I added a comment there regarding GitHub's incorrect parsing of MATLAB comments (https://github.com/github-linguist/linguist/issues/6668#issuecomment-1982121637). Is that a Linguist issue, or an issue provided by this grammar engine?