@@ -56,9 +56,6 @@ fn parse_expr_with_min_bp<S: TokenStream>(
56
56
57
57
// `expr<generic_param_args>()`.
58
58
SyntaxKind :: Lt => {
59
- //let is_call_expr =
60
- // parser.dry_run(|parser| parser.parse(CallExprScope::default(),
61
- // None).0);
62
59
if is_call_expr ( parser) {
63
60
parser. parse ( CallExprScope :: default ( ) , Some ( checkpoint) ) ;
64
61
continue ;
@@ -83,16 +80,17 @@ fn parse_expr_with_min_bp<S: TokenStream>(
83
80
break ;
84
81
}
85
82
86
- if !match kind {
87
- // Method call is already handled as the postfix operator.
88
- SyntaxKind :: Dot => parser. parse ( FieldExprScope :: default ( ) , Some ( checkpoint) ) . 0 ,
89
- _ => {
90
- // 1. Try to parse the expression as an augmented assignment expression.
91
- // 2. If 1. fails, try to parse the expression as an assignment expression.
92
- // 3. If 2. fails, try to parse the expression as a binary expression.
93
- parser. parse ( BinExprScope :: default ( ) , Some ( checkpoint) ) . 0
94
- }
95
- } {
83
+ let ( ok, _) = if kind == SyntaxKind :: Dot {
84
+ parser. parse ( FieldExprScope :: default ( ) , Some ( checkpoint) )
85
+ } else if is_asn ( parser) {
86
+ parser. parse ( AssignExprScope :: default ( ) , Some ( checkpoint) )
87
+ } else if is_aug ( parser) {
88
+ parser. parse ( AugAssignExprScope :: default ( ) , Some ( checkpoint) )
89
+ } else {
90
+ parser. parse ( BinExprScope :: default ( ) , Some ( checkpoint) )
91
+ } ;
92
+
93
+ if !ok {
96
94
return false ;
97
95
}
98
96
@@ -202,20 +200,28 @@ impl super::Parse for BinExprScope {
202
200
fn parse < S : TokenStream > ( & mut self , parser : & mut Parser < S > ) {
203
201
parser. set_newline_as_trivia ( false ) ;
204
202
let ( _, rbp) = infix_binding_power ( parser) . unwrap ( ) ;
205
- if is_aug ( parser) {
206
- self . set_kind ( SyntaxKind :: AugAssignExpr ) ;
207
- bump_aug_assign_op ( parser) ;
208
- parse_expr_with_min_bp ( parser, rbp, true ) ;
209
- } else if is_asn ( parser) {
210
- self . set_kind ( SyntaxKind :: AssignExpr ) ;
211
- parser. set_newline_as_trivia ( false ) ;
212
- let ( _, rbp) = infix_binding_power ( parser) . unwrap ( ) ;
213
- parser. bump_expected ( SyntaxKind :: Eq ) ;
214
- parse_expr_with_min_bp ( parser, rbp, true ) ;
215
- } else {
216
- bump_bin_op ( parser) ;
217
- parse_expr_with_min_bp ( parser, rbp, false ) ;
218
- }
203
+ bump_bin_op ( parser) ;
204
+ parse_expr_with_min_bp ( parser, rbp, false ) ;
205
+ }
206
+ }
207
+
208
+ define_scope ! { AugAssignExprScope , AugAssignExpr , Inheritance }
209
+ impl super :: Parse for AugAssignExprScope {
210
+ fn parse < S : TokenStream > ( & mut self , parser : & mut Parser < S > ) {
211
+ parser. set_newline_as_trivia ( false ) ;
212
+ let ( _, rbp) = infix_binding_power ( parser) . unwrap ( ) ;
213
+ bump_aug_assign_op ( parser) ;
214
+ parse_expr_with_min_bp ( parser, rbp, false ) ;
215
+ }
216
+ }
217
+
218
+ define_scope ! { AssignExprScope , AssignExpr , Inheritance }
219
+ impl super :: Parse for AssignExprScope {
220
+ fn parse < S : TokenStream > ( & mut self , parser : & mut Parser < S > ) {
221
+ parser. set_newline_as_trivia ( false ) ;
222
+ let ( _, rbp) = infix_binding_power ( parser) . unwrap ( ) ;
223
+ parser. bump_expected ( SyntaxKind :: Eq ) ;
224
+ parse_expr_with_min_bp ( parser, rbp, true ) ;
219
225
}
220
226
}
221
227
0 commit comments