Tuesday, December 7, 2010

State machines

Yeah, so I'm going to add explicit state machines support to the language. It looks like this:

state-machine
  start {
    # Figure stuff out.
    => a1
    => b1
  }
  a1 {
    # Other stuff.
    => return
    ...

You can parameterize a state machine:

state-machine (input)
  ...

Put like this, a state machine is itself an action (e.g. a "do" that runs on ->go()). You can also simply declare a state machine and instantiate it on input elsewhere, in which case the instance will be a ....

[we interrupt this post to point out that FSA::Rules really does.]

... function that you can call repeatedly. And thanks to FSA::Rules, all the hard work is done; I can just wrap it. The only question remaining being whether state machines belong in the core or not. Actually, I think not. Which means I have to figure out how to chain semantic domains (but I had to figure that out eventually anyway).

No comments:

Post a Comment