Surpressing Mulitple Matches
Jonathan Stott
jonathan.st... at gmail.com
Sat Apr 5 15:34:25 UTC 2008
Hi all
I'm writing a parser for some irc logs (to convert them to wiki markup and/or html) and the machine is fairly simple.
eol = '\n';
text = any -- eol;
# action line (generated from /me)
action_line = timestamp action_nick text %print_action eol;
# text line, normal irc chat
text_line = timestamp nick text %print_text eol;
# system line. Joins, parts etc. Included so I can ignore it.
# system_leader is a unique bit of text the irc client puts just after the timestamp for all system info.
system_line = timestamp system_leader nick text eol;
# hr line. A convention which has developed.
#A line of just '-'s should be converted to a <hr />
hr_line = timestamp nick '-'{3,} %print_hr eol;
line = action_line | text_line | system_line | hr_line
main := line*
print_action, print_text both print a nicely formatted line, with two newlines, suitable for the wiki. print_hr prints '----', the wiki markup for a <hr />. Except that any hr_line, is also a valid text line, so two lines get printed. And I can't really exclude '-' from a text_line, they do get used in typing. Is there any solution to avoiding printing both lines? (Beyond the obvious one of some test like 'if this is all -s, don't print' in the print_text action)
Regards
Jon
More information about the ragel-users
mailing list