[ragel-users] Reading from stream instead of buffer

Adrian Thurston thurston at complang.org
Sat Apr 18 17:13:14 UTC 2009


You can execute on one character at a time.

while (true)
{
     int c = getchar();
     if ( c == EOF )
         break;

     char cv = c;
     char *p = &cv;
     char *pe = p + 1;

     %%write exec;
}

-Adrian

Ico wrote:
> Hello List,
> 
> Tody I discoverd Ragel, and I'm trying to create a small parser for
> reading a binary protocol. The databytes are read from a serial port,
> and only the parser will know when packets are complete. This makes it
> hard to read data into a buffer first, since the underlying code does
> not have any protocol knowledge.
> 
> Is there a way to make ragel read bytes from a stream, e.g. instead of
> using the *p and *pe pointers, I'd like to have a function called by
> ragel to receive data from the serial drivere, similar to the ANSI C
> getchar() function.
> 
> Regards,
> 
> Ico
> 




More information about the ragel-users mailing list