[ragel-users] Re: Newbie advice

Adrian Thurston thurs... at cs.queensu.ca
Tue Aug 28 17:43:31 UTC 2007


Hi David,

Instead of using any to match stuff that isn't a marker, use a pattern
that ends in newline, then the scanner will be consuming line-by-line
and marker line will be restricted to matching lines that contain only '--'.

Cheers,
 Adrian

Dave Dribin wrote:
> 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
> 
> 
> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google Groups "ragel-users" group.
> To post to this group, send email to ragel-users at googlegroups.com
> To unsubscribe from this group, send email to ragel-users-unsubscribe at googlegroups.com
> For more options, visit this group at http://groups.google.com/group/ragel-users?hl=en
> -~----------~----~----~----~------~----~------~--~---
> 
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
URL: <http://www.colm.net/pipermail/ragel-users/attachments/20070828/04e5e8ce/attachment-0001.sig>


More information about the ragel-users mailing list