[ragel-users] Re: selecting a starting state or how to serialize a machine

Adrian Thurston thurs... at cs.queensu.ca
Fri Mar 2 21:44:28 UTC 2007


For a really long time now I've been meaning to implement a new feature
which should help you out.

%% write entry <machine_or_label>;

With this ragel should generate:

static const int entry_name = X;

Where X is a state number representing the entry point given. Then before
running the state machine on an input character you can go:

cs = entry_name;

This will work just like fgoto <machine_or_label>; except cs is modified
before entering the processing loop.

-Adrian

skk wrote:
> What I have done with a text editor in a windows control is build the
> initial state machine so things transition through the basic states as
> required.  I validate this machine first.  Then I build in transitions
> from the start state into the internal states with the input that
> represents the current state.  In the text editor, build the machine
> to handle the cursor movement, character insert, delete, insert/
> overwright, skip mask characters and so on.  When entering the machine
> I then create a transition from the initial state into the internal
> states after computing the current state of the cursor.  The current
> state of the cursor can be far left/right, insert/overwright, valid
> character to the left/right/both, etc.  This is encoded into an
> integer (all input is in integers, not characters) and is fed in as
> the first character thus putting me exactly where I want to be for the
> next keyboard input character (integer).  This is necessary because
> the user may have moved the text cursor with the mouse and the last
> state I was in is not valid any more.
> 
> On Feb 23, 9:08 pm, "Jason" <jason2... at jasonjobe.com> wrote:
>> I am finding more uses for ragel all the time :-)
>> Now I am experimenting with using a ragel to model work flow logic.
>> For example, a document has an associated state, approved, rejected,
>> pending, etc. So I want to load the document and "post" events that
>> will drive the document status to new states, triggering actions
>> along
>> the way.
>>
>> So the question is: How do I tell a ragel machine I want to start at
>> a
>> particular point (where it left off before)?
>>
>> Do I just archive the entire machine variables (fixing up pointers of
>> course)?
>>
>> thanks,
>> Jason
> 
> 
> 



More information about the ragel-users mailing list