Skip to content

Use re-lexing for normal list parsing#11871

Merged
dhruvmanila merged 1 commit intomainfrom
dhruv/re-lexing-2
Jun 18, 2024
Merged

Use re-lexing for normal list parsing#11871
dhruvmanila merged 1 commit intomainfrom
dhruv/re-lexing-2

Conversation

@dhruvmanila
Copy link
Member

@dhruvmanila dhruvmanila commented Jun 14, 2024

Summary

This PR is a follow-up on #11845 to add the re-lexing logic for normal list parsing.

A normal list parsing is basically parsing elements without any separator in between i.e., there can only be trivia tokens in between the two elements. Currently, this is only being used for parsing assignment statement and f-string elements. Assignment statements cannot be in a parenthesized context, but f-string can have curly braces so this PR is specifically for them.

I don't think this is an ideal recovery but the problem is that both lexer and parser could add an error for f-strings. If the lexer adds an error it'll emit an Unknown token instead while the parser adds the error directly. I think we'd need to move all f-string errors to be emitted by the parser instead. This way the parser can correctly inform the lexer that it's out of an f-string and then the lexer can pop the current f-string context out of the stack.

Test Plan

Add test cases, update the snapshots, and run the fuzzer.

@dhruvmanila dhruvmanila added the parser Related to the parser label Jun 14, 2024
@codspeed-hq
Copy link

codspeed-hq bot commented Jun 14, 2024

CodSpeed Performance Report

Merging #11871 will not alter performance

Comparing dhruv/re-lexing-2 (7543306) with main (8499abf)

Summary

✅ 30 untouched benchmarks

@github-actions
Copy link
Contributor

github-actions bot commented Jun 14, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

@dhruvmanila dhruvmanila force-pushed the dhruv/re-lexing branch 2 times, most recently from 14fcbb3 to 1989946 Compare June 17, 2024 06:43
Base automatically changed from dhruv/re-lexing to main June 17, 2024 06:47
@dhruvmanila dhruvmanila marked this pull request as ready for review June 17, 2024 10:03
@dhruvmanila dhruvmanila requested a review from MichaReiser as a code owner June 17, 2024 10:03
@dhruvmanila dhruvmanila merged commit 1e0642f into main Jun 18, 2024
@dhruvmanila dhruvmanila deleted the dhruv/re-lexing-2 branch June 18, 2024 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

parser Related to the parser

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants