guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: a Q on syntax-rules vs syntax-case


From: Matt Wette
Subject: Re: a Q on syntax-rules vs syntax-case
Date: Sun, 08 Feb 2015 18:36:46 -0800

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

[Prev in Thread] Current Thread [Next in Thread]