rlgen-ruby / ruby 1.9 incompatibilities, possible fixes, and offer to patch

dcgrigsby dan-goo... at unpossible.com
Wed Jan 2 19:56:55 UTC 2008


The code generated by rlgen-ruby is incompatible with Ruby 1.9.

Using the simple DevChix Hello World example (http://www.devchix.com/
2007/12/13/a-hello-world-for-ruby-on-ragel/)., the generated "write
exec" ruby contains a handful of errors.

1) the "when" clause in the generated case statements uses a
deprecated form.  It is in the form "when <value>:" and should be
"when <value> then" instead.

2) under 1.9, a string element reference (i.e., [] operator) returns a
string, not a fixnum as under 1.8.  So the comparisons like this...

  if data[p] < _hello_trans_keys[_mid]

...result in "`<': comparison of String with 104 failed
(ArgumentError)" under 1.9.

I'd be happy to work up a patch, hopefully one that works under both
1.8 and 1.9, but I need some guidance.

The former should be easy.  I found all the instances that use the
colon in when and changed them successfully.

The later is where I'm uncertain.  Appending ".to_s" to both sides of
the comparison (needs to be both sides to retain 1.8 compatibility)
everywhere seems wrong.  At this point I'm doing little more than
grepping the source; I don't really comprehend what's going on, so a
point in the right direction would be welcome.


More information about the ragel-users mailing list