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
[email protected]
http://www.complang.org/mailman/listinfo/ragel-users
--===============09807

--
Adrian D. Thurston
http://www.complang.org/thurston/

_______________________________________________
ragel-users mailing list
[email protected]
http://www.complang.org/mailman/listinfo/ragel-users

Reply via email to