I need help building a data structure for a state diagram
matt at tplus1.com
Mon May 25 01:46:31 CEST 2009
On Sun 24 May 2009 03:42:01 PM EDT, Kay Schluehr wrote:
> General answer: you can encode finite state machines as grammars.
> States as non-terminals and transition labels as terminals:
> UNSTARTED: 'start' STARTED
> STARTED: 'ok' FINISHED | 'cancel' ABANDONED
> ABANDONED: 'done'
> FINISHED: 'done'
> In some sense each state-machine is also a little language.
I've never formally studied grammars, but I've worked through trivial
stuff that uses BNF to express ideas like
<postal-address> ::= <name-part> <street-address> <zip-part>
I don't really understand how to apply that notion to this statement:
UNSTARTED: 'start' STARTED
That doesn't seem to be BNF, and that's all I know about grammar stuff.
Can you explain a little more? This idea of using grammars for my
workflow sounds *really* fun and I'd love to learn this stuff, but I
could benefit from some more explanation.
More information about the Python-list