Defining a language grammar via code


Is it possible to create a language grammar using code instead of regexes?

For information this is how CodeMirror works. E.g. check out the clojure mode :

Is there something like this for atom?

In TypeScript too many things are contextual for me to reliably capture them in regex plus typescript comes with an excellent code based tokenizer that I would love to use for `ato.


There was this discussion about dynamically updating a grammar:

And this discussion where someone wanted to use an existing tokenizer:

Dynamic Grammers
Marker decorations that add style classes to the actual text nodes?

For the curious minded. Its not that much work at all : (If you like it … put a star on the repo ;))

Just poorly documented. FWIW its miles faster than the cson file grammar (for obvious reasons).


soo close :