2011/8/11 Racket Noob <racketn...@hotmail.com>: > Hi all! > > I want to create macro for creating a DFA automaton (similar to > one described > here: http://www.cs.brown.edu/~sk/Publications/Papers/Published/sk-automata-macros/paper.pdf ) > > My desire is that, for example, this form > > (automaton init > (init : (c -> more)) > (more : (a -> more) > (d -> more) > (r -> END))) > > expands to: > > (letrec ([curr-state empty] > [init > (lambda (symbol) > (case symbol > [(c) (set! curr-state more) 'ok] > [else 'transition-error]))] > [more > (lambda (symbol) > (case symbol > [(a) (set! curr-state more) 'ok] > [(d) (set! curr-state more) 'ok] > [(r) (set! curr-state END) 'endstate] > [else 'transition-error]))] > [END > (lambda (symbol) > 'reading-past-end-error)]) > (set! curr-state init) > (lambda (c) > (curr-state c)))) > > > I've created the following two macros, but unfortunatelly they are wrong: > > (define-syntax process-state > (syntax-rules (: -> END) > [(_ (label -> END)) > [(label) (set! curr-state END) 'endstate]] > [(_ (label -> new-state)) > [(label) (set! curr-state new-state) 'ok]])) > > > (define-syntax automaton > (syntax-rules (: -> END) > [(_ init-state > (state : transition ...) > ...) > (letrec ([curr-state empty] > [state > (lambda (symbol) > (case symbol > [(process-state transition)]
The line above here should be a case clause, but it only has one part. I think you meant [process-state transition] Jay > ... > [else 'transition-error]))] > ... > [END > (lambda (symbol) > 'reading-past-end-error)]) > (set! curr-state init-state) > (lambda (c) > (curr-state c)))])) > > Reported error is: case: bad syntax (missing expression after datum > sequence) in: ((process-state (c -> more))) > It seems to me that macro process-state is not expanding at all. > > Can somebody tell me what's wrong and how to fix it??? > > Thanks in advance, > Racket Noob > > _________________________________________________ > For list-related administrative tasks: > http://lists.racket-lang.org/listinfo/users > -- Jay McCarthy <j...@cs.byu.edu> Assistant Professor / Brigham Young University http://faculty.cs.byu.edu/~jay "The glory of God is Intelligence" - D&C 93 _________________________________________________ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/users