Thanks, but could you maybe give me a 10-liner that exemplifies this kind of behavior inside another application? Let's say I have my own event loop set up to feed Ragel buffers. Where do I (or does Ragel) allocate and store it's state? How do I get the pair of functions described above that are parameterized over the state and consume incremental new input? Can I have Ragel pass me a bit of userdata as well, where I can keep the parse state and the thing receiving the events? Keeping it simple, how about a parser that has an in-action that tells a C function got_null(void *userdata, size_t start_addr) whenever it encounters a 0 byte. Prototypes below:
void got_null(void *userdata, size_t start_addr); int parse_null(ragel_state_t *st, void *buf, size_t buf_len, void *userdata); int parse_null_eof(rage_state_t *st, void *userdata); On Sat, Nov 10, 2012 at 6:33 PM, Adrian Thurston <thurs...@complang.org> wrote: > You came to the right place. This is what ragel was designed for. > > -Adrian > ------Original Message------ > From: Karel Sedláček > Sender: ragel-users-boun...@complang.org > To: ragel-users > ReplyTo: ragel-users > Subject: [ragel-users] Incremental parsing with ragel > Sent: Nov 10, 2012 11:02 AM > > Ideally, I'd like to be able to write a parser that fits this sort of > a prototype: > > /* feed data in in blocks and let ragel call the actions to deal with it */ > void parse_x(parser_t *p, void *buf, size_t buf_len); > /* now we need an OOB way to tell ragel about real EOF */ > void parse_x_eof(parser_t *p); > > The need here is that all of the parsing work I am doing deals with > non-blocking I/O, and it is not at all feasible to buffer "all" of the > protocol data and then feed it to ragel. Neither is it acceptible to > do something like the getchar() loop I have seen elsewhere. Is it > possible in Ragel for the parser to encounter a EOB (end of buffer) > state and serialize itself somewhere to be re-entered with more data > later? > > k > > _______________________________________________ > ragel-users mailing list > ragel-users@complang.org > http://www.complang.org/mailman/listinfo/ragel-users > > > _______________________________________________ > ragel-users mailing list > ragel-users@complang.org > http://www.complang.org/mailman/listinfo/ragel-users _______________________________________________ ragel-users mailing list ragel-users@complang.org http://www.complang.org/mailman/listinfo/ragel-users