Skip to content

nested syntaxes overhaul

Compare
Choose a tag to compare
@blake-regalia blake-regalia released this 02 Sep 23:54
· 81 commits to master since this release

Summary of changes:

Safe Mode

To mitigate any potential issues down the road, this release ships with a "Safe Mode" syntax variant which has nested syntaxes disabled. For example, if ST were to update a syntax definitions (one that we are currently nesting) to embed text.html.basic (if it wasn't already), this could cause an excess of 25,000 scopes. Although this type of error is now unlikely to happen again, "Safe Mode" is a future-proofing fix for these kinds of scenarios.

Generated Nested Syntax Definitions

Under the nested/ subdirectory, a custom build script does quite a bit of work to ensure that the Ecmascript syntax definition does not push a scope: that ultimately would cause recursion (it actually builds an entire dependency graph to check this). For those syntaxes that would cause recursion (e.g., Graphviz (dot), HTML, Markdown), the dependent syntax source gets cloned and then modified so that it "plays nice".

For example, HTML embeds source.js. We don't want that. So, we clone the HTML syntax and replace source.js with source.js.nested.es. In other words, we create a new HTML syntax that will embed our pre-approved "nested Ecmascript" syntax.

Nested Ecmascript

This "nested Ecmascript" syntax is a variant of the Ecmascript syntax which understands it exists inside of a template literal string.

For example, it knows to recognize escaped characters (such as the backtick, dollar-sign, etc.) as if they were not escaped when expecting template literal strings. This presents an interesting use-case:
nest-es-string

One challenging consequence to this feature is that we want to be able to resume at the correct scope after being interrupted by an interpolated expression. This is still a work in progress, but this release currently supports the following types of interruptions:

nested-es