[ragel-users] Re: Bug or feature?

Adrian Thurston thurs... at cs.queensu.ca
Sat Jul 14 20:47:02 UTC 2007


Carlos,

The leaving action is run because the machine accepts the zero-length
word at the time that it is embedded. That is, the start state is also
final. When you 'pass over' a machine that accepts the zero-length word
you are always passing through the start state which is also final. And
so you are 'leaving' it.

But entering actions are always associated with transitions inside the
machine. This is how you can leave a machine you have never 'entered.'

It's true, the wording of things doesn't perfectly match the semantics,
and they used to match better (see the thread), but to me the current
state of things seems the best way to go. The semantics of the operators
are simple and easy to define.

If you make a habit of factoring out zero-length machines then you can
avoid this problem.

word = char+ >enter %leave;
opt_word = word?;

-Adrian

Carlos Antunes wrote:
> Adrian,
> 
> Ok, read the thread and that message specifically. I still don't get
> why a machine that doesn't get entered gets to be exited. If a
> transition goes around, not through, the machine, why would the exit
> action of that machine be called? After all, that optional machine
> final state may never be transitioned to, right? How come it can be
> transitioned from, then?
> 
> Thanks!
> 
> Carlos
> 
> On 7/14/07, Adrian Thurston <thurs... at cs.queensu.ca> wrote:
>> Hi Carlos,
>>
>> See this thread:
>>
>> http://groups.google.com/group/ragel-users/browse_thread/thread/9509ab83d7f022f1/
>>
>> And in particular this message:
>>
>> http://groups.google.com/group/ragel-users/msg/79546a93494e6773
>>
>> -Adrian
>>
>> Carlos Antunes wrote:
>>> Adrian,
>>>
>>> I have the following construct:
>>>
>>> password = password_char**
>>>                >{ capture_start(capid_password, p); }
>>>                %{ capture_stop(capid_password, p); };
>>>
>>> When I feed a string that doesn't match "password", "capture_stop" is
>>> immediately called but not "capture_start". I would expect that either
>>> both or none are called (I prefer both). What say you?
>>>
>>> Thanks!
>>>
>>> Carlos
>>>
>>
>>
> 
> 

-------------- 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/20070714/32252be3/attachment-0001.sig>


More information about the ragel-users mailing list