% Leaving Action Questions

francois.beausoleil francois.beausol... at gmail.com
Mon Feb 25 15:47:18 UTC 2008


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 !
François



More information about the ragel-users mailing list