Ragel quickstartEdit
This article demonstrates the basic work flow for Ragel development.
simple.rl
Start with the simplest code possible, a recognizer for strings of letters (taken from the Ragel user guide):
#include <stdio.h>
%% machine foo;
int main(int argc, char **argv)
{
    %% write data noerror nofinal;
    int cs, res = 0;
    if (argc > 1)
    {
        char *p = argv[1];
        %%{
            main := [a-z]+ 0 @{ res = 1; fbreak; };
            write init;
            write exec noend;
        }%%
    }
    printf("execute = %i\n", res );
    return 0;
}
Run ragel
Now run the ragel on the file:
$ ragel simple.rl
Compile the C code
$ gcc simple.c -o simple
Run
$ gcc simple.c -o simple
A sample session; 0 is printed if no match occurs, 1 is printed on success:
$ ./simple
execute = 0
$ ./simple foo
execute = 1
$ ./simple fo4
execute = 0