[ragel-users] Passing data to actions

Adrian Thurston thurston at colm.net
Thu Apr 19 00:29:30 UTC 2018


Hi Ico,

Nice to hear :)

It's actually already implemented in ragel 7. See tests/args*.rl.

Hopefully this year I'll start iterating some ragel 7 stable releases. 
I'm almost done the researchy kind of things and soon I can start 
addressing issues of a practical matter.

Cheers,
  Adrian

On 2018-04-18 18:12, Ico wrote:
> Hello,
> 
> First let me thank you for writing Ragel - my #1 tool for implementing
> protocol parsers.
> 
> When writing machines I often find myself repeating a lot of similar
> code, for example like this when parsing the RTSP protocol:
> 
>   action method_describe { rtsp.method = RTSP_DESCRIBE; }
>   action method_options  { rtsp.method = RTSP_OPTIONS; }
>   action method_play     { rtsp.method = RTSP_PLAY; }
>   action method_setup    { rtsp.method = RTSP_SETUP; }
> 
>   method = ('DESCRIBE' %method_describe) |
>            ('OPTIONS' %method_options) |
>            ('PLAY' %method_play) |
>            ('SETUP' %method_setup);
> 
> Would it be possible to pass information from the machine definition
> expressions into a action blocks do get a cpp/macro-like behaviour:
> 
>   action method(x) { rtsp.method = x; }
> 
>   method = ('DESCRIBE' %method(RTSP_DESCRIBE)) |
>            ('OPTIONS' %method(RTSP_OPTIONS)) |
>            ('PLAY' %method(RTSP_PLAY)) |
>            ('SETUP' %method(RTSP_SETUP))
> 
> Would something like this be feasible?
> 
> Thanks,
> 
> Ico
> 
> --
> :wq
> ^X^Cy^K^X^C^C^C^C
> 
> _______________________________________________
> ragel-users mailing list
> ragel-users at colm.net
> http://www.colm.net/cgi-bin/mailman/listinfo/ragel-users



More information about the ragel-users mailing list