[ragel-users] Conditional parsing, is it possible?

Iñaki Baz Castillo ibc at aliax.net
Thu Dec 30 01:26:48 UTC 2010


2010/12/30 Iñaki Baz Castillo <ibc at aliax.net>:
> Hi, I wonder if there is a way to parse (or not) some fragments of the
> stream depending on previous parsed elements.
>
> For example, in HTTP, imagine I just want to parse a custom header
> "X-MyHeader" (which has a specific value format)  in case the request
> method is POST. But in case it's a GET then I just want to store the
> header raw value.

This is, there would be two valid syntax for "X-MyHeader":


  generic_value = any* -CRLF;
  x_value = [0-9] ":" [a-z]+;
  x_myheader_value = generic_value | x_value;

If a previous field of the stream (the request method) is POST (an
action could set a variable) I want 'x_myheader_value' just to be
checked with 'x_value', and if the method is other, then
'x_myheader_value' should be just checked with 'generic_value'.

Thanks for any suggestion or clarification.


-- 
Iñaki Baz Castillo
<ibc at aliax.net>

_______________________________________________
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