scala/scala — pull request #2691 by densh (2013-06-27 21:55:32+00:00)
Title: Add quasiquotes to reflection api

The implementation consits of following parts:

- Additions to reflection api:

- Quasiquotes implicit class that defines `q`, `tq`, `pq` and `cq` interpolators that now become a part of the `scala.reflect.api.Universe`. The implementation of given interpolators is macro-based and is hardwired to actual macro through `FastTrack`.

- `Liftable` class and `StandardLiftables` slice of the cake which are parts of typeclass-like mechanism that allows to splice custom user-defined types into quasiquotes

- Additional methods in `BuildUtils` which are used by quasiquotes macro to generate trees, notably:

- `SyntacticClassDef`. An extractor/constructor that allows to construct and deconstruct classes using arguments that mirror syntactic form of ClassDefs (e.g. constructor outside of the body)

- `TupleN`, `TupleTypeN`. Extractor/constructor for easy construction of ast that represents a tuple term or type with given amount of elements.

- Actual implementation of quasiquotes in `scala.tools.reflect.quasiquotes.package` which is organized into a cake called `Quasiquotes` with slices:

- `Macros`. Core macro expansion logic with `dispatch` entry-point.

- `Parsers`. Customized parser that contains modifications to support various types of extensions to the Scala language that are needed for quasiquotes. Due to the fact that code snippets need to be parsed differently depending on the quasiquote flavor that is being used at the moment (`q`, `tq` etc) there a few sub-Parsers with different code wrapping logic.

- `Reifiers`. Customized reifiers that combines reification and substitution of trees that represent holes in a quote (placeholders) with corresponding spliced values. There are two main different reification strategies: `ApplyReifier` and `UnapplyReifier` that are used correspondingly for construction and deconstruction quasiquotes.

- Extremely minor patch to the typer that special-cases expansion of unapply quasiquotes so that they can expand directly into inline patterns

- A few minor changes to the parser that simplify implementation of customized parser for quasiquotes

- Scalacheck-based tests