2014-04-10 22:08 GMT+02:00 Iñaki Baz Castillo <i...@aliax.net>: > Hi, > > I'm building a parser for a protocol message similar to HTTP (let's > say: a main header and N key: value separated by CRLF until a final > double CRLF). My concern is: > > - I parse the messages in a "Dispatcher" module that just needs to > parse a few fields in each message. > - Then the Dispatcher passes the message to a Worker thread via UNIX Socket. > - And the Worker must parse it again, but in this case I need all the > fields parsed. > > Note that during the Worker's parsing, a C++ complex object is build > with all the parsed fields mapped into member variables, so I don't > want to play with those complex objects in the Dispatcher module. > > How could I reuse the same Ragel machine for both cases? Of course I > would like something like: > > > > %%{ > machine Parser; > > [...] > > if (dispatcher) { > main := xxxxxxx > } > else { > main := yyyyyyy > } > > }%%
Mmm, I think using the "when" statement is the way to go :) -- Iñaki Baz Castillo <i...@aliax.net> _______________________________________________ ragel-users mailing list ragel-users@complang.org http://www.complang.org/mailman/listinfo/ragel-users