[ragel-users] Action at the Beginning of Starred Expression

Arne Goedeke la... at laramies.com
Fri Aug 22 11:32:19 UTC 2008


I am not sure, if I understand you correctly, but have a look at the
example file. Depending on the placement of the >{} action it is either
executed every time a is found or only on the first a.

best

arne

On Thu, 21 Aug 2008, Manfred_Nowak wrote:
>
>  I still haven't found a way to embed an action into the entry point of
>  a starred expression.
>
>  Given some arbitrary regular expression `e=(ax)*y': how to execute an
>  action, whenever the starred expression `ax' is started over, i.e. the
>  `a' is read?
>
>  -manfred
-------------- next part --------------
#include <string.h>
#include <printf.h>
// vim:syntax=ragel

%%{
    machine test;
    alphtype char;


    main := ('ax' >{ printf("starting over.\n");})* >{ printf("first\n");} ;
}%%

int main() {
    int cs;
    char s[] = "axaxaxaxsad";
    char *p = &s, *pe = p + strlen(s);


    %% write data;

    %% write init;
    %% write exec;


    return 0;
}


More information about the ragel-users mailing list