(#21264) Monkey-patch rgen 0.6.2 to handle implicit array#to_str

The problem was that ruby does implicit Array to String conversion
by testing that a call to #to_str fails. This does not work well
with Rgen's implementation (in version 0.6.2) of Array#method_missing
where the special case of empty array is not handled for #to_str. RGen
recently fixed a similar issue for #to_hash. 

This commit adds a monkey-patch of Rgen's array extension that checks
for #to_str the same way as #to_hash.

This commit also includes a test that checks that the monkey patch
works.

Since RGen is loaded on-demand (not upfront), the monkey_patch must
naturally also be applied dynamically. The main entry point for this in
the normal flow is in the parser-factory.

Later, when RGen becomes a requirement (and if the issue is not fixed in
RGen), the monkey patch can move to use the same mechanism as all other
monkey-patches.