I work on a simple indentation-based metalanguage called Tree Notation.
I have a function that takes a grammar file and generates a sublime-syntax file. The grammar file is written in a custom language, sort of like an ANTLR.
It works! Well, somewhat. The syntax highlighting is super helpful.
The problem is, all of my languages are indentation-based. I cannot figure out how to correctly handle scope changes as indentation changes.
On each new line there are 3 scenarios: indentation increases by 1+ and a single scope is added, indentation stays the same and scope stays the same, indentation decreases by N and N scopes are popped.
I have tried everything I can think of to implement this–backreferences, scopes, lookaheads, lookbehinds, negative lookaheads, textmate grammars, et cetera–and can’t figure it out. I even went so far as to build my own “sublime-syntax” engine to try and reverse engineer how I might get this to work.
So far every path I attempt hits a dead-end (for example, if I could use backreferences in lookbehinds I had a solution).
Anyone out there who can help me crack this nut?
I put a demo of the problem here: https://github.com/breck7/demo
I have written highlighters for CodeMirror with ease, but trying to get things to work with this declarative sublime-syntax/textmate grammar files has crushed my spirit and made me want to flee society and live in the sea with the dolphins.