[ragel-users] % Leaving Action Questions

Adrian Thurston thurs... at cs.queensu.ca
Mon Feb 25 22:01:59 UTC 2008

Hi Francois,

The problem is the any* at the beginning of bla. It creates an ambiguity for the bla*. Changing that to bla** will fix that. 

You might want to consider using a scanner to find the interesting things. In the event of only a partial match it can default to another pattern. 

-----Original Message-----
From: "francois.beausoleil" <francois.beausoleil at gmail.com>

Date: Mon, 25 Feb 2008 07:47:18 
To:ragel-users <ragel-users at googlegroups.com>
Subject: [ragel-users] % Leaving Action Questions

Hi all !

I'm writing a state machine that would detect interesting sentences
from withing a commit message.  For instance, given this:

Fix problem with dada.  Fixes #231.  Assign to qa.

There are 2 interesting events here:  "Fixes #231" and "Assign to qa".

At the moment, I'm just concentrating on "Fixes #231".  The machine
works, kind of.  Running my machine prints this:

$ rake ragel:compile && ruby bla.rb "Fix problem with dada.  Fixes
#231.  Assign to qa."
(in /home/francois/src/fogbugz-svnhook)
Fixing 23
Fixing 231
Fixing 231.

My specification is:

      machine commit_message_parser;

      action mark { mark = p }
      action bugid { bugid = data[mark .. p] }

      action close { action = :close }
      action fix { action = :fix }
      action notify { listener.send(action, bugid.pack("C*")) }

      bugid = ("#" ('1'..'9')>mark ('0'..'9')**) % bugid;
      close = ( (/close/i 's'? ':'? space*) %close bugid%notify);
      fix = ( (/fix/i 'es'? ':'? space*) %fix bugid%notify);

      bla = (any* (close | fix));
      main := bla*;

Isn't % supposed to fire only on leaving ?  Why is the bugid machine
leaving at 3 and 1 and '.' ?  Why is '.' even in the bugid machine ?

And then, I still have the problem of parsing "Closes #123, #234 and
#345." !

Thanks for any help !

More information about the ragel-users mailing list