[ragel-users] Actions with arguments?
Adrian Thurston
thurston at complang.org
Wed Jun 8 14:59:13 UTC 2011
To add a remark, actions with arguments have been desired for quite some
time, though development is not high on the priority list, considering
the possibility for compilers to inline function calls.
-Adrian
On 06/08/11 16:27, Пётр wrote:
> Hello
> // buff is a char[MAX_EXPR_SIZE], space_left is an int.
> > number {
> > strncpy(buff + (MAX_EXPR_SIZE - space_left), ts, te-ts);
> > space_left -= te-ts+1;
> > buff[te-ts] = '\0';
> > parse(NUMBER, buff);
> >};
>
> > I use almost that same exact set of code except for the last line
> > (which might be "parse(STRING, buff);" or whatever).
> Just use functions.
> instead of
> > action number {
> > ...
> > parse(NUMBER, buff);
> > }
> and [0-9]+ %number
> write this
> void CallParser(int type) {
> ...
> parse(type, buff);
> }
> and invoke it like
> [0-9]+ %{ CallParser(NUMBER); }
> " (any :>> '"') %{ CallParser(STRING); }
> --
> Peter A. Kerzum
>
>
>
> _______________________________________________
> ragel-users mailing list
> ragel-users at complang.org
> http://www.complang.org/mailman/listinfo/ragel-users
> --===============09807
--
Adrian D. Thurston
http://www.complang.org/thurston/
_______________________________________________
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