[ragel-users] Catch-rest machines

Diego E. “Flameeyes” Pettenò flameeyes at gmail.com
Thu May 7 12:04:37 UTC 2009


Hi everybody,

I'm having some little trouble trying to wire up some tokenizing state
machines I wrote for feng ( http://www.lscube.org/ ) from one side
branch to the master one, and I start to wonder if it only worke dout of
luck before.

Basically this is used during RTSP requests parsing (RFC822-compatible),
it's autogenerated (yes, autogenerating ragel code that generates C
code, I know it sounds silly at first), so that it only identifies the
headers that we _actually_ use and skip all the rest.

The autogenerated machine can be reduced to

  Header_Name = (
    'Transport'i % { hdr_code = RTSP_Header_Transport; } |
    'Unsupported'i % { hdr_code = RTSP_Header_Unsupported; } |
    'User-Agent'i % { hdr_code = RTSP_Header_User_Agent; } |
    ( unreserved+ ) % { hdr_code = RTSP_Header_Unknown; }
  );

and then I wire it up in 

  Header = Header_Name :>
      ':' . SP . print+ > hdr_val_start;

  main := ( (Header % save_header) :> CRLF )** :> CRLF . 0;

By the time it calls save_header, though, hdr_code is always
RTSP_Header_Unknown if not for the last User-Agent one.

I'm sincerely at a bit of a loss.. or maybe I tried to bang my head on
this too much for now...

-- 
Diego Elio Pettenò — “Flameeyes”
http://blog.flameeyes.eu/

If you found a .asc file in this mail and know not what it is,
it's a GnuPG digital signature: http://www.gnupg.org/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://www.colm.net/pipermail/ragel-users/attachments/20090507/820fdd17/attachment-0001.sig>


More information about the ragel-users mailing list