Parse delimiter before contents
diff --git a/src/attr.rs b/src/attr.rs
index 13e1867..3955876 100644
--- a/src/attr.rs
+++ b/src/attr.rs
@@ -348,7 +348,7 @@
syn!(TokenStream)
)) >>
({
- let ((path, tts), bracket) = path_and_tts;
+ let (bracket, (path, tts)) = path_and_tts;
Attribute {
style: AttrStyle::Inner(bang),
@@ -388,7 +388,7 @@
syn!(TokenStream)
)) >>
({
- let ((path, tts), bracket) = path_and_tts;
+ let (bracket, (path, tts)) = path_and_tts;
Attribute {
style: AttrStyle::Outer,
diff --git a/src/data.rs b/src/data.rs
index 3db0307..c420095 100644
--- a/src/data.rs
+++ b/src/data.rs
@@ -22,10 +22,10 @@
/// Data stored within an enum variant or struct.
pub enum VariantData {
/// Struct variant, e.g. `Point { x: f64, y: f64 }`.
- Struct(Delimited<Field, Token![,]>, token::Brace),
+ Struct(token::Brace, Delimited<Field, Token![,]>),
/// Tuple variant, e.g. `Some(T)`.
- Tuple(Delimited<Field, Token![,]>, token::Paren),
+ Tuple(token::Paren, Delimited<Field, Token![,]>),
/// Unit variant, e.g. `None`.
Unit,
@@ -37,8 +37,8 @@
// /// Slice containing the fields stored in the variant.
// pub fn fields(&self) -> &Delimited<Field, token::Comma> {
// match *self {
- // VariantData::Struct(ref fields, _) |
- // VariantData::Tuple(ref fields, _) => fields,
+ // VariantData::Struct(_, ref fields) |
+ // VariantData::Tuple(_, ref fields) => fields,
// VariantData::Unit => &[],
// }
// }
@@ -144,9 +144,9 @@
pub_token: keyword!(pub) >>
other: parens!(keyword!(crate)) >>
(Visibility::Crate(VisCrate {
- crate_token: other.0,
- paren_token: other.1,
pub_token: pub_token,
+ paren_token: other.0,
+ crate_token: other.1,
}))
)
|
@@ -154,10 +154,10 @@
pub_token: keyword!(pub) >>
other: parens!(keyword!(self)) >>
(Visibility::Restricted(VisRestricted {
- path: Box::new(other.0.into()),
- in_token: None,
- paren_token: other.1,
pub_token: pub_token,
+ paren_token: other.0,
+ in_token: None,
+ path: Box::new(other.1.into()),
}))
)
|
@@ -165,10 +165,10 @@
pub_token: keyword!(pub) >>
other: parens!(keyword!(super)) >>
(Visibility::Restricted(VisRestricted {
- path: Box::new(other.0.into()),
- in_token: None,
- paren_token: other.1,
pub_token: pub_token,
+ paren_token: other.0,
+ in_token: None,
+ path: Box::new(other.1.into()),
}))
)
|
@@ -180,10 +180,10 @@
(in_tok, restricted)
)) >>
(Visibility::Restricted(VisRestricted {
- path: Box::new((other.0).1),
- in_token: Some((other.0).0),
- paren_token: other.1,
pub_token: pub_token,
+ paren_token: other.0,
+ in_token: Some((other.1).0),
+ path: Box::new((other.1).1),
}))
)
|
@@ -222,12 +222,12 @@
impl ToTokens for VariantData {
fn to_tokens(&self, tokens: &mut Tokens) {
match *self {
- VariantData::Struct(ref fields, ref brace) => {
+ VariantData::Struct(ref brace, ref fields) => {
brace.surround(tokens, |tokens| {
fields.to_tokens(tokens);
});
}
- VariantData::Tuple(ref fields, ref paren) => {
+ VariantData::Tuple(ref paren, ref fields) => {
paren.surround(tokens, |tokens| {
fields.to_tokens(tokens);
});
diff --git a/src/derive.rs b/src/derive.rs
index 04d7599..cf4a3d1 100644
--- a/src/derive.rs
+++ b/src/derive.rs
@@ -75,7 +75,7 @@
}),
})
|
- Err(e) => map!(enum_body, move |(wh, body, brace)| DeriveInput {
+ Err(e) => map!(enum_body, move |(wh, brace, body)| DeriveInput {
ident: id,
vis: vis,
attrs: attrs,
@@ -119,7 +119,7 @@
)
));
- named!(enum_body -> (Option<WhereClause>, Delimited<Variant, Token![,]>, token::Brace), do_parse!(
+ named!(enum_body -> (Option<WhereClause>, token::Brace, Delimited<Variant, Token![,]>), do_parse!(
wh: option!(syn!(WhereClause)) >>
data: braces!(Delimited::parse_terminated) >>
(wh, data.0, data.1)
@@ -130,9 +130,9 @@
attrs: many0!(Attribute::parse_outer) >>
id: syn!(Ident) >>
data: alt!(
- struct_like_body => { |(d, b)| VariantData::Struct(d, b) }
+ struct_like_body => { |(b, d)| VariantData::Struct(b, d) }
|
- tuple_like_body => { |(d, b)| VariantData::Tuple(d, b) }
+ tuple_like_body => { |(b, d)| VariantData::Tuple(b, d) }
|
epsilon!() => { |_| VariantData::Unit }
) >>
@@ -150,10 +150,10 @@
}
}
- named!(struct_like_body -> (Delimited<Field, Token![,]>, token::Brace),
+ named!(struct_like_body -> (token::Brace, Delimited<Field, Token![,]>),
braces!(call!(Delimited::parse_terminated_with, Field::parse_struct)));
- named!(tuple_like_body -> (Delimited<Field, Token![,]>, token::Paren),
+ named!(tuple_like_body -> (token::Paren, Delimited<Field, Token![,]>),
parens!(call!(Delimited::parse_terminated_with, Field::parse_tuple)));
}
diff --git a/src/expr.rs b/src/expr.rs
index 16b04d9..fbc3033 100644
--- a/src/expr.rs
+++ b/src/expr.rs
@@ -1227,7 +1227,7 @@
mut e: call!(atom_expr, allow_struct, allow_block) >>
many0!(alt!(
tap!(args: and_call => {
- let (args, paren) = args;
+ let (paren, args) = args;
e = ExprCall {
attrs: Vec::new(),
func: Box::new(e),
@@ -1253,11 +1253,11 @@
})
|
tap!(i: and_index => {
- let (i, token) = i;
+ let (bracket, i) = i;
e = ExprIndex {
attrs: Vec::new(),
expr: Box::new(e),
- bracket_token: token,
+ bracket_token: bracket,
index: Box::new(i),
}.into();
})
@@ -1279,7 +1279,7 @@
mut e: call!(atom_expr, allow_struct, allow_block) >>
many0!(alt!(
tap!(args: and_call => {
- let (args, paren) = args;
+ let (paren, args) = args;
e = ExprCall {
attrs: Vec::new(),
func: Box::new(e),
@@ -1417,8 +1417,8 @@
e: grouped!(syn!(Expr)) >>
(ExprGroup {
attrs: Vec::new(),
- expr: Box::new(e.0),
- group_token: e.1,
+ expr: Box::new(e.1),
+ group_token: e.0,
})
));
}
@@ -1429,8 +1429,8 @@
e: parens!(syn!(Expr)) >>
(ExprParen {
attrs: Vec::new(),
- expr: Box::new(e.0),
- paren_token: e.1,
+ paren_token: e.0,
+ expr: Box::new(e.1),
})
));
}
@@ -1441,8 +1441,8 @@
elems: brackets!(Delimited::parse_terminated) >>
(ExprArray {
attrs: Vec::new(),
- elems: elems.0,
- bracket_token: elems.1,
+ bracket_token: elems.0,
+ elems: elems.1,
})
));
@@ -1451,7 +1451,7 @@
}
}
- named!(and_call -> (Delimited<Expr, Token![,]>, token::Paren),
+ named!(and_call -> (token::Paren, Delimited<Expr, Token![,]>),
parens!(Delimited::parse_terminated));
#[cfg(feature = "full")]
@@ -1484,8 +1484,8 @@
args: fish.2,
gt_token: fish.3,
}),
- args: args.0,
- paren_token: args.1,
+ args: args.1,
+ paren_token: args.0,
dot_token: dot,
}
})
@@ -1503,8 +1503,8 @@
elems: parens!(Delimited::parse_terminated) >>
(ExprTuple {
attrs: Vec::new(),
- elems: elems.0,
- paren_token: elems.1,
+ elems: elems.1,
+ paren_token: elems.0,
})
));
@@ -1530,8 +1530,8 @@
eq_token: eq,
expr: Box::new(cond),
then_branch: Block {
- stmts: then_block.0,
- brace_token: then_block.1,
+ brace_token: then_block.0,
+ stmts: then_block.1,
},
if_token: if_,
else_branch: else_block,
@@ -1554,8 +1554,8 @@
attrs: Vec::new(),
cond: Box::new(cond),
then_branch: Block {
- stmts: then_block.0,
- brace_token: then_block.1,
+ brace_token: then_block.0,
+ stmts: then_block.1,
},
if_token: if_,
else_branch: else_block,
@@ -1580,8 +1580,8 @@
(Expr::Block(ExprBlock {
attrs: Vec::new(),
block: Block {
- stmts: else_block.0,
- brace_token: else_block.1,
+ brace_token: else_block.0,
+ stmts: else_block.1,
},
}))
)
@@ -1639,15 +1639,12 @@
match_: keyword!(match) >>
obj: expr_no_struct >>
res: braces!(many0!(Arm::parse)) >>
- ({
- let (arms, brace) = res;
- ExprMatch {
- attrs: Vec::new(),
- expr: Box::new(obj),
- match_token: match_,
- brace_token: brace,
- arms: arms,
- }
+ (ExprMatch {
+ attrs: Vec::new(),
+ expr: Box::new(obj),
+ match_token: match_,
+ brace_token: res.0,
+ arms: res.1,
})
));
@@ -1897,7 +1894,7 @@
(fields, base)
)) >>
({
- let ((fields, base), brace) = data;
+ let (brace, (fields, base)) = data;
let (dots, rest) = match base.and_then(|b| b) {
Some((dots, base)) => (Some(dots), Some(base)),
None => (None, None),
@@ -1961,10 +1958,10 @@
)) >>
(ExprRepeat {
attrs: Vec::new(),
- expr: Box::new((data.0).0),
- amt: Box::new((data.0).2),
- bracket_token: data.1,
- semi_token: (data.0).1,
+ expr: Box::new((data.1).0),
+ amt: Box::new((data.1).2),
+ bracket_token: data.0,
+ semi_token: (data.1).1,
})
));
@@ -2052,15 +2049,15 @@
#[cfg(feature = "full")]
named!(and_field -> (Token![.], Member), tuple!(punct!(.), syn!(Member)));
- named!(and_index -> (Expr, token::Bracket), brackets!(syn!(Expr)));
+ named!(and_index -> (token::Bracket, Expr), brackets!(syn!(Expr)));
#[cfg(feature = "full")]
impl Synom for Block {
named!(parse -> Self, do_parse!(
stmts: braces!(Block::parse_within) >>
(Block {
- stmts: stmts.0,
- brace_token: stmts.1,
+ brace_token: stmts.0,
+ stmts: stmts.1,
})
));
@@ -2130,8 +2127,8 @@
mac: Macro {
path: what,
bang_token: bang,
- delimiter: MacroDelimiter::Brace(data.1),
- tts: data.0,
+ delimiter: MacroDelimiter::Brace(data.0),
+ tts: data.1,
},
semi_token: semi,
}))))
@@ -2302,9 +2299,9 @@
)) >>
(PatStruct {
path: path,
- fields: (data.0).0,
- brace_token: data.1,
- dot2_token: (data.0).1.and_then(|m| m),
+ fields: (data.1).0,
+ brace_token: data.0,
+ dot2_token: (data.1).1.and_then(|m| m),
})
));
@@ -2420,7 +2417,7 @@
(front, dotdot, back)
)) >>
({
- let ((front, dotdot, back), parens) = data;
+ let (parens, (front, dotdot, back)) = data;
let (dotdot, trailing) = match dotdot {
Some((a, b)) => (Some(a), Some(b)),
None => (None, None),
@@ -2532,7 +2529,7 @@
) >>
(before, middle, after)
)),
- |((before, middle, after), brackets)| {
+ |(brackets, (before, middle, after))| {
let mut before: Delimited<Pat, Token![,]> = before;
let after: Option<Delimited<Pat, Token![,]>> = after;
let middle: Option<(Token![..], Option<Token![,]>)> = middle;
diff --git a/src/gen/fold.rs b/src/gen/fold.rs
index 8580952..14e4575 100644
--- a/src/gen/fold.rs
+++ b/src/gen/fold.rs
@@ -2727,14 +2727,14 @@
match _i {
VariantData::Struct(_binding_0, _binding_1, ) => {
VariantData::Struct (
- FoldHelper::lift(_binding_0, |it| { _visitor.fold_field(it) }),
- Brace(tokens_helper(_visitor, &(_binding_1).0)),
+ Brace(tokens_helper(_visitor, &(_binding_0).0)),
+ FoldHelper::lift(_binding_1, |it| { _visitor.fold_field(it) }),
)
}
VariantData::Tuple(_binding_0, _binding_1, ) => {
VariantData::Tuple (
- FoldHelper::lift(_binding_0, |it| { _visitor.fold_field(it) }),
- Paren(tokens_helper(_visitor, &(_binding_1).0)),
+ Paren(tokens_helper(_visitor, &(_binding_0).0)),
+ FoldHelper::lift(_binding_1, |it| { _visitor.fold_field(it) }),
)
}
VariantData::Unit => { VariantData::Unit }
diff --git a/src/gen/visit.rs b/src/gen/visit.rs
index 56ac2c8..4f73cb2 100644
--- a/src/gen/visit.rs
+++ b/src/gen/visit.rs
@@ -2097,12 +2097,12 @@
pub fn visit_variant_data<'ast, V: Visitor<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast VariantData) {
match *_i {
VariantData::Struct(ref _binding_0, ref _binding_1, ) => {
- for el in _binding_0 { let it = el.item(); _visitor.visit_field(it) };
- tokens_helper(_visitor, &(_binding_1).0);
+ tokens_helper(_visitor, &(_binding_0).0);
+ for el in _binding_1 { let it = el.item(); _visitor.visit_field(it) };
}
VariantData::Tuple(ref _binding_0, ref _binding_1, ) => {
- for el in _binding_0 { let it = el.item(); _visitor.visit_field(it) };
- tokens_helper(_visitor, &(_binding_1).0);
+ tokens_helper(_visitor, &(_binding_0).0);
+ for el in _binding_1 { let it = el.item(); _visitor.visit_field(it) };
}
VariantData::Unit => { }
}
diff --git a/src/gen/visit_mut.rs b/src/gen/visit_mut.rs
index 94fd73f..812a4f1 100644
--- a/src/gen/visit_mut.rs
+++ b/src/gen/visit_mut.rs
@@ -2097,12 +2097,12 @@
pub fn visit_variant_data_mut<V: VisitorMut + ?Sized>(_visitor: &mut V, _i: &mut VariantData) {
match *_i {
VariantData::Struct(ref mut _binding_0, ref mut _binding_1, ) => {
- for mut el in _binding_0 { let it = el.item_mut(); _visitor.visit_field_mut(it) };
- tokens_helper(_visitor, &mut (_binding_1).0);
+ tokens_helper(_visitor, &mut (_binding_0).0);
+ for mut el in _binding_1 { let it = el.item_mut(); _visitor.visit_field_mut(it) };
}
VariantData::Tuple(ref mut _binding_0, ref mut _binding_1, ) => {
- for mut el in _binding_0 { let it = el.item_mut(); _visitor.visit_field_mut(it) };
- tokens_helper(_visitor, &mut (_binding_1).0);
+ tokens_helper(_visitor, &mut (_binding_0).0);
+ for mut el in _binding_1 { let it = el.item_mut(); _visitor.visit_field_mut(it) };
}
VariantData::Unit => { }
}
diff --git a/src/generics.rs b/src/generics.rs
index 349a46c..bdf002f 100644
--- a/src/generics.rs
+++ b/src/generics.rs
@@ -318,7 +318,7 @@
}
|
parens!(syn!(PolyTraitRef)) => {
- |poly| TypeParamBound::Trait(poly.0, TraitBoundModifier::None)
+ |poly| TypeParamBound::Trait(poly.1, TraitBoundModifier::None)
}
));
diff --git a/src/item.rs b/src/item.rs
index 3d84c28..3305678 100644
--- a/src/item.rs
+++ b/src/item.rs
@@ -708,8 +708,8 @@
impl_synom!(UseList "use list" do_parse!(
list: braces!(Delimited::parse_terminated) >>
(UseList {
- brace_token: list.1,
- items: list.0,
+ brace_token: list.0,
+ items: list.1,
})
));
@@ -780,7 +780,7 @@
(ItemFn {
attrs: {
let mut attrs = outer_attrs;
- attrs.extend((inner_attrs_stmts.0).0);
+ attrs.extend((inner_attrs_stmts.1).0);
attrs
},
vis: vis,
@@ -789,8 +789,8 @@
abi: abi,
decl: Box::new(FnDecl {
fn_token: fn_,
- paren_token: inputs.1,
- inputs: inputs.0,
+ paren_token: inputs.0,
+ inputs: inputs.1,
output: ret,
variadic: None,
generics: Generics {
@@ -800,8 +800,8 @@
}),
ident: ident,
block: Box::new(Block {
- brace_token: inner_attrs_stmts.1,
- stmts: (inner_attrs_stmts.0).1,
+ brace_token: inner_attrs_stmts.0,
+ stmts: (inner_attrs_stmts.1).1,
}),
})
));
@@ -868,7 +868,7 @@
many0!(Attribute::parse_inner),
many0!(Item::parse)
)
- ) => {|((inner_attrs, items), brace)| (
+ ) => {|(brace, (inner_attrs, items))| (
inner_attrs,
Some((brace, items)),
None,
@@ -895,8 +895,8 @@
(ItemForeignMod {
attrs: attrs,
abi: abi,
- brace_token: items.1,
- items: items.0,
+ brace_token: items.0,
+ items: items.1,
})
));
@@ -923,7 +923,7 @@
where_clause: option!(syn!(WhereClause)) >>
semi: punct!(;) >>
({
- let ((inputs, variadic), parens) = inputs;
+ let (parens, (inputs, variadic)) = inputs;
ForeignItemFn {
ident: ident,
attrs: attrs,
@@ -1066,8 +1066,8 @@
},
colon_token: colon,
supertraits: bounds.unwrap_or_default(),
- brace_token: body.1,
- items: body.0,
+ brace_token: body.0,
+ items: body.1,
})
));
@@ -1141,7 +1141,7 @@
semi: cond!(body.is_none(), punct!(;)) >>
({
let (inner_attrs, stmts) = match body {
- Some(((inner_attrs, stmts), b)) => (inner_attrs, Some((stmts, b))),
+ Some((b, (inner_attrs, stmts))) => (inner_attrs, Some((stmts, b))),
None => (Vec::new(), None),
};
TraitItemMethod {
@@ -1156,10 +1156,10 @@
abi: abi,
ident: ident,
decl: FnDecl {
- inputs: inputs.0,
+ inputs: inputs.1,
output: ret,
fn_token: fn_,
- paren_token: inputs.1,
+ paren_token: inputs.0,
variadic: None,
generics: Generics {
where_clause: where_clause,
@@ -1244,8 +1244,8 @@
},
trait_: polarity_path,
self_ty: Box::new(self_ty),
- brace_token: body.1,
- items: body.0,
+ brace_token: body.0,
+ items: body.1,
})
));
@@ -1304,7 +1304,7 @@
(ImplItemMethod {
attrs: {
let mut attrs = outer_attrs;
- attrs.extend((inner_attrs_stmts.0).0);
+ attrs.extend((inner_attrs_stmts.1).0);
attrs
},
vis: vis,
@@ -1316,8 +1316,8 @@
ident: ident,
decl: FnDecl {
fn_token: fn_,
- paren_token: inputs.1,
- inputs: inputs.0,
+ paren_token: inputs.0,
+ inputs: inputs.1,
output: ret,
generics: Generics {
where_clause: where_clause,
@@ -1327,8 +1327,8 @@
},
},
block: Block {
- brace_token: inner_attrs_stmts.1,
- stmts: (inner_attrs_stmts.0).1,
+ brace_token: inner_attrs_stmts.0,
+ stmts: (inner_attrs_stmts.1).1,
},
})
));
diff --git a/src/parsers.rs b/src/parsers.rs
index 8072ab8..41b36b0 100644
--- a/src/parsers.rs
+++ b/src/parsers.rs
@@ -277,11 +277,11 @@
/// name: syn!(Ident) >>
/// bang: punct!(!) >>
/// empty_body: alt!(
-/// parens!(epsilon!()) => { |d| MacroDelimiter::Paren(d.1) }
+/// parens!(epsilon!()) => { |d| MacroDelimiter::Paren(d.0) }
/// |
-/// brackets!(epsilon!()) => { |d| MacroDelimiter::Bracket(d.1) }
+/// brackets!(epsilon!()) => { |d| MacroDelimiter::Bracket(d.0) }
/// |
-/// braces!(epsilon!()) => { |d| MacroDelimiter::Brace(d.1) }
+/// braces!(epsilon!()) => { |d| MacroDelimiter::Brace(d.0) }
/// ) >>
/// semi: cond!(empty_body.requires_semi(), punct!(;)) >>
/// (EmptyMacroCall {
@@ -422,8 +422,8 @@
/// (SimpleMod {
/// mod_token: mod_token,
/// name: name,
-/// brace_token: body.1,
-/// items: body.0,
+/// brace_token: body.0,
+/// items: body.1,
/// })
/// ));
/// }
@@ -556,7 +556,7 @@
/// |
/// StructOrEnum::Enum(enum_token) => map!(
/// braces!(syn!(Ident)),
-/// |(variant, brace_token)| UnitType::Enum {
+/// |(brace_token, variant)| UnitType::Enum {
/// enum_token: enum_token,
/// name: name,
/// brace_token: brace_token,
@@ -648,7 +648,7 @@
/// |
/// StructOrEnum::Enum(enum_token) => map!(
/// braces!(syn!(Ident)),
-/// |(variant, brace_token)| UnitType::Enum {
+/// |(brace_token, variant)| UnitType::Enum {
/// enum_token: enum_token,
/// name: name,
/// brace_token: brace_token,
@@ -1167,8 +1167,8 @@
/// (SimpleMod {
/// mod_token: mod_token,
/// name: name,
-/// brace_token: body.1,
-/// items: body.0,
+/// brace_token: body.0,
+/// items: body.1,
/// })
/// ));
/// }
@@ -1188,8 +1188,8 @@
/// the content inside. The sub-parser is required to consume all tokens within
/// the parentheses in order for this parser to return successfully.
///
-/// - **Syntax:** `parens!(SUBPARSER)`
-/// - **Output:** `(SUBPARSER, token::Paren)`
+/// - **Syntax:** `parens!(CONTENT)`
+/// - **Output:** `(token::Paren, CONENT)`
///
/// ```rust
/// #[macro_use]
@@ -1201,7 +1201,7 @@
/// /// Parses an expression inside of parentheses.
/// ///
/// /// Example: `(1 + 1)`
-/// named!(expr_paren -> (Expr, Paren), parens!(syn!(Expr)));
+/// named!(expr_paren -> (Paren, Expr), parens!(syn!(Expr)));
/// #
/// # fn main() {}
/// ```
@@ -1222,8 +1222,8 @@
/// content inside. The sub-parser is required to consume all tokens within the
/// brackets in order for this parser to return successfully.
///
-/// - **Syntax:** `brackets!(SUBPARSER)`
-/// - **Output:** `(SUBPARSER, token::Bracket)`
+/// - **Syntax:** `brackets!(CONTENT)`
+/// - **Output:** `(token::Bracket, CONTENT)`
///
/// ```rust
/// #[macro_use]
@@ -1235,7 +1235,7 @@
/// /// Parses an expression inside of brackets.
/// ///
/// /// Example: `[1 + 1]`
-/// named!(expr_paren -> (Expr, Bracket), brackets!(syn!(Expr)));
+/// named!(expr_paren -> (Bracket, Expr), brackets!(syn!(Expr)));
/// #
/// # fn main() {}
/// ```
@@ -1256,8 +1256,8 @@
/// content inside. The sub-parser is required to consume all tokens within the
/// braces in order for this parser to return successfully.
///
-/// - **Syntax:** `braces!(SUBPARSER)`
-/// - **Output:** `(SUBPARSER, token::Brace)`
+/// - **Syntax:** `braces!(CONTENT)`
+/// - **Output:** `(token::Brace, CONTENT)`
///
/// ```rust
/// #[macro_use]
@@ -1269,7 +1269,7 @@
/// /// Parses an expression inside of braces.
/// ///
/// /// Example: `{1 + 1}`
-/// named!(expr_paren -> (Expr, Brace), braces!(syn!(Expr)));
+/// named!(expr_paren -> (Brace, Expr), braces!(syn!(Expr)));
/// #
/// # fn main() {}
/// ```
diff --git a/src/token.rs b/src/token.rs
index 5419fe7..d3e320a 100644
--- a/src/token.rs
+++ b/src/token.rs
@@ -171,7 +171,7 @@
}
#[cfg(feature = "parsing")]
- pub fn parse<F, R>(tokens: $crate::synom::Cursor, f: F) -> $crate::synom::PResult<(R, $name)>
+ pub fn parse<F, R>(tokens: $crate::synom::Cursor, f: F) -> $crate::synom::PResult<($name, R)>
where F: FnOnce($crate::synom::Cursor) -> $crate::synom::PResult<R>
{
parsing::delim($s, tokens, $name, f)
@@ -540,7 +540,7 @@
tokens: Cursor<'a>,
new: fn(Span) -> T,
f: F,
- ) -> PResult<'a, (R, T)>
+ ) -> PResult<'a, (T, R)>
where
F: FnOnce(Cursor) -> PResult<R>,
{
@@ -557,7 +557,7 @@
match f(seqinfo.inside) {
Ok((remaining, ret)) => {
if remaining.eof() {
- return Ok((seqinfo.outside, (ret, new(seqinfo.span))));
+ return Ok((seqinfo.outside, (new(seqinfo.span), ret)));
}
}
Err(err) => return Err(err),
diff --git a/src/ty.rs b/src/ty.rs
index 69d7d21..dc520df 100644
--- a/src/ty.rs
+++ b/src/ty.rs
@@ -400,7 +400,7 @@
impl Synom for TypeSlice {
named!(parse -> Self, map!(
brackets!(syn!(Type)),
- |(ty, b)| TypeSlice {
+ |(b, ty)| TypeSlice {
elem: Box::new(ty),
bracket_token: b,
}
@@ -419,7 +419,7 @@
len: syn!(Expr) >>
(elem, semi, len)
)),
- |((elem, semi, len), brackets)| {
+ |(brackets, (elem, semi, len))| {
TypeArray {
elem: Box::new(elem),
len: len,
@@ -493,10 +493,10 @@
abi: abi,
lifetimes: lifetimes,
output: output,
- variadic: (parens.0).1,
+ variadic: (parens.1).1,
fn_token: fn_,
- paren_token: parens.1,
- inputs: (parens.0).0,
+ paren_token: parens.0,
+ inputs: (parens.1).0,
})
));
@@ -531,8 +531,8 @@
named!(parse -> Self, do_parse!(
data: parens!(Delimited::parse_terminated) >>
(TypeTuple {
- elems: data.0,
- paren_token: data.1,
+ paren_token: data.0,
+ elems: data.1,
})
));
@@ -611,8 +611,8 @@
data: parens!(Delimited::parse_terminated) >>
output: syn!(ReturnType) >>
(ParenthesizedGenericArguments {
- paren_token: data.1,
- inputs: data.0,
+ paren_token: data.0,
+ inputs: data.1,
output: output,
})
));
@@ -689,8 +689,8 @@
named!(parse -> Self, do_parse!(
data: grouped!(syn!(Type)) >>
(TypeGroup {
- group_token: data.1,
- elem: Box::new(data.0),
+ group_token: data.0,
+ elem: Box::new(data.1),
})
));
}
@@ -704,8 +704,8 @@
data: parens!(syn!(Type)) >>
cond!(allow_plus, not!(punct!(+))) >>
(TypeParen {
- paren_token: data.1,
- elem: Box::new(data.0),
+ paren_token: data.0,
+ elem: Box::new(data.1),
})
));
}