title: Extracting tokens out of ES6 template literals with Ragel
body: <p>JavaScript contains the following syntax:</p>
  
  <pre><code>`hello ${name}`
  </code></pre>
  
  <p>I'm wondering how a Ragel machine would split the syntax above. The way I see it, the type of the closing curly brace depends on the parsing state. For example, in the code below the curly brace is instead part of the string token, since the <code>${</code> token isn't there:</p>
  
  <pre><code>`hello name}`
  </code></pre>
  
  <p>Finally, it becomes more tricky when you consider that the right curly can also be found within the variable expression itself, ie:</p>
  
  <pre><code>`hello ${() =&gt; { return name }()}`
  </code></pre>
  
  <p>How would a similar context-dependent grammar be implemented with Ragel?</p>