[ragel-users] Re: Am I misinterpreting the purpose of fbreak?

Adrian Thurston thurs... at cs.queensu.ca
Sun Jan 6 00:52:01 UTC 2008


Sorry that won't work. When you break from the processing loop you
abandon any remaining actions on that character. Ragel does not jump
back into the action list to the point of departure.

What you could do is queue up actions and then embed the break action using:

${ p++; break; }

Just be sure the break action is embedded after the actions that queue
up tokens. See the section on action ordering in the manual.

-Adrian

David Waite wrote:
> I don't know if advancing p is the correct option all the time though,
> because (in the example, and unfortunately in the actual machine I'm
> trying to create) I trigger multiple breaking actions on a single
> transition. For example, the two character JSON document "[]"
> currently should have the following actions triggered by my machine:
> 
> main:
>   StartDocument - fbreak; (returns Event.Document)
>   ParseArray - fcall array;
>   StartArray - fbreak; (returns Event.Array)
>   EndArray - fbreak; (returns Event.EndArray)
>   Return - fret;
>   EndDocument (eof) - fbreak; (returns Event.EndDocument)
> 
> If I remove the StartDocument fbreak, would incrementing p on break
> work?
> 
> -DW
> 
> On Jan 5, 3:56 pm, Adrian Thurston <thurs... at cs.queensu.ca> wrote:
>> The problem is that fbreak does not advance p when it breaks out of the
>> loop. This is a choice I made a long time ago and I think I was taking
>> the "do as little as possible on behalf of the user" approach. But not
>> advancing p while advancing cs is clearly wrong and confusing. This is
>> something that will change in 6.0 (it's in the TODO already).
>>
>> In the meantime you can do p++ just before the break.
> > 
> 



More information about the ragel-users mailing list