<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'><div dir='ltr'>
Hi all!<BR>
 <BR>
I want to create macro for creating a DFA automaton (similar to one described here: <A href="http://www.cs.brown.edu/~sk/Publications/Papers/Published/sk-automata-macros/paper.pdf">http://www.cs.brown.edu/~sk/Publications/Papers/Published/sk-automata-macros/paper.pdf</A> )<BR>
 <BR>
My desire is that, for example, this form<BR>
 <BR>
(automaton init<BR>   (init : (c -> more))<BR>   (more : (a -> more)<BR>           (d -> more)<BR>           (r -> END)))<BR>
 <BR>
expands to:<BR>
 <BR>
(letrec ([curr-state empty]<BR>           [init<BR>            (lambda (symbol)<BR>              (case symbol<BR>                [(c) (set! curr-state more) 'ok]<BR>                [else 'transition-error]))]<BR>           [more<BR>            (lambda (symbol)<BR>              (case symbol<BR>                [(a) (set! curr-state more) 'ok]<BR>                [(d) (set! curr-state more) 'ok]<BR>                [(r) (set! curr-state END) 'endstate]<BR>                [else 'transition-error]))]<BR>           [END<BR>            (lambda (symbol)<BR>              'reading-past-end-error)])<BR>    (set! curr-state init)<BR>    (lambda (c)<BR>      (curr-state c))))<BR>
 <BR>
 <BR>
I've created the following two macros, but unfortunatelly they are wrong:<BR>
 <BR>
(define-syntax process-state<BR>  (syntax-rules (: -> END)<BR>    [(_ (label -> END))<BR>     [(label) (set! curr-state END) 'endstate]]<BR>    [(_ (label -> new-state))<BR>     [(label) (set! curr-state new-state) 'ok]]))<BR>
 <BR>
 <BR>
(define-syntax automaton<BR>  (syntax-rules (: -> END)<BR>    [(_ init-state<BR>        (state : transition ...)<BR>        ...)<BR>     (letrec ([curr-state empty]<BR>              [state<BR>               (lambda (symbol)<BR>                 (case symbol<BR>                   [(process-state transition)]<BR>                   ...<BR>                   [else 'transition-error]))]<BR>              ...<BR>              [END<BR>               (lambda (symbol)<BR>                 'reading-past-end-error)])<BR>       (set! curr-state init-state)<BR>       (lambda (c)<BR>         (curr-state c)))]))<BR>
 <BR>
Reported error is: case: bad syntax (missing expression after datum sequence) in: ((process-state (c -> more)))<BR>
It seems to me that macro process-state is not expanding at all.<BR>
 <BR>
Can somebody tell me what's wrong and how to fix it???<BR>
 <BR>
Thanks in advance,<BR>
Racket Noob<BR>                                               </div></body>
</html>