[previous] [up] [next]


7.1.4 Quasiquotations

The following grammar for quasiquote expressions is not context-free. It is presented as a recipe for generating an infinite number of production rules. Imagine a copy of the following rules for D = 1, 2, 3, .... D keeps track of the nesting depth.

<quasiquotation> ---> <quasiquotation 1>

<qq template 0> ---> <expression>

<quasiquotation D> ---> `<qq template D> | (quasiquote <qq template D>)

<qq template D> ---> <simple datum> | <list qq template D>
                   | <vector qq template D> | <unquotation D>

<list qq template D> ---> (<qq template or splice D>*)
                        | (<qq template or splice D>+ . <qq template D>)
                        | '<qq template D> | <quasiquotation D+1>

<vector qq template D> ---> #(<qq template or splice D>*)

<unquotation D> ---> ,<qq template D-1> | (unquote <qq template D-1>)

<qq template or splice D> ---> <qq template D> | <splicing unquotation D>

<splicing unquotation D> ---> ,@<qq template D-1>
                            | (unquote-splicing <qq template D-1>)

In <quasiquotation>s, a <list qq template D> can sometimes be confused with either an <unquotation D> or a <splicing unquotation D>. The interpretation as an <unquotation> or <splicing unquotation D> takes precedence.