Sublime Forum

Syntax file help

#1

Hello,

I’m trying to convert a syntax file (for the Koka programming language) from vscode to Sublime Text. Unfortunately I hit a issue: “error: Error loading syntax file “Packages/User/koka.tmLanguage”: Error in regex: premature end of char-class in regex ([^]\s+)?([a-z][\w-][’?])\s*(?=[:,)])”.

The file works if I remove the offending block that triggers that error, but it would be nicer to understand what the regex tries to do, and why it is an error in Sublime Text, and fix it.

Here is the offending block, including the faulty regex:

  <key>param_identifier</key>
  <dict>
    <key>match</key>
    <string>([^]\s+)?([a-z][\w\-]*[\'\?]*)\s*(?=[:,\)])</string>
    <key>captures</key>
    <dict>
      <key>1</key>
      <dict>
        <key>name</key>
        <string>entity.name.function koka.id.param</string>
      </dict>
      <key>2</key>
      <dict>
        <key>name</key>
        <string>koka.keyword.borrow</string>
      </dict>
    </dict>
  </dict>
0 Likes

#2

You need to scape the ^ in the character class, eg. [\^]

0 Likes

#3

Thank you very much! That got rid of the error message.

0 Likes