Sublime Forum

Help with syntax definition/coloring

#1

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:

image

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

- match: '\{|\(\*|/\*'
  comment: Block comment
  push:
    - 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!

0 Likes

#2

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

1 Like

#3

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.

0 Likes

#4

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

0 Likes