[ragel-users] Scanner question
Adrian Thurston
thurs... at cs.queensu.ca
Mon May 14 22:05:46 UTC 2007
Hi,
What you're seeing is an an artifact of the scanner implementation. It
wasn't really designed to work in combination with EOF actions. In the
case of the final 'C' character, the third pattern can be determined to
have matched without any lookahead and so ragel optimizes the state
tables by drawing a transition directly to the start state. The old
final state that has the embedded EOF action is abandoned.
Just use pattern actions instead:
'ABC' => { t = TOK_ABC; };
-Adrian
metatr... at gmail.com wrote:
> Hi everyone. I've been trying out Ragel for a number of things, first
> of which is matching a token from a list of possibilities. Sounds
> perfect for a scanner!
>
> Here's a really simple example:
>
> %%{
>
> machine scanner;
>
> main := |*
> 'A' %/ { t = TOK_A; };
> 'AB' %/ { t = TOK_AB; };
> 'ABC' %/ { t = TOK_ABC; };
> *|;
> }%%
>
> The EOF actions do the matching and return the right value to the next
> part of the parser.
>
> My problem is that if you run this machine definition through
> rlcodegen -V and dotty, there doesn't seem to be any sequence of
> states to match the longest string, ABC. You can follow along the
> state machine and see the transitions (A, EOF) and (A, B, EOF) but for
> ABC, there doesn't seem to be (A, B, C, EOF). This is borne out by
> filling in a simple processing loop processing a static string. It
> will match 'A', 'AB' but not 'ABC'.
>
> I'm hoping this is something silly on my part - any hints are much
> appreciated!
>
>
> MT.
>
>
> --~--~---------~--~----~------------~-------~--~----~
> 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/20070514/5bf7f6ab/attachment-0001.sig>
More information about the ragel-users
mailing list