Commit c5be2a3
committed
Python: Allow comments in subscripts
Once again, the interaction between anchors and extras (specifically
comments) was causing trouble.
The root of the problem was the fact that in `a[b]`, we put `b` in the
`index` field of the subscript node, whereas in `a[b,c]`, we
additionally synthesize a `Tuple` node for `b,c` (which matches the
Python AST).
To fix this, we refactored the grammar slightly so as to make that tuple
explicit, such that a subscript node either contains a single expression
or the newly added tuple node. This greatly simplifies the logic.1 parent 5773538 commit c5be2a3
File tree
3 files changed
+37
-55
lines changed- python/extractor
- tests/parser
- tsg-python
- tsp
3 files changed
+37
-55
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
2543 | 2543 | | |
2544 | 2544 | | |
2545 | 2545 | | |
| 2546 | + | |
2546 | 2547 | | |
2547 | 2548 | | |
2548 | 2549 | | |
2549 | 2550 | | |
2550 | | - | |
2551 | 2551 | | |
2552 | | - | |
2553 | | - | |
2554 | | - | |
2555 | | - | |
2556 | | - | |
2557 | | - | |
2558 | | - | |
2559 | | - | |
2560 | 2552 | | |
2561 | 2553 | | |
2562 | 2554 | | |
2563 | 2555 | | |
2564 | | - | |
2565 | | - | |
2566 | | - | |
2567 | | - | |
2568 | | - | |
2569 | | - | |
2570 | | - | |
2571 | | - | |
2572 | | - | |
2573 | | - | |
2574 | | - | |
2575 | | - | |
2576 | | - | |
2577 | | - | |
2578 | | - | |
2579 | | - | |
2580 | | - | |
2581 | | - | |
2582 | | - | |
2583 | | - | |
2584 | | - | |
2585 | | - | |
2586 | | - | |
2587 | | - | |
2588 | | - | |
2589 | | - | |
2590 | | - | |
2591 | | - | |
2592 | | - | |
2593 | | - | |
2594 | | - | |
2595 | | - | |
2596 | | - | |
2597 | | - | |
2598 | | - | |
2599 | | - | |
2600 | | - | |
2601 | | - | |
2602 | | - | |
2603 | | - | |
2604 | | - | |
2605 | | - | |
2606 | 2556 | | |
2607 | 2557 | | |
2608 | 2558 | | |
| |||
3448 | 3398 | | |
3449 | 3399 | | |
3450 | 3400 | | |
3451 | | - | |
| 3401 | + | |
3452 | 3402 | | |
3453 | 3403 | | |
| 3404 | + | |
| 3405 | + | |
| 3406 | + | |
3454 | 3407 | | |
3455 | 3408 | | |
3456 | 3409 | | |
| |||
3486 | 3439 | | |
3487 | 3440 | | |
3488 | 3441 | | |
| 3442 | + | |
3489 | 3443 | | |
3490 | 3444 | | |
3491 | 3445 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
929 | 929 | | |
930 | 930 | | |
931 | 931 | | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
932 | 940 | | |
933 | 941 | | |
934 | 942 | | |
935 | | - | |
936 | | - | |
| 943 | + | |
937 | 944 | | |
938 | 945 | | |
939 | 946 | | |
| |||
0 commit comments