Newbie advice
ddri... at gmail.com
ddri... at gmail.com
Mon Aug 27 14:25:07 UTC 2007
Hello,
I'm trying to use Ragel to split apart a structured text file. As a
simplified example, I want to split apart sections of a file separated
by "--" on its own line, e.g.:
foo--
bar
--
bing
--
--
baz
--
This sample has four sections (the third one is empty). I've got a
simple machine like this that seems to work:
section = (any* $onChar '\n')? :>> "--\n" @onSection;
main := section*;
The idea is that I buffer up section data in the onChar action, and
then I can process it in onSection. While this machine does seem to
work, onChar is being called for the trailing "--". I understand why
this is being done, but I'm looking for advice to work around it.
Should I just delete the trailing "--" in onSection? Or is there a
better way?
Thanks,
-Dave
More information about the ragel-users
mailing list