Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<h2>TL;DR</h2> <p>Originally, I'd hypothesized:</p> <blockquote> <p><em>Embedded expression</em> seems the most likely definition for this token, based on hints in the source code.</p> </blockquote> <p>This turned out to be true, and has been officially validated by the Ruby 2.x documentation. Based on the updates to the <a href="http://ruby-doc.org/stdlib-2.2.3/libdoc/ripper/rdoc/Ripper.html" rel="nofollow noreferrer">Ripper documentation</a> since this answer was originally written, it seems the parser token is formally defined as <code>string_embexpr</code> and the symbol itself is called an "embedded expression." See the <em>Update for Ruby 2.x</em> section at the bottom of this answer for detailed corroboration.</p> <p>The remainder of the answer is still relevant, especially for older Rubies such as Ruby 1.9.3, and the methodology used to develop the original answer remains interesting. I am therefore updating the answer, but leaving the bulk of the original post as-is for historical purposes, even though the <em>current</em> answer could now be shorter.</p> <h2>Pre-2.x Answer Based on Ruby 1.9.3 Source Code</h2> <h3>Related Answer</h3> <p><a href="https://stackoverflow.com/a/10875052/1301972">This answer</a> calls attention to the Ruby source, which makes numerous references to <em>embexpr</em> throughout the code base. @Phlip suggests that this variable is an abbreviation for "EMBedded EXPRession." This seems like a reasonable interpretation, but neither the ruby-1.9.3-p194 source nor Google (as of this writing) explicitly references the term <em>embedded expression</em> in association with <em>embexpr</em> in any context, Ruby-related or not.</p> <h3>Additional Research</h3> <p>A scan of the Ruby 1.9.3-p194 source code with:</p> <pre><code>ack-grep -cil --type-add=YACC=.y embexpr .rvm/src/ruby-1.9.3-p194 | sort -rnk2 -t: | sed 's!^.*/!!' </code></pre> <p>reveals 9 files and 33 lines with the term <em>embexpr</em>:</p> <pre><code>test_scanner_events.rb:12 test_parser_events.rb:7 eventids2.c:5 eventids1.c:3 eventids2table.c:2 parse.y:1 parse.c:1 ripper.y:1 ripper.c:1 </code></pre> <p>Of particular interest is the inclusion of <strong>string_embexpr</strong> on line 4,176 of the <strong>parse.y</strong> and <strong>ripper.y</strong> bison files. Likewise, <strong>TestRipper::ParserEvents#test_string_embexpr</strong> contains two references to parsing <em>#{}</em> on lines 899 and 902 of <strong>test_parser_events.rb</strong>.</p> <p>The scanner, exercised in <strong>test_scanner_events.rb</strong>, is also noteworthy. This file defines tests in <strong>#test_embexpr_beg</strong> and <strong>#test_embexpr_end</strong> that scan for the token <em>#{expr}</em> inside various string expressions. The tests reference both <em>embexpr</em> and <em>expr</em>, raising the likelihood that "embedded expression" is indeed a sensible name for the thing.</p> <h2>Update for Ruby 2.x</h2> <p>Since this post was originally written, the documentation for the standard library's Ripper class has been updated to formally identify the token. The <a href="http://ruby-doc.org/stdlib-2.2.3/libdoc/ripper/rdoc/Ripper.html#class-Ripper-label-Usage" rel="nofollow noreferrer">usage section</a> provides <code>"Hello, #{world}!"</code> as an example, and says in part:</p> <blockquote> <p>Within our <code>:string_literal</code> you’ll notice two <code>@tstring_content</code>, this is the literal part for <code>Hello,</code> and <code>!</code>. Between the two <code>@tstring_content</code> statements is a <code>:string_embexpr</code>, where <em>embexpr</em> is an embedded expression.</p> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload