[ragel-users] Re: % Leaving Action Questions
Adrian Thurston
thurs... at cs.queensu.ca
Tue Mar 18 19:29:14 UTC 2008
Hi Francois, did you ever get this issue resolved? I can't see the
problem just by looking at the grammar.
-Adrian
francois.beausoleil wrote:
> Hello Adrian,
>
> On 25 fév, 17:01, "Adrian Thurston" <thurs... at cs.queensu.ca> wrote:
>> The problem is the any* at the beginning of bla. It creates an ambiguity for the bla*. Changing that to bla** will fix that.
>
> Thanks for that. I did finally manage to implement something that
> works for the vast majority of cases. I can identify "closes #123,
> fixes #321" and other patterns. My problem is now "assigned to
> francois". Here's my latest machine:
>
> %%{
> machine commit_message_parser;
>
> action mark { mark = p }
> action bugid { bugid = data[mark .. p] }
> action name { name = data[mark .. p] }
>
> action close { action = :close }
> action fix { action = :fix }
> action reference { action = :reference }
> action reopen { action = :reopen }
> action reactivate { action = :reactivate }
> action implement { action = :implement }
> action assign { action = :assign }
> action notify { listener.send(action, bugid.pack("C*")) }
> action notify_assign { listener.send(action, name.pack("C*")) }
>
> bugid = ("#" ('1'..'9')>mark ('0'..'9')**)@bugid %notify;
> bugid_separator = (space* (punct | /and/i) space*);
> bugids = (bugid (bugid_separator bugid)*);
>
> close = (/close/i /s/i? /:/?) %close;
> fix = (/fix/i /es/i? /:/?) %fix;
> reference = (/reference/i /s/i? /:/?) %reference;
> reopen = (/re/i? /open/i /s/i? /:/?) %reopen;
> reactivate = (/re/i? /activate/i /s/i? /:/?) %reactivate;
> implement = (/implement/i? /s/i? /:/?) %implement;
> assign = (/re/i? /assign/i /ed/i? (space+ /to/i)?) %assign;
> name = (alpha)+ >mark %name;
> assignto = (assign space+ name) %notify_assign;
>
> keywords = (close | fix | reference | reopen | reactivate |
> assignto);
> text = (any - (keywords | bugids));
> main := (text* (keywords space* bugids)*);
> }%%
>
> With this machine, Ragel doesn't recognize "The parser assign
> francois." (meaning my notify_action isn't called). But it does
> recognize "The parser assign to francois.", but says the name is "to
> ".
>
>> 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.
>
> Regarding scanners, I looked at chapter 6 of the guide, but couldn't
> find an immediate application. I don't really know where/how to start
> to write my scanner.
>
> Thanks for any other help !
> François
>
> >
>
More information about the ragel-users
mailing list