Skip to content

GH-131498: Cases generator: Parse down to C statement level. - #131948

Merged
markshannon merged 14 commits into
python:mainfrom
faster-cpython:code-gen-add-parser
Apr 2, 2025
Merged

GH-131498: Cases generator: Parse down to C statement level.#131948
markshannon merged 14 commits into
python:mainfrom
faster-cpython:code-gen-add-parser

Conversation

@markshannon

@markshannonmarkshannon commented Mar 31, 2025

Copy link
Copy Markdown
Member

This PR enhances the cases generator parser to parse instructions and labels down to C statement level.

This:

  • Simplifies the rest of the code generator.
  • Enables us to treat #if conditionals like normal if statements ensuring that the free-threading and default builds have the same properties and are properly understood by the code generator.

Because we are now parsing the source, rather than simply tokenizing it, the output no longer contains the comments present in the original.

Comment threadTools/cases_generator/generators_common.py
Comment threadTools/cases_generator/parsing.py Outdated
raise NotImplementedError()


@dataclass

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe to reduce memory footprint, use slots=True

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it is worth it to save a few kbytes.

Comment threadTools/cases_generator/parsing.py Outdated
Comment threadTools/cases_generator/parsing.py Outdated
Comment threadTools/cases_generator/parsing.py
Comment threadTools/cases_generator/generators_common.py Outdated
@markshannon
markshannon marked this pull request as ready for review April 2, 2025 13:57
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@markshannon@iritkatriel@picnixz