Issue #669 resolved

No highlighting of CoffeeScript "heregexes"

Johannes Heckel
created an issue

This for example will not be highlighted properly:

{{{

OPERATOR = /// ^ ( ?: [-=]> # function | [-+*/%<>&|^!?=]= # compound assign / compare | >>>=? # zero-fill right shift | ([-+:])\1 # doubles | ([&|<>])\2=? # logic / shift | \?. # soak access | .{2,3} # range or splat ) /// }}}

Comments (2)

  1. bigeasy

    I've patched the CoffeeScript lexer to highlight here-regexen. The regex is highlighted with regex coloring, but inline comments are highlighted with comment coloring. I find it quite handsome.

    In addition, I fixed a lone @, which is a common idiom, that is not highlighted as name.

    method.apply @, [ 1, 2, 3 ]
    

    Also fixed is syntax highlighting of division which is currently misinterpreted as a "badregex".

    You'll notice that I commented out the "badregex" state. I can see it in the JavaScript lexer, so I assume that someone based the CoffeeScript lexer off of the JavaScript lexer. I couldn't figure out how the JavaScript lexer managed to skip out of that state and find its way back to the "root" state and then match the regular expression that matches "Operator". Removing "badregex" fixes division. I'm going to assume that the JavaScript and CoffeeScript have diverged to the point where "badregex" is not going to be made to work. I've highlighted a fair bit of regex heavy code with this patch, and it always correctly identified regular expressions.

  2. Log in to comment