bablr-lang / bablr-vm

A VM for enforcing language rules on agAST trees
MIT License
40 stars 2 forks source link

Language embedding-on #43

Closed conartist6 closed 6 months ago

conartist6 commented 1 year ago

Support languages embedded in other languages, e.g. Regex language embedded inside Javascript.

conartist6 commented 1 year ago

See also: https://github.com/js-cst-tokens/cst-tokens/issues/32

conartist6 commented 1 year ago

There are two distinct scenarios in my mind:

  1. Multiple language definitions transfer control between each other in order to complete parsing
  2. One language definition runs on the output of another

This ticket is about scenario 2.

conartist6 commented 6 months ago

I'm going to close this for the moment because I'm not sure it's really a defect anymore. I believe that everything that will be necessary to support this functionality has been built.

Since we are talking about things like template strings that definitely parse in the underlying language before having another parser run on their content, in general we can't pretend that embedding-on is embedding-in, because it isn't. In other words, we must never pretend that there aren't two layers of meaning going on in something like a template string. If you ask to see only the syntax that JS will recognize, you would not that to include any of the syntax inside the template string.