The culmination of many features has finally arrived: syntax highlighting grammars based on metadata!
This is a screenshot of my prototype language workbench for meta#. In the grammar section you write rules that get combined together into an implicit grammar which is used to parse each of the code blocks below. On the right is the AST of whatever block you have currently selected. This is a basic “hello world” grammar.
Notice the syntax highlighting! Keywords are yellow, identifiers are gray, character and string literals are green and everything else is white.
The thing that’s cool about this is that the editor for each of those blocks actually does not know anything about the grammar of the code it is highlighting. The highlighting information is coming from the metadata of the grammar itself. In fact you can add that same metadata to the grammar you are authoring in order to get highlighting in the code blocks as well.
Here you can see that I have added the [Keyword] attribute onto the ident rule, this attribute is aggregated as metadata and can be harvested by the code editor. It uses that metadata to get information about the original code and add appropriate colors. The code editor is a custom control I am working on that inherits from RichTextEditor in wpf.
This language workbench is still just a prototype but it’s still kind of cool. I have some ideas on how to evolve it that I need to solidify still but it provides a nice playground for me to experiment with features like this.
You must log in to post a comment.