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

Reply via email to