Sublime Forum

Line break issues in syntax definition


I’ve this in a Sublime Text syntax file:

    - include: ignoreBlank
    - match: '/=?'
      pop: true
    - match: '\<'
      pop: true
    - match: '(?![<\s\t\n\r/]|/=)'
      pop: true

    - match: '{{Whitespace}}|{{LineTerminator}}'
    - include: comments

The context deambiguatedSubexpressions allows to distinguish divide operator from regular expression in an ActionScript 3.0 dialect. Line breaks are allowed before the slash operator, but actually it seems like Sublime Text pops the context right on the line terminator, which causes the following:

/ b

To wrongly highlight / b as a regular expression.



Anyone, please? There’s no way to find info on this. What I find about Perl regular expressions reveals nothing.



it’s a little hard to comment concretely without a minimal usable example to look at - your example is missing some variable definitions and the main context.
It may be useful to know that the regex patterns you specify are run on a line by line basis, so one pattern will never match a newline char AND something following it, but from the example you’ve given, that doesn’t seem to be the problem…

Generally, if you are matching \n, you may want to set into a context which will pop on ^, otherwise rules like $ could still potentially match after that iirc, which could be why you are seeing the pop where you are not expecting it



I didn’t mention earlier; this is the full highlighter: My code is line-based BTW, I only attempted to match line separators in a single regular expression between assign followed by an object literal. Actually I use $ for single-line comment.

All contexts normally match line break, such as expressions and directives (because it includes expressions). I’ve tried several variations with matching line end!