Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: Are state machines just for parsing?

by samtregar (Abbot)
on Dec 08, 2004 at 22:15 UTC ( #413350=note: print w/ replies, xml ) Need Help??


in reply to Re: Are state machines just for parsing?
in thread Are state machines just for parsing?

What kind of interface / API would you be interested in seeing?

I see two phases. First, I need an API to lay out the network. For my purposes each state has to have:

  • A unique name
  • A description
  • A list of possible next states
  • Code which runs when the state is reached
  • Code to determine if this state should be the next one

I don't know what this API should look like. Maybe each state is a Perl module implementing a few methods. Maybe it's just a big data structure made of hashes and arrays. Whatever it is it has to be easy to change later when the businessmen change their minds.

Next I need to give the machine a starting state and an event. The machine should either tell me what the next state is or produce an error if the event doesn't trigger a valid next state. Something like:

$next_state = $machine->run($state, $event);

-sam


Comment on Re^2: Are state machines just for parsing?
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://413350]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (9)
As of 2015-07-30 17:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (273 votes), past polls