Here’s some pseudo-code (that is valid in my language):
# random code from my language
script:
javascript ->
alert("Hello, world!");
>/
/
# other random code
If you know html, you can think of the javascript part as this:
<script type="text/javascript"></script>
However, in my language it’s completely valid to escape out of embedded code to form an expression and insert it into that embedded code:
$variable = "Hello, world!"/
script:
javascript ->
alert("<-$variable->");
>/
/
You can think of the way that works as similar to php:
<?php $variable = "Hello, world!"; ?>
<script type="text/html">
alert("<?php echo $variable; ?>");
</script>
The problem is not implementing this, the problem is figuring out how to write something that works for it in my atom language grammar. =P
Currently, the grammar reaches an embedding section and uses the identifier (javascript, coffeescript, etc) to include that grammar. include: "source.js"
But now I have no control over the grammar until the JS grammar finishes successfully, and I’m pretty sure when it reaches my <-$variable->
it’s just going to stop working.
Is there a way I can make an escape back into my grammar temporarily?