David Tolnay | 35161ff | 2016-09-03 11:33:15 -0700 | [diff] [blame] | 1 | Nom parser for Rust items |
| 2 | ========================= |
| 3 | |
David Tolnay | ac9953b | 2016-09-07 08:37:12 -0700 | [diff] [blame] | 4 | [](https://travis-ci.org/dtolnay/syn) |
| 5 | [](https://crates.io/crates/syn) |
| 6 | [](https://dtolnay.github.io/syn/syn/) |
| 7 | |
David Tolnay | 35161ff | 2016-09-03 11:33:15 -0700 | [diff] [blame] | 8 | Parse Rust structs and enums without a Syntex dependency, intended for use with |
| 9 | [Macros 1.1](https://github.com/rust-lang/rfcs/blob/master/text/1681-macros-1.1.md). |
| 10 | |
| 11 | ```toml |
| 12 | [dependencies] |
David Tolnay | 7b3973e | 2016-09-11 17:46:52 -0700 | [diff] [blame] | 13 | syn = "0.5" |
David Tolnay | 35161ff | 2016-09-03 11:33:15 -0700 | [diff] [blame] | 14 | ``` |
| 15 | |
| 16 | ```rust |
David Tolnay | a097608 | 2016-09-07 08:24:28 -0700 | [diff] [blame] | 17 | extern crate syn; |
David Tolnay | 35161ff | 2016-09-03 11:33:15 -0700 | [diff] [blame] | 18 | |
| 19 | let raw = " |
David Tolnay | 99ef8c9 | 2016-09-04 11:31:37 -0700 | [diff] [blame] | 20 | #[derive(Debug, Clone, Eq, PartialEq)] |
David Tolnay | 35161ff | 2016-09-03 11:33:15 -0700 | [diff] [blame] | 21 | pub struct Item { |
| 22 | pub ident: Ident, |
David Tolnay | 99ef8c9 | 2016-09-04 11:31:37 -0700 | [diff] [blame] | 23 | pub vis: Visibility, |
David Tolnay | 35161ff | 2016-09-03 11:33:15 -0700 | [diff] [blame] | 24 | pub attrs: Vec<Attribute>, |
David Tolnay | 99ef8c9 | 2016-09-04 11:31:37 -0700 | [diff] [blame] | 25 | pub generics: Generics, |
| 26 | pub body: Body, |
David Tolnay | 35161ff | 2016-09-03 11:33:15 -0700 | [diff] [blame] | 27 | } |
| 28 | "; |
| 29 | |
David Tolnay | b0a2c3a | 2016-09-11 17:48:11 -0700 | [diff] [blame^] | 30 | let ast = syn::parse_item(raw).unwrap(); |
David Tolnay | 35161ff | 2016-09-03 11:33:15 -0700 | [diff] [blame] | 31 | ``` |
| 32 | |
| 33 | ## License |
| 34 | |
| 35 | Licensed under either of |
| 36 | |
| 37 | * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) |
| 38 | * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) |
| 39 | |
| 40 | at your option. |
| 41 | |
| 42 | ### Contribution |
| 43 | |
| 44 | Unless you explicitly state otherwise, any contribution intentionally submitted |
| 45 | for inclusion in this crate by you, as defined in the Apache-2.0 license, shall |
| 46 | be dual licensed as above, without any additional terms or conditions. |