Problem: Change state only when a new input is received
Aditi
ad... at cse.iitk.ac.in
Wed Jul 11 13:27:09 UTC 2007
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.
More information about the ragel-users
mailing list