David Tolnay | ad2836d | 2017-04-20 10:11:43 -0700 | [diff] [blame] | 1 | #![doc(html_root_url = "https://dtolnay.github.io/syn")] |
| 2 | |
David Tolnay | 02a8d47 | 2017-02-19 12:59:44 -0800 | [diff] [blame] | 3 | #![cfg_attr(feature = "cargo-clippy", allow(large_enum_variant))] |
David Tolnay | aed77b0 | 2016-09-23 20:50:31 -0700 | [diff] [blame] | 4 | |
Alex Crichton | ccbb45d | 2017-05-23 10:58:24 -0700 | [diff] [blame] | 5 | extern crate proc_macro2; |
David Tolnay | 570695e | 2017-06-03 16:15:13 -0700 | [diff] [blame^] | 6 | extern crate unicode_xid; |
Alex Crichton | ccbb45d | 2017-05-23 10:58:24 -0700 | [diff] [blame] | 7 | |
David Tolnay | 87d0b44 | 2016-09-04 11:52:12 -0700 | [diff] [blame] | 8 | #[cfg(feature = "printing")] |
| 9 | extern crate quote; |
| 10 | |
Alex Crichton | ccbb45d | 2017-05-23 10:58:24 -0700 | [diff] [blame] | 11 | #[cfg_attr(feature = "parsing", macro_use)] |
David Tolnay | 5fe14fc | 2017-01-27 16:22:08 -0800 | [diff] [blame] | 12 | extern crate synom; |
David Tolnay | 35161ff | 2016-09-03 11:33:15 -0700 | [diff] [blame] | 13 | |
Alex Crichton | 62a0a59 | 2017-05-22 13:58:53 -0700 | [diff] [blame] | 14 | #[macro_use] |
| 15 | mod macros; |
| 16 | |
David Tolnay | b79ee96 | 2016-09-04 09:39:20 -0700 | [diff] [blame] | 17 | mod attr; |
Alex Crichton | 62a0a59 | 2017-05-22 13:58:53 -0700 | [diff] [blame] | 18 | pub use attr::{Attribute, AttrStyle, MetaItem, NestedMetaItem, MetaItemList, |
| 19 | MetaNameValue}; |
David Tolnay | 35161ff | 2016-09-03 11:33:15 -0700 | [diff] [blame] | 20 | |
David Tolnay | 3cb23a9 | 2016-10-07 23:02:21 -0700 | [diff] [blame] | 21 | mod constant; |
Alex Crichton | 62a0a59 | 2017-05-22 13:58:53 -0700 | [diff] [blame] | 22 | pub use constant::{ConstExpr, ConstCall, ConstBinary, ConstUnary, ConstCast, |
| 23 | ConstIndex, ConstParen}; |
David Tolnay | 3cb23a9 | 2016-10-07 23:02:21 -0700 | [diff] [blame] | 24 | |
David Tolnay | f38cdf6 | 2016-09-23 19:07:09 -0700 | [diff] [blame] | 25 | mod data; |
Alex Crichton | ccbb45d | 2017-05-23 10:58:24 -0700 | [diff] [blame] | 26 | pub use data::{Field, Variant, VariantData, Visibility, VisRestricted, VisCrate, |
| 27 | VisPublic, VisInherited}; |
David Tolnay | f38cdf6 | 2016-09-23 19:07:09 -0700 | [diff] [blame] | 28 | |
David Tolnay | f4bbbd9 | 2016-09-23 14:41:55 -0700 | [diff] [blame] | 29 | #[cfg(feature = "full")] |
| 30 | mod expr; |
| 31 | #[cfg(feature = "full")] |
David Tolnay | 05120ef | 2017-03-12 18:29:26 -0700 | [diff] [blame] | 32 | pub use expr::{Arm, BindingMode, Block, CaptureBy, Expr, ExprKind, FieldPat, FieldValue, Local, |
Alex Crichton | 62a0a59 | 2017-05-22 13:58:53 -0700 | [diff] [blame] | 33 | MacStmtStyle, Pat, RangeLimits, Stmt, ExprBox, ExprInPlace, |
| 34 | ExprArray, ExprCall, ExprMethodCall, ExprTup, ExprBinary, ExprUnary, |
| 35 | ExprCast, ExprType, ExprIf, ExprIfLet, ExprWhile, ExprWhileLet, |
| 36 | ExprForLoop, ExprLoop, ExprMatch, ExprClosure, ExprBlock, |
| 37 | ExprAssign, ExprAssignOp, ExprField, ExprTupField, ExprIndex, |
| 38 | ExprRange, ExprPath, ExprAddrOf, ExprBreak, ExprContinue, |
Alex Crichton | ccbb45d | 2017-05-23 10:58:24 -0700 | [diff] [blame] | 39 | ExprRet, ExprStruct, ExprRepeat, ExprParen, ExprTry, ExprCatch, |
| 40 | PatIdent, PatWild, PatStruct, PatTuple, PatTupleStruct, PatPath, |
| 41 | PatBox, PatRef, PatLit, PatRange, PatSlice}; |
David Tolnay | f4bbbd9 | 2016-09-23 14:41:55 -0700 | [diff] [blame] | 42 | |
David Tolnay | b79ee96 | 2016-09-04 09:39:20 -0700 | [diff] [blame] | 43 | mod generics; |
David Tolnay | daaf774 | 2016-10-03 11:11:43 -0700 | [diff] [blame] | 44 | pub use generics::{Generics, Lifetime, LifetimeDef, TraitBoundModifier, TyParam, TyParamBound, |
David Tolnay | fa23f57 | 2017-01-23 00:19:11 -0800 | [diff] [blame] | 45 | WhereBoundPredicate, WhereClause, WhereEqPredicate, WherePredicate, |
Alex Crichton | ccbb45d | 2017-05-23 10:58:24 -0700 | [diff] [blame] | 46 | WhereRegionPredicate, BoundLifetimes}; |
David Tolnay | e767892 | 2016-10-13 20:44:03 -0700 | [diff] [blame] | 47 | #[cfg(feature = "printing")] |
David Tolnay | c879a50 | 2017-01-25 15:51:32 -0800 | [diff] [blame] | 48 | pub use generics::{ImplGenerics, Turbofish, TyGenerics}; |
David Tolnay | 35161ff | 2016-09-03 11:33:15 -0700 | [diff] [blame] | 49 | |
David Tolnay | 5533772 | 2016-09-11 12:58:56 -0700 | [diff] [blame] | 50 | mod ident; |
David Tolnay | daaf774 | 2016-10-03 11:11:43 -0700 | [diff] [blame] | 51 | pub use ident::Ident; |
David Tolnay | 5533772 | 2016-09-11 12:58:56 -0700 | [diff] [blame] | 52 | |
David Tolnay | f38cdf6 | 2016-09-23 19:07:09 -0700 | [diff] [blame] | 53 | #[cfg(feature = "full")] |
David Tolnay | b79ee96 | 2016-09-04 09:39:20 -0700 | [diff] [blame] | 54 | mod item; |
David Tolnay | f38cdf6 | 2016-09-23 19:07:09 -0700 | [diff] [blame] | 55 | #[cfg(feature = "full")] |
Alex Crichton | 62a0a59 | 2017-05-22 13:58:53 -0700 | [diff] [blame] | 56 | pub use item::{Constness, Defaultness, FnArg, FnDecl, ForeignItemKind, ForeignItem, ItemForeignMod, |
David Tolnay | c1fea50 | 2016-10-30 17:54:02 -0700 | [diff] [blame] | 57 | ImplItem, ImplItemKind, ImplPolarity, Item, ItemKind, MethodSig, PathListItem, |
Alex Crichton | 62a0a59 | 2017-05-22 13:58:53 -0700 | [diff] [blame] | 58 | TraitItem, TraitItemKind, ViewPath, ItemExternCrate, ItemUse, |
| 59 | ItemStatic, ItemConst, ItemFn, ItemMod, ItemTy, ItemEnum, |
| 60 | ItemStruct, ItemUnion, ItemTrait, ItemDefaultImpl, ItemImpl, |
| 61 | PathSimple, PathGlob, PathList, ForeignItemFn, ForeignItemStatic, |
| 62 | TraitItemConst, TraitItemMethod, TraitItemType, |
| 63 | ImplItemConst, ImplItemMethod, ImplItemType, ArgSelfRef, |
| 64 | ArgSelf, ArgCaptured}; |
David Tolnay | 35161ff | 2016-09-03 11:33:15 -0700 | [diff] [blame] | 65 | |
David Tolnay | 631cb8c | 2016-11-10 17:16:41 -0800 | [diff] [blame] | 66 | #[cfg(feature = "full")] |
| 67 | mod krate; |
| 68 | #[cfg(feature = "full")] |
| 69 | pub use krate::Crate; |
| 70 | |
David Tolnay | f4bbbd9 | 2016-09-23 14:41:55 -0700 | [diff] [blame] | 71 | mod lit; |
Alex Crichton | ccbb45d | 2017-05-23 10:58:24 -0700 | [diff] [blame] | 72 | pub use lit::{Lit, LitKind}; |
David Tolnay | f4bbbd9 | 2016-09-23 14:41:55 -0700 | [diff] [blame] | 73 | |
David Tolnay | f4bbbd9 | 2016-09-23 14:41:55 -0700 | [diff] [blame] | 74 | mod mac; |
Alex Crichton | ccbb45d | 2017-05-23 10:58:24 -0700 | [diff] [blame] | 75 | pub use mac::{Mac, TokenTree}; |
David Tolnay | f4bbbd9 | 2016-09-23 14:41:55 -0700 | [diff] [blame] | 76 | |
David Tolnay | 0e83740 | 2016-12-22 17:25:55 -0500 | [diff] [blame] | 77 | mod derive; |
Alex Crichton | ccbb45d | 2017-05-23 10:58:24 -0700 | [diff] [blame] | 78 | pub use derive::{Body, DeriveInput, BodyEnum, BodyStruct}; |
David Tolnay | c28a4a5 | 2017-02-04 09:50:57 -0800 | [diff] [blame] | 79 | // Deprecated. Use `DeriveInput` instead. |
David Tolnay | 0e83740 | 2016-12-22 17:25:55 -0500 | [diff] [blame] | 80 | #[doc(hidden)] |
| 81 | pub type MacroInput = DeriveInput; |
David Tolnay | f38cdf6 | 2016-09-23 19:07:09 -0700 | [diff] [blame] | 82 | |
David Tolnay | 3cb23a9 | 2016-10-07 23:02:21 -0700 | [diff] [blame] | 83 | mod op; |
| 84 | pub use op::{BinOp, UnOp}; |
| 85 | |
David Tolnay | b79ee96 | 2016-09-04 09:39:20 -0700 | [diff] [blame] | 86 | mod ty; |
David Tolnay | b8d8ef5 | 2016-10-29 14:30:08 -0700 | [diff] [blame] | 87 | pub use ty::{Abi, AngleBracketedParameterData, BareFnArg, BareFnTy, FunctionRetTy, MutTy, |
| 88 | Mutability, ParenthesizedParameterData, Path, PathParameters, PathSegment, |
Alex Crichton | 62a0a59 | 2017-05-22 13:58:53 -0700 | [diff] [blame] | 89 | PolyTraitRef, QSelf, Ty, TypeBinding, Unsafety, TySlice, TyArray, |
| 90 | TyPtr, TyRptr, TyBareFn, TyNever, TyTup, TyPath, TyTraitObject, |
| 91 | TyImplTrait, TyParen, TyInfer}; |
Alex Crichton | ccbb45d | 2017-05-23 10:58:24 -0700 | [diff] [blame] | 92 | #[cfg(feature = "printing")] |
| 93 | pub use ty::PathTokens; |
| 94 | |
Alex Crichton | 954046c | 2017-05-30 21:49:42 -0700 | [diff] [blame] | 95 | pub use synom::span::Span; |
| 96 | pub use synom::tokens; |
Alex Crichton | ccbb45d | 2017-05-23 10:58:24 -0700 | [diff] [blame] | 97 | pub use synom::delimited; |
David Tolnay | 35161ff | 2016-09-03 11:33:15 -0700 | [diff] [blame] | 98 | |
David Tolnay | 5533772 | 2016-09-11 12:58:56 -0700 | [diff] [blame] | 99 | #[cfg(feature = "visit")] |
| 100 | pub mod visit; |
| 101 | |
gnzlbg | 9ae88d8 | 2017-01-26 20:45:17 +0100 | [diff] [blame] | 102 | #[cfg(feature = "fold")] |
| 103 | pub mod fold; |
| 104 | |
David Tolnay | 5533772 | 2016-09-11 12:58:56 -0700 | [diff] [blame] | 105 | #[cfg(feature = "parsing")] |
David Tolnay | 5533772 | 2016-09-11 12:58:56 -0700 | [diff] [blame] | 106 | mod parsing { |
Ted Driggs | 054abbb | 2017-05-01 12:20:52 -0700 | [diff] [blame] | 107 | use std::str::FromStr; |
| 108 | |
David Tolnay | 5533772 | 2016-09-11 12:58:56 -0700 | [diff] [blame] | 109 | use super::*; |
Alex Crichton | 954046c | 2017-05-30 21:49:42 -0700 | [diff] [blame] | 110 | use synom::{Synom, ParseError}; |
| 111 | use proc_macro2::TokenStream; |
Michael Layzell | 416724e | 2017-05-24 21:12:34 -0400 | [diff] [blame] | 112 | |
Alex Crichton | 954046c | 2017-05-30 21:49:42 -0700 | [diff] [blame] | 113 | macro_rules! traits { |
| 114 | ($($ty:ident,)*) => ($( |
| 115 | impl From<TokenStream> for $ty { |
| 116 | fn from(stream: TokenStream) -> $ty { |
| 117 | $ty::parse_all_unwrap(stream) |
David Tolnay | c94c38a | 2016-09-05 17:02:03 -0700 | [diff] [blame] | 118 | } |
David Tolnay | 5533772 | 2016-09-11 12:58:56 -0700 | [diff] [blame] | 119 | } |
Alex Crichton | 954046c | 2017-05-30 21:49:42 -0700 | [diff] [blame] | 120 | |
| 121 | impl FromStr for $ty { |
| 122 | type Err = ParseError; |
| 123 | |
| 124 | fn from_str(s: &str) -> Result<Self, Self::Err> { |
| 125 | $ty::parse_str_all(s) |
| 126 | } |
| 127 | } |
| 128 | )*) |
David Tolnay | 35161ff | 2016-09-03 11:33:15 -0700 | [diff] [blame] | 129 | } |
Michael Layzell | 5e107ff | 2017-01-24 19:58:39 -0500 | [diff] [blame] | 130 | |
Alex Crichton | 954046c | 2017-05-30 21:49:42 -0700 | [diff] [blame] | 131 | traits! { |
| 132 | DeriveInput, |
| 133 | TyParamBound, |
| 134 | Ident, |
| 135 | WhereClause, |
| 136 | Ty, |
Michael Layzell | c864f02 | 2017-06-03 13:01:33 -0400 | [diff] [blame] | 137 | Lit, |
Alex Crichton | 954046c | 2017-05-30 21:49:42 -0700 | [diff] [blame] | 138 | } |
David Tolnay | 0a8972b | 2017-02-27 02:10:01 -0800 | [diff] [blame] | 139 | |
Michael Layzell | 5e107ff | 2017-01-24 19:58:39 -0500 | [diff] [blame] | 140 | #[cfg(feature = "full")] |
Alex Crichton | 954046c | 2017-05-30 21:49:42 -0700 | [diff] [blame] | 141 | traits! { |
| 142 | Expr, |
| 143 | Item, |
| 144 | Crate, |
| 145 | } |
Michael Layzell | 5e107ff | 2017-01-24 19:58:39 -0500 | [diff] [blame] | 146 | } |