Sublime Forum

Help with syntax definition/coloring


Hello everyone!

I am one of contributors for KSP (Kontakt Script Processor) package for ST. I am trying for quite some time to fix one bug in syntax coloring. To explain in a bit more detail: in this extension we support multiple block comment types: { } /* */ (* *). These can be nested, and the compiler understands this just fine. However, I cannot figure out how to make the syntax coloring work with this nesting properly. Here’s what we have right now:


The sublime-syntax file is defined like this for block comments:

- match: '\{|\(\*|/\*'
  comment: Block comment
    - meta_scope: comment.block.source.ksp
    - match: '\}|\*\)|\*/'
      pop: true

I’m really stuck here, I’ve tried going through the docs a few times but it’s just not happening. Any tips and help are much appreciated. Thanks!



Just separate them into 3 cases. { never matches a *) or a */, doesn’t it?

1 Like


That is correct, only same type brackets should match. Wow, if it’s really that simple, I’m gonna double facepalm like that Picard meme.



…that was exactly it! Wow, so simple, I can’t believe it. Thank you!