|
404 | 404 |
|
405 | 405 | ;;; GeneratorExp |
406 | 406 |
|
407 | | -(generator_expression . "(" . (comment)* . (_) @start (_) @end . (comment)* . ")" .) @generatorexp |
| 407 | +(generator_expression . "(" . (comment)* . (expression) @start [(for_in_clause) (if_clause)] @end . (comment)* . ")" .) @generatorexp |
408 | 408 | { |
409 | 409 | attr (@generatorexp.node) _location_start = (location-start @start) |
410 | 410 | attr (@generatorexp.node) _location_end = (location-end @end) |
|
416 | 416 | attr (@if.node) _location_end = (location-end @expr) |
417 | 417 | } |
418 | 418 |
|
419 | | -(generator_expression . "(" . (comment)* . (_) @start (for_in_clause) @child (_) @end . (comment)* . ")" .) @genexpr |
| 419 | +(generator_expression . "(" . (comment)* . (expression) @start (for_in_clause) @child [(for_in_clause) (if_clause)] @end . (comment)* . ")" .) @genexpr |
420 | 420 | { |
421 | 421 | attr (@child.node) _location_start = (location-start @start) |
422 | 422 | attr (@child.node) _location_end = (location-end @end) |
423 | 423 | } |
424 | 424 |
|
425 | | -(generator_expression . "(" . (comment)* . (_) @start (for_in_clause) @end . (comment)* . ")" .) @genexpr |
| 425 | +(generator_expression . "(" . (comment)* . (expression) @start (for_in_clause) @end . (comment)* . ")" .) @genexpr |
426 | 426 | { |
427 | 427 | attr (@end.node) _location_start = (location-start @start) |
428 | 428 | attr (@end.node) _location_end = (location-end @end) |
|
863 | 863 | ; information for the entire generator expression (yes, it is a wide parameter!) and so we must recreate the logic for |
864 | 864 | ; setting this location information correctly. |
865 | 865 |
|
866 | | -(generator_expression . "(" . (comment)* . (_) @start (_) @end . (comment)* . ")" .) @genexpr |
| 866 | +(generator_expression . "(" . (comment)* . (expression) @start [(for_in_clause) (if_clause)] @end . (comment)* . ")" .) @genexpr |
867 | 867 | { |
868 | 868 | ; Synthesize the `genexpr` function |
869 | 869 | let @genexpr.fun = (ast-node @genexpr "Function") |
|
2661 | 2661 | let @with.first = @first.node |
2662 | 2662 | } |
2663 | 2663 |
|
| 2664 | +; Async status |
| 2665 | +; NOTE: We only set the `is_async` field on the _first_ clause of the `with` statement, |
| 2666 | +; as this is the behaviour of the old parser. |
| 2667 | +(with_statement "async" "with" @with_keyword (with_clause . (with_item) @with)) |
| 2668 | +{ |
| 2669 | + attr (@with.node) is_async = #true |
| 2670 | +} |
| 2671 | + |
2664 | 2672 | (with_item |
2665 | 2673 | value: (_) @value |
2666 | 2674 | ) @with |
|
3264 | 3272 | } |
3265 | 3273 | } |
3266 | 3274 |
|
| 3275 | +; Async status |
| 3276 | +(function_definition "async" "def" @def_keyword) @funcdef |
| 3277 | +{ |
| 3278 | + let start = (location-start @def_keyword) |
| 3279 | + attr (@funcdef.function) is_async = #true |
| 3280 | + attr (@funcdef.node) _location_start = start |
| 3281 | + attr (@funcdef.function) _location_start = start |
| 3282 | + attr (@funcdef.funcexpr) _location_start = start |
| 3283 | +} |
| 3284 | + |
3267 | 3285 | ;;; Decorators |
3268 | 3286 |
|
3269 | 3287 | (decorated_definition |
|
3478 | 3496 |
|
3479 | 3497 | [(tuple element: (_)) (tuple_pattern)] @tup |
3480 | 3498 | { |
3481 | | - attr (@tup.node) parenthesised = #true |
| 3499 | + ; In order to avoid writing to the `parenthesised` attribute twice, we only set it here |
| 3500 | + ; if the surrounding expression is not a `parenthesized_expression`. |
| 3501 | + if (not (instance-of (get-parent @tup) "parenthesized_expression")) { |
| 3502 | + attr (@tup.node) parenthesised = #true |
| 3503 | + } |
3482 | 3504 | } |
0 commit comments