Before anything else, let me state this: Of course it&#39;s going to be PAINFULLY slow on MRI.&nbsp; That&#39;s not the point :)<br><br>I thought I&#39;d try out writing out a Ruby version of the parser for the purposes of Rubinius.&nbsp; For those of you who aren&#39;t aware, Ragel supports a goto-driven FSM on Rubinius by injecting assembly directly, and Rubinus head honcho guy Evan Phoenix is working on a patch for Ragel to update it to the new compiler semantics.&nbsp; So really, there is a purpose for trying this out.<br>
<br>Anyway, here&#39;s my initial hack.&nbsp; It&#39;s nasty, and presently jams the entire FSM into instance-specific data.&nbsp; Aieee!&nbsp; But it more or less seems to generate similar (albeit not identical) output to the C one:<br>
<br><a href="http://git.rubini.us/?p=code;a=blob;f=lib/mongrel/http11_parser.rb.rl;h=508f9bd42b4aad322f357637d52576f780707a2f;hb=868732662abbf4aa571bf2f3d598152467f6f4da">http://git.rubini.us/?p=code;a=blob;f=lib/mongrel/http11_parser.rb.rl;h=508f9bd42b4aad322f357637d52576f780707a2f;hb=868732662abbf4aa571bf2f3d598152467f6f4da</a><br>
<br>I&#39;ve thought about having a Mongrel::HttpParser::FSM module to store
the actual Ragel-generated state machine, and pass all ivars from the
Mongrel::HttpParser to an execute method then recapture them as return
values, or something to that effect.<br>
<br>Thoughts?&nbsp; Suggestions?&nbsp; Complete rewrites?&nbsp; I&#39;d appreciate them all.<br><br>-- <br>Tony Arcieri<br><a href="http://medioh.com">medioh.com</a>