|
13 | 13 | //! A library for procedural macro writers. |
14 | 14 | //! |
15 | 15 | //! ## Usage |
16 | | -//! This package provides the `qquote!` macro for syntax creation, and the prelude |
17 | | -//! (at libproc_macro::prelude) provides a number of operations: |
18 | | -//! - `concat`, for concatenating two TokenStreams. |
19 | | -//! - `ident_eq`, for checking if two identifiers are equal regardless of syntax context. |
20 | | -//! - `str_to_token_ident`, for converting an `&str` into a Token. |
21 | | -//! - `keyword_to_token_delim`, for converting a `parse::token::keywords::Keyword` into a |
22 | | -//! Token. |
23 | | -//! - `build_delimited`, for creating a new TokenStream from an existing one and a delimiter |
24 | | -//! by wrapping the TokenStream in the delimiter. |
25 | | -//! - `build_bracket_delimited`, `build_brace_delimited`, and `build_paren_delimited`, for |
26 | | -//! easing the above. |
27 | | -//! - `build_empty_args`, which returns a TokenStream containing `()`. |
28 | | -//! - `lex`, which takes an `&str` and returns the TokenStream it represents. |
29 | | -//! |
30 | | -//! The `qquote!` macro also imports `syntax::ext::proc_macro_shim::prelude::*`, so you |
| 16 | +//! This crate provides the `qquote!` macro for syntax creation. |
| 17 | +//! |
| 18 | +//! The `qquote!` macro imports `syntax::ext::proc_macro_shim::prelude::*`, so you |
31 | 19 | //! will need to `extern crate syntax` for usage. (This is a temporary solution until more |
32 | | -//! of the external API in libproc_macro is stabilized to support the token construction |
| 20 | +//! of the external API in libproc_macro_tokens is stabilized to support the token construction |
33 | 21 | //! operations that the qausiquoter relies on.) The shim file also provides additional |
34 | 22 | //! operations, such as `build_block_emitter` (as used in the `cond` example below). |
35 | 23 | //! |
36 | | -//! ## TokenStreams |
37 | | -//! |
38 | | -//! TokenStreams serve as the basis of the macro system. They are, in essence, vectors of |
39 | | -//! TokenTrees, where indexing treats delimited values as a single term. That is, the term |
40 | | -//! `even(a+c) && even(b)` will be indexibly encoded as `even | (a+c) | even | (b)` where, |
41 | | -//! in reality, `(a+c)` is actually a decorated pointer to `a | + | c`. |
42 | | -//! |
43 | | -//! If a user has a TokenStream that is a single, delimited value, they can use |
44 | | -//! `maybe_delimited` to destruct it and receive the internal vector as a new TokenStream |
45 | | -//! as: |
46 | | -//! ``` |
47 | | -//! `(a+c)`.maybe_delimited() ~> Some(a | + | c)` |
48 | | -//! ``` |
49 | | -//! |
50 | | -//! Check the TokenStream documentation for more information; the structure also provides |
51 | | -//! cheap concatenation and slicing. |
52 | | -//! |
53 | 24 | //! ## Quasiquotation |
54 | 25 | //! |
55 | 26 | //! The quasiquoter creates output that, when run, constructs the tokenstream specified as |
|
118 | 89 | extern crate rustc_plugin; |
119 | 90 | extern crate syntax; |
120 | 91 | extern crate syntax_pos; |
| 92 | +extern crate proc_macro_tokens; |
121 | 93 | #[macro_use] extern crate log; |
122 | 94 |
|
123 | 95 | mod qquote; |
124 | | -pub mod build; |
125 | | -pub mod parse; |
126 | | -pub mod prelude; |
| 96 | + |
127 | 97 | use qquote::qquote; |
128 | 98 |
|
129 | 99 | use rustc_plugin::Registry; |
|
0 commit comments