1. Debugging
Debugging is mainly handled via the syntax_test files. The tests are executed via build system. The output shows which scopes are not correctly assigned - just like a unittest
Example of an syntax_test_java.java
// SYNTAX TEST "Packages/Java/Java.sublime-syntax"
package apple;
// <- meta.namespace.package.java storage.type.namespace.package.java keyword.declaration.namespace.package.java
//^^^^^ meta.namespace.package.java - meta.path
// ^^^^^^ meta.namespace.package.identifier.java - meta.path
//^^^^^ keyword.declaration.namespace.package.java
// ^^^^^ entity.name.namespace.package.java
// ^ punctuation.terminator.java
2. Tranforming BNF to sublime-syntax
While BNF is declarative, sublime-syntax is imperative. The Scala.sublime-syntax seems to closely follow its BNF scheme from the specs. Not sure if we can describe a general way for simply transform a BNF to sublime-syntax though.
You may want to put the simplest entities into variables
to be able to re-use them. More complex variables may be worth a dedicated context, which can be included wherever needed. … a bit tricky to decribe without an example.
Maybe reading the scala specs and comparing with the sublime-syntax can give a first impression.
Basically it’s like writing normal programms. Each context is a function, which matches a couple of related things. Each context can contain of matches
or include
other contexts. Each match
can eigther simply scope a token or push/set
a new context onto the stack, with another set of match rules. E.g. matching a {
pushes into a dedicated stack with its own rules and }
popping off again returning to the original ones. …