solar_macros/
lib.rs

1#![doc = include_str!("../README.md")]
2#![doc(
3    html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/solar/main/assets/logo.png",
4    html_favicon_url = "https://raw.githubusercontent.com/paradigmxyz/solar/main/assets/favicon.ico"
5)]
6#![allow(unreachable_pub)]
7#![cfg_attr(docsrs, feature(doc_cfg))]
8
9use proc_macro::TokenStream;
10use syn::parse_macro_input;
11
12mod symbols;
13mod visitor;
14
15/// Declare a set of pre-interned keywords and symbols.
16#[proc_macro]
17pub fn symbols(input: TokenStream) -> TokenStream {
18    symbols::symbols(input.into()).into()
19}
20
21/// Declare constant and mutable visitor traits.
22///
23/// First this expands:
24/// - `#mut` is removed or replaced with `mut` on the mutable visitor.
25/// - `#_mut` is removed or concatenated with the previous identifier on the mutable visitor.
26///
27/// Then `walk_` functions are generated for each `visit_` function with the same signature and
28/// block and the `visit_` functions are made to call the `walk_` functions by default.
29///
30/// `walk_` functions should not be overridden.
31#[proc_macro]
32pub fn declare_visitors(input: TokenStream) -> TokenStream {
33    parse_macro_input!(input as visitor::Input).expand().into()
34}