pii_ke
pii_ke

Reputation: 2901

Getting a scheme macro keyword to match only if at least two arguments are given to it

I am trying to implement a keyword (named =) for a macro transformer (named latex) which is intended to match only if at least two arguments are given to it. My attempt is:

     ((_ (= a b))
      `(,@(latex a) "=" ,@(latex b)))
     ((_ (= a b ...))
      `(,@(latex a) "=" ,@(latex (= b ...))))

but this implementation matches when only one argument is given to = and gives an undesirable result. A table of outputs for various inputs is given below.

Input to latex Displayed Result comment
= = ok (no match)
(=) (=) ok (no match)
(= a) a=(=) bad match. result should be (= a)
(= a b) a=b ok (match)
(= a b c) a=b=c ok (match)
(= a b c d) a=b=c=d ok (match)

You may view the source file or the project page if you require more context.

Upvotes: 0

Views: 49

Answers (0)

Related Questions