문제

I am trying to get proper syntax highlighting for the Matlab operators >= and <=. Currently, only < and > are highlighted -- not the =. But e.g. == is highlighted.

I've looked in the Matlab.tmLanguage file, and both &gt;=and &lt;= are included in the operator regex.

What could be wrong here?

도움이 되었습니까?

해결책

The issue is with the complete regex, which is found under:

</dict>
<key>operators</key>
<dict>
    <key>comment</key>
    <string>Operator symbols</string>
    <key>match</key>
    <string>\s*(==|~=|&gt;|&gt;=|&lt;|&lt;=|&amp;|&amp;&amp;|:|\||\|\||\+|-|\*|\.\*|/|\./|\\|\.\\|\^|\.\^)\s*</string>
    <key>name</key>
    <string>keyword.operator.symbols.matlab</string>
</dict>

The issue is the order of the or'ed sub-expressions (|&gt;|&gt;=|&lt;|&lt;=). E.g. &gt; is matched before &gt;=, which then isn't matched at all. So the solution is to change the order of the subexpressions, matching the longer first. I.e. change the match string to:

 \s*(==|~=|&gt;=|&gt;|&lt;=|&lt;|&amp;|&amp;&amp;|:|\||\|\||\+|-|\*|\.\*|/|\./|\\|\.\\|\^|\.\^)\s*
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top