Problem: Change state only when a new input is received

Aditi ad... at
Wed Jul 11 13:27:09 UTC 2007

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

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 :( -->
		if ((rval=read(msgsock, buff, 4)) < 0){
			perror("reading stream message");

		p = buff;

		%% write init;
		%% write exec noend;

		while(true) {
			if ((rval=read(msgsock, buff, 4)) < 0){
				perror("reading stream message");
			else {
				p = buff;
				printf("-->%s\n", buff);

			if(strcmp(buff,"exit")== 0) break;

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.

More information about the ragel-users mailing list