David Tolnay | 4b4c4b6 | 2018-01-06 13:48:05 -0800 | [diff] [blame] | 1 | //! This crate automatically generates the definition of the `Visit`, |
| 2 | //! `VisitMut`, and `Fold` traits in `syn` based on the `syn` source. It |
Nika Layzell | 2772666 | 2017-10-24 23:16:35 -0400 | [diff] [blame] | 3 | //! discovers structs and enums declared with the `ast_*` macros and generates |
| 4 | //! the functions for those types. |
| 5 | //! |
| 6 | //! It makes a few assumptions about the target crate: |
| 7 | //! 1. All structs which are discovered must be re-exported in the root of the |
| 8 | //! crate, even if they were declared in a submodule. |
| 9 | //! 2. This code cannot discover submodules which are located in subdirectories |
| 10 | //! - only submodules located in the same directory. |
| 11 | //! 3. The path to `syn` is hardcoded. |
| 12 | |
David Tolnay | 6af4899 | 2018-08-01 11:16:28 -0700 | [diff] [blame] | 13 | #![recursion_limit = "128"] |
David Tolnay | c1f5579 | 2018-11-21 01:39:42 -0800 | [diff] [blame] | 14 | #![allow(clippy::needless_pass_by_value)] |
David Tolnay | ea9ae89 | 2017-12-26 01:44:32 -0500 | [diff] [blame] | 15 | |
Nika Layzell | 2772666 | 2017-10-24 23:16:35 -0400 | [diff] [blame] | 16 | extern crate inflections; |
David Tolnay | 2e0dba1 | 2017-12-27 01:54:40 -0500 | [diff] [blame] | 17 | extern crate proc_macro2; |
David Tolnay | d67fb75 | 2017-12-27 13:50:29 -0500 | [diff] [blame] | 18 | #[macro_use] |
| 19 | extern crate quote; |
David Tolnay | 8c81f62 | 2018-07-31 23:34:35 -0700 | [diff] [blame] | 20 | extern crate rustfmt_nightly as rustfmt; |
Carl Lerche | 058ff47 | 2019-02-13 16:23:52 -0800 | [diff] [blame] | 21 | #[macro_use] |
David Tolnay | 5f79480 | 2018-11-24 14:51:21 -0800 | [diff] [blame] | 22 | extern crate syn; |
Carl Lerche | 9a7d588 | 2019-02-15 12:27:04 -0800 | [diff] [blame^] | 23 | extern crate serde; |
| 24 | #[macro_use] |
| 25 | extern crate serde_derive; |
| 26 | extern crate serde_json; |
| 27 | extern crate toml; |
Nika Layzell | 2772666 | 2017-10-24 23:16:35 -0400 | [diff] [blame] | 28 | |
Carl Lerche | 058ff47 | 2019-02-13 16:23:52 -0800 | [diff] [blame] | 29 | mod gen; |
Carl Lerche | 9a7d588 | 2019-02-15 12:27:04 -0800 | [diff] [blame^] | 30 | mod json; |
Carl Lerche | 058ff47 | 2019-02-13 16:23:52 -0800 | [diff] [blame] | 31 | mod parse; |
| 32 | mod types; |
David Tolnay | 8c81f62 | 2018-07-31 23:34:35 -0700 | [diff] [blame] | 33 | |
Nika Layzell | 2772666 | 2017-10-24 23:16:35 -0400 | [diff] [blame] | 34 | fn main() { |
Carl Lerche | 058ff47 | 2019-02-13 16:23:52 -0800 | [diff] [blame] | 35 | let types = parse::parse(); |
| 36 | gen::generate(&types); |
Carl Lerche | 9a7d588 | 2019-02-15 12:27:04 -0800 | [diff] [blame^] | 37 | json::generate(&types); |
Nika Layzell | 2772666 | 2017-10-24 23:16:35 -0400 | [diff] [blame] | 38 | } |