[ragel-users] another newbie question!!

Adrian Thurston thurs... at cs.queensu.ca
Thu Sep 13 15:05:20 UTC 2007


Hi,

This state machine is executed with the first argument string as input,
not the contents of the file named by the first argument. Ragel does not
open any files for you in case that's what you thought. You want to be
executing the program with

/ragel$ ./prog 'bar bar bar'

-Adrian

Sarkar wrote:
> 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??!
> 
> Cheers!
> 
> 
> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google Groups "ragel-users" group.
> To post to this group, send email to ragel-users at googlegroups.com
> To unsubscribe from this group, send email to ragel-users-unsubscribe at googlegroups.com
> For more options, visit this group at http://groups.google.com/group/ragel-users?hl=en
> -~----------~----~----~----~------~----~------~--~---
> 
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
URL: <http://www.colm.net/pipermail/ragel-users/attachments/20070913/cb8d15c3/attachment-0001.sig>


More information about the ragel-users mailing list