# [plt-scheme] Code generation question from Shriram's Automata via Macros

On 8/2/07, Noel Welsh <noelwelsh at gmail.com> wrote:
>* On 8/2/07, Grant Rettke <grettke at acm.org> wrote:
*>* > Suppose I took that definition and did something like:
*>* >
*>* > (define the-data
*>* > "(automaton init
*>* > (init :
*>* > (c -> more))
*>* > (more :
*>* > (a -> more)
*>* > (d -> more)
*>* > (r -> end))
*>* > (end : )))"
*>* >
*>* > First question, how would I got about evaluating it and binding it to
*>* > a value like in previous example?
*>*
*>* http://schemecookbook.org/Cookbook/StringEval
*
One could use eval here, but may I ask why you've got a string in the
first place?
>* > Second, how could I take the definition of 'the-data' and use that
*>* > language to, for example, create a graphviz file that represented the
*>* > state machine?
*>*
*>* Easy. Just walk the data structure and spit out the right strings. I
*>* do it all the time for POMDPs, which are kinda an extended finite
*>* state machine.
*
Given this particular code, you might try instead to write a different
implementation of the automaton macro that produces the input for dot.
Robby