another newbie question!!

Sarkar sanju.mathew.... at
Thu Sep 13 02:27:16 UTC 2007

i went thru the earlier post on tryin to run c++ programs using
ragel..i tried it..

/ragel$ ragel -C prog.rl -o prog.rlo
/ragel$ rlgen prog.rlo -l -o prog.cpp
/ragel$ g++ prog.cpp -o prog
/ragel$ ./prog input.txt

the program i ran was

#include <string.h>
#include <stdio.h>

    machine foo;
    main := ('foo'|'bar') @{res = 1; };

%% write data;

int main( int argc, char **argv )
	int cs, res = 0;
	if ( argc > 0 ) {
		char *p = argv[1];
		char *pe = p + strlen(p) + 1;
		%% write init;
		%% write exec;
printf("result = %i\n", res );
return 0;

the input text file is gave was 'bar bar bar'

i expect the output should have been 'result = 1'
but the output always came out as 'result = 0'
when i initialised res=1 the output came out as 'result = 1'

could someone please help me understand what the program is all about
and whether the output i got is valid and why??!


More information about the ragel-users mailing list