On Sep 29, 2006, at 1:52 PM, Eric Hodel wrote:

> On Sep 29, 2006, at 9:56 AM, James Edward Gray II wrote:
>
>> I'm needing to know the full list of characters that can (or  
>> cannot) be used in the following Ruby construct:
>>
>>   %?special Ruby String literal?
>>
>> What are all the legal choices for the ?s above?
>>
>> I did browse parse.y a little, but couldn't find an obvious answer  
>> there.
>
> It looks like the rule is something like:
>
> /%[QqWwxrs]?(.).*\1/
>
> Where QqWwxrs define what type of special literal it is (string,  
> array, exec (`), regex or symbol) and following that is the  
> terminating character which may be any character (but ([<{ must be  
> balanced).

This is interesting.  The operators do differ slightly when you omit  
the letter though (because they are matched by different grammar  
rules, I assume).  For example:

$ ruby -e 'p % test '
-e:1:in `test': wrong number of arguments (ArgumentError)
         from -e:1
$ ruby -e 'p %Q test '
"test"

And of course, %= .. = is out because %= is the Ruby operator for ..  
= .. % ...

> See parse.y around line 4162, "case '%':"

Yes, I see it now.  Thank you for pointing me in the right direction.

James Edward Gray II