8000 gh-104683: Modernise Argument Clinic parameter state machine by erlend-aasland · Pull Request #106362 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-104683: Modernise Argument Clinic parameter state machine #106362

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add ParamState class
  • Loading branch information
erlend-aasland committed Jul 3, 2023
commit 4b84af3470e01a8e2d7ea37e2d4f45f0d3e9f747
26 changes: 26 additions & 0 deletions Tools/clinic/clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -4292,6 +4292,32 @@ def dedent(self, line):

StateKeeper = Callable[[str | None], None]

class ParamState(enum.IntEnum):
# Before we've seen anything.
# Legal transitions: to LEFT_SQUARE_BEFORE or REQUIRED
START = enum.auto()

# Left square backets before required params.
LEFT_SQUARE_BEFORE = enum.auto()

# In a group, before required params.
GROUP_BEFORE = enum.auto()

# Required params, positional-or-keyword or positional-only (we
# don't know yet). Renumber lefft groups!
REQUIRED = enum.auto()

# Positional-or-keyword or positional-only params that now must have
# default values.
OPTIONAL = enum.auto()

# In a group, after required params.
GROUP_AFTER = enum.auto()

# Right square brackets after required params.
RIGHT_SQUARE_AFTER = enum.auto()


class DSLParser:
function: Function | None
state: StateKeeper
Expand Down
0