cawright.99
2018-10-6 11:51:04

@cawright.99 has joined the channel


cawright.99
2018-10-6 11:52:45

My application is a state machine with some local variables in each node, and time-outs for arcs as well, Having really enjoyed Shriram Krishnamurthi’s automaton compile-to-closures,

http://cs.brown.edu/~sk/Publications/Papers/Published/sk-automata-macros/

As I’ve implemented the additional stuff (local vars, timeout etc), I’ve started to get pretty complicated macros. I wonder if I would be better off compiling the automaton definition

(fsm init
    [init : (c -> more)]
    [more : (a -> more)
          (d -> more)
          (r -> end)]
    [end : ])

for example, to a class - which I could then add methods to so I could query the variables in a node, check time-remaining-in-node etc… I know all of this can be done with closures (and a dispatch method), but it seems a bit more straightforward to do it with explicit objects/methods.

Second questions - given that (above) type of definition, are macros emitting class defns the way to go, or parser-tools (lex/yacc) a better bet?

Again, thanks for the help…


samth
2018-10-6 12:52:08

If you want to change to using classes with basically the same syntax, then using macros is still the way to go


samth
2018-10-6 12:52:37

Only use parsing and lexing if you need to handle syntax that doesn’t fit with s-expressions


cawright.99
2018-10-7 01:19:34

Thanks @samth. The description of the Automata is s-expressions, so macros it is. Thanks again