Scanner question

metatr... at metatr... at
Mon May 14 13:06:37 UTC 2007

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


More information about the ragel-users mailing list