[ragel-users] Problem: Change state only when a new input is received

Adrian Thurston thurs... at cs.queensu.ca
Wed Jul 11 17:42:23 UTC 2007


Hi Aditi,

For this task don't use the "noend" write option. Set the alphabet type
to int and when an integer arrives set p to point it and set pe to (p +
1). Also, make sure you separate out the init code so it is invoked only
once before you start reading input.

I've always wanted to add a "one-at-a-time" option to write which would
eliminate the unnecessary loop over the single character but never got
around to it.

Adrian

Aditi wrote:
> Hi,
> I am new to ragel and was hoping to use it for the following purpose-
> I need to match a regular expression, but the input which is to be
> matched comes as a series of tokens over a socket. I need the state
> machine to advance to the next state as and when it receives the
> token.
> 
> I am trying to do this with ragel but have been unsuccessful so far.
> According to my understanding of ragel, I need to specify the whole
> chunk of string between pointers p and pe and let machine run on it.
> Instead I want p to read one value from socket on advance on it. Can
> somebody please give me pointers on how to do this?
> 
> This is a code snippet of one of my futile attempts :( -->
> <snip>
> 		if ((rval=read(msgsock, buff, 4)) < 0){
> 			perror("reading stream message");
> 			exit(1);
> 		}
> 
> 		p = buff;
> 
> 		%% write init;
> 		%% write exec noend;
> 
> 		while(true) {
> 			if ((rval=read(msgsock, buff, 4)) < 0){
> 				perror("reading stream message");
> 				break;
> 			}
> 			else {
> 				p = buff;
> 				printf("-->%s\n", buff);
> 
> 			}
> 			if(strcmp(buff,"exit")== 0) break;
> 		}
> </snip>
> 
> My token will by of type integer, but as a startup i was trying with
> normal string tokens. It would be really helpful if someone can help
> me out with this.
> Regards,
> Aditi.
> 
> 
> --~--~---------~--~----~------------~-------~--~----~
> 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/20070711/644625aa/attachment-0001.sig>


More information about the ragel-users mailing list