blob: 3dc73836961594e165ae6a35c7460f7b21c9e5a4 [file] [log] [blame]
David Tolnay983cd142019-05-08 15:05:54 -07001// This crate crawls the Syn source directory to find all structs and enums that
2// form the Syn syntax tree.
3//
4// A machine-readable representation of the syntax tree is saved to syn.json in
5// the repo root for other code generation tools to consume. The syn-codegen
6// crate (https://docs.rs/syn-codegen/) provides the data structures for parsing
7// and making use of syn.json from Rust code.
8//
9// Finally this crate generates the Visit, VisitMut, and Fold traits in Syn
10// programmatically from the syntax tree description.
Nika Layzell27726662017-10-24 23:16:35 -040011
David Tolnay6af48992018-08-01 11:16:28 -070012#![recursion_limit = "128"]
David Tolnayc1f55792018-11-21 01:39:42 -080013#![allow(clippy::needless_pass_by_value)]
David Tolnayea9ae892017-12-26 01:44:32 -050014
David Tolnay3c3c7d12019-05-08 14:54:12 -070015mod debug;
David Tolnayb2188a62019-05-09 11:42:44 -070016mod error;
David Tolnaycec98a72019-05-08 15:23:19 -070017mod file;
David Tolnayf1e57f02019-05-08 15:30:39 -070018mod fold;
David Tolnay1db3d8e2019-05-08 16:10:25 -070019mod full;
David Tolnay1e99fa32019-05-08 16:18:36 -070020mod gen;
Carl Lerche9a7d5882019-02-15 12:27:04 -080021mod json;
David Tolnaye627fa82019-05-08 16:58:01 -070022mod operand;
Carl Lerche058ff472019-02-13 16:23:52 -080023mod parse;
David Tolnay10227122019-02-15 20:53:45 -080024mod version;
David Tolnay490b91b2019-05-08 15:46:09 -070025mod visit;
26mod visit_mut;
David Tolnay8c81f622018-07-31 23:34:35 -070027
David Tolnayb2188a62019-05-09 11:42:44 -070028use crate::error::Result;
29use std::process;
30
Nika Layzell27726662017-10-24 23:16:35 -040031fn main() {
David Tolnayb2188a62019-05-09 11:42:44 -070032 if let Err(err) = do_main() {
33 let _ = eprintln!("error: {}", err);
34 process::exit(1);
35 }
36}
37
38fn do_main() -> Result<()> {
39 let defs = parse::parse()?;
40 json::generate(&defs)?;
41 fold::generate(&defs)?;
42 visit::generate(&defs)?;
43 visit_mut::generate(&defs)?;
David Tolnay3c3c7d12019-05-08 14:54:12 -070044 debug::generate(&defs)?;
David Tolnayb2188a62019-05-09 11:42:44 -070045 Ok(())
Nika Layzell27726662017-10-24 23:16:35 -040046}