Commit e48edd0
committed
fix: align ellipsis and range-step parsing with Elixir
Update parser semantics around ellipsis and range-step handling to match Elixir behavior for edge cases involving //.
What changed:
- In parse_infix_expression/2, handle infix // as a range-step operator only when the lhs is a range node, producing :..//.
- For non-range lhs, record the same range-step diagnostic intent Elixir uses, instead of silently accepting a generic binary //.
- In parse_ellipsis_op/1, treat :ternary_op as a continuation candidate rather than a standalone-ellipsis stop token, which fixes newline forms like x...\n//y.
- Add a regression test asserting non-range // produces an error path for x...//y.
Why:
The previous behavior diverged from Elixir in two directions: it accepted non-range infix // and parsed x...\n//y as ternary continuation instead of preserving ellipsis unary continuation semantics. This change resolves both at grammar/parse semantics level rather than adding context-specific lookahead hacks.
Special considerations:
- Tokenizer behavior was already aligned with Elixir for these inputs; the fix is parser-only.
- Existing semicolon-separated ellipsis cases remain covered and passing.1 parent e4f928b commit e48edd0
2 files changed
Lines changed: 35 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1423 | 1423 | | |
1424 | 1424 | | |
1425 | 1425 | | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
1426 | 1437 | | |
1427 | 1438 | | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
1428 | 1448 | | |
1429 | 1449 | | |
1430 | 1450 | | |
| |||
2927 | 2947 | | |
2928 | 2948 | | |
2929 | 2949 | | |
2930 | | - | |
| 2950 | + | |
2931 | 2951 | | |
2932 | 2952 | | |
2933 | 2953 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2321 | 2321 | | |
2322 | 2322 | | |
2323 | 2323 | | |
| 2324 | + | |
| 2325 | + | |
| 2326 | + | |
| 2327 | + | |
| 2328 | + | |
| 2329 | + | |
| 2330 | + | |
| 2331 | + | |
| 2332 | + | |
| 2333 | + | |
| 2334 | + | |
| 2335 | + | |
| 2336 | + | |
| 2337 | + | |
2324 | 2338 | | |
2325 | 2339 | | |
2326 | 2340 | | |
| |||
0 commit comments