[ragel-users] Actions with arguments?

Kevin T. Ryan kevin.t.ryan at gmail.com
Sun Jun 5 19:02:09 UTC 2011


Hi Ragel List -

I'm fairly new to Ragel, so I apologize if this is covered in the
documentation or elsewhere.  I'm trying to create a lexer and as part
of the process, anytime I run across a certain pattern, I fill a
buffer and call the parser.  Eg:

// 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).  Thus, I'm
wondering if there is a way to either 1) call actions with arguments
(e.g., action fill_buff (arg) { strncpy ... parse(arg, buff); }) or
call to actions within a parser (e.g., number fill_buff_action, {
parse(NUMBER ... })?  Or is there some other way I should be doing
this (e.g., I thought maybe fcall might be the clue, but then I have
to keep a stack, etc. which I'd rather not do).

Thanks!

ktr

_______________________________________________
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