[ragel-users] Catch-rest machines
Adrian Thurston
thurston at complang.org
Fri May 15 13:42:10 UTC 2009
Hi Diego,
The reason here is that the specific headers are a subset of the default
headers and two actions will be executed. A quick fix is to put the default
header at the top of the union to reverse the order. To see this, use -V and
graphviz. It should make things clear.
To avoid the double action execution you can either exclude the known headers
from the catch all with the - operator, or you can use priorities.
Adrian
On Thu, May 07, 2009 at 02:04:37PM +0200, Diego E. “Flameeyes” Pettenò wrote:
> 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/
>
> _______________________________________________
> ragel-users mailing list
> ragel-users at complang.org
> http://www.complang.org/mailman/listinfo/ragel-users
More information about the ragel-users
mailing list