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