SwiftStudies/OysterKit

Using OysterKit for syntax highlight

Closed this issue · 1 comments

I'm pretty new to this language creation thing using tools like STLR. I was wondering if OysterKit and STLR would be of any help in creating a simple editor with rudimentary syntax highlight (by recognizing language node types and providing location information in source string).

Yes, in fact I started creating it in order to do just that.

You can actually get away with a whole lot less than a full grammar to do syntax highlighting, and it can be a lot faster than actually "building" the IR.

OysterKit supports that with the TokenStreamIterable. You can see that in use in the example playground (OysterKit Tutorial.playground).

If you were go off and read the excellent Noodlesoft articles on syntax highlighting and use a TokenStream to get the tokens you can do pretty much anything you like and STLR is much better than regular expressions for achieving the highlighting (your example from yesterday wouldn't have been possible... regex just doesn't support nesting).