Tapatalk

Block comment starts with line comment - solution for MATLAB?

Block comment starts with line comment - solution for MATLAB?

1
NewbieNewbie
1

    Feb 12, 2015#1

    I'm having difficulty making the block comment and the line comment for MATLAB work at the same time. Here are the first few lines of my wordfile:

    Code: Select all

    /L16"MatLab File" MATLAB_LANG case 
    /Block Comment On Alt = %{ Block Comment Off Alt = %}
    /Line Comment = % Line Comment Alt = ... 
    It seems like the problem is that the block comment starts with a line comment, and the highlighting interprets the line comment first, ignoring the block comment.

    How do I get around this?

    Thanks,
    Todd

    6,685587
    Grand MasterGrand Master
    6,685587

      Feb 13, 2015#2

      There is a matlab5.uew and a matlab6.uew on Downloads - Extras - Wordfiles and in wordfiles Git repository.

      First line of matlab5.uew is okay. First line of matlab6.uew is

      Code: Select all

      /L6"Matlab" Nocase MATLAB_LANG Line Comment = % Block Comment On = %{ Block Comment Off = %} String Chars = ' DisableMLS File Extensions = m asv
      which of course results also in first line of a block comment being highlighted as line comment because UltraEdit does not look on next characters once beginning of a line or block comment was identified. (Browser perhaps display the single line as two lines.)

      A possible solution is to use for matlab6.uew as first line

      Code: Select all

      /L6"Matlab" MATLAB_LANG Nocase Line Comment Num = 2%  Block Comment On = %{ Block Comment Off = %} String Chars = ' DisableMLS File Extensions = m asv
      So instead of Line Comment = % there is now Line Comment Num = 2% and two spaces after percent sign instead of just one space.

      With this definition it is possible to get block and line comment highlighting working for MATLAB files in UltraEdit as long as there is always a space after % being beginning of a line comment which I would strongly recommend for MATLAB files as first character of line and block comment are identical. A space between line/block comment starting string and comment text is in general always good as making the comment easier to read. Exceptions are special comments like for PC-Lint/FlexeLint, PolySpace, Doxygen, ...

      There is no other solution than using Line Comment Num = 2% .

      BTW: case is not a keyword, remove it. There is either keyword Nocase for being case-insensitive or the language is case-sensitive. And block comment and line comment definitions should be on first line. What you used works although defined wrong, but you better should follow the guidelines for syntax highlighting wordfiles as documented in help of UltraEdit on page Syntax Highlighting and in sticky topic template for syntax highlighting language wordfile.
      Best regards from an UC/UE/UES for Windows user from Austria