Newbie advice
Dave Dribin
ddri... at gmail.com
Mon Aug 27 22:04:30 UTC 2007
Hi Adrian,
On Aug 27, 12:37 pm, "Adrian Thurston" <thurs... at cs.queensu.ca> wrote:
> This is where the pure state machine model breaks down and scanners begin to shine because they delay their pattern actions until after the pattern matches (made possible by backtracking).
Okay, even though I don't need a scanner for this particular example,
I decided to try it just to learn more about scanners. I can't quite
figure out how to use it in this case. Here's my first attempt:
marker_line = '--' newline;
main := |*
marker_line => { printf("\n"); };
any => {
printf("%c", isprint(*tokstart)? *tokstart : '.');
};
*|;
This doesn't force marker_line to be at the start of the line, though,
and will match any line that ends in "--". Plus, it won't force the
last section to end in "--\n".
Thanks for your help as I learn this tool.
-Dave
More information about the ragel-users
mailing list