Thanks Mark.   

I did make progress on this.  I also discovered that I need to use the optional 
specification of ellipses (i..e, :::) in the top-level macro to avoid clash 
with ellipses in the letrec-syntax part.

For information, the project is an LALR parser generator which has a Scheme 
flavor for specifying grammars.   There is no need to declare tokens: the macro 
uses a fender to differentiate non-terminals (e.g., expr) from terminals (e.g., 
'float, #\+).   The code turns out to be pretty clean and compact, I believe.  
I plan to use the local bindings to provide macros for common patterns (e.g., 
($opt 'const) int =>  opt-1 'int ,  (opt-1 () ('const)). 

Matt

(define spec0
  (lalr2-spec
   (start expr)
   (grammar
    (expr
     (expr #\+ term ($action (+ $1 $3)))
     (expr #\- term ($action (- $1 $3)))
     (term))
    (term
     (term #\* factor ($action (* $1 $3)))
     (term #\/ factor ($action (/ $1 $3)))
     (factor))
    (factor ('integer) ('float))
    )))



Reply via email to