| 244 | |
| 245 | |
| 246 | class DSLParser: |
| 247 | function: Function | None |
| 248 | state: StateKeeper |
| 249 | expecting_parameters: bool |
| 250 | keyword_only: bool |
| 251 | positional_only: bool |
| 252 | deprecated_positional: VersionTuple | None |
| 253 | deprecated_keyword: VersionTuple | None |
| 254 | group: int |
| 255 | parameter_state: ParamState |
| 256 | indent: IndentStack |
| 257 | kind: FunctionKind |
| 258 | coexist: bool |
| 259 | forced_text_signature: str | None |
| 260 | parameter_continuation: str |
| 261 | preserve_output: bool |
| 262 | critical_section: bool |
| 263 | target_critical_section: list[str] |
| 264 | disable_fastcall: bool |
| 265 | from_version_re = re.compile(r'([*/]) +\[from +(.+)\]') |
| 266 | permit_long_summary = False |
| 267 | permit_long_docstring_body = False |
| 268 | |
| 269 | def __init__(self, clinic: Clinic) -> None: |
| 270 | self.clinic = clinic |
| 271 | |
| 272 | self.directives = {} |
| 273 | for name in dir(self): |
| 274 | # functions that start with directive_ are added to directives |
| 275 | _, s, key = name.partition("directive_") |
| 276 | if s: |
| 277 | self.directives[key] = getattr(self, name) |
| 278 | |
| 279 | # functions that start with at_ are too, with an @ in front |
| 280 | _, s, key = name.partition("at_") |
| 281 | if s: |
| 282 | self.directives['@' + key] = getattr(self, name) |
| 283 | |
| 284 | self.reset() |
| 285 | |
| 286 | def reset(self) -> None: |
| 287 | self.function = None |
| 288 | self.state = self.state_dsl_start |
| 289 | self.expecting_parameters = True |
| 290 | self.keyword_only = False |
| 291 | self.positional_only = False |
| 292 | self.deprecated_positional = None |
| 293 | self.deprecated_keyword = None |
| 294 | self.group = 0 |
| 295 | self.parameter_state: ParamState = ParamState.START |
| 296 | self.indent = IndentStack() |
| 297 | self.kind = CALLABLE |
| 298 | self.coexist = False |
| 299 | self.forced_text_signature = None |
| 300 | self.parameter_continuation = '' |
| 301 | self.preserve_output = False |
| 302 | self.critical_section = False |
| 303 | self.target_critical_section = [] |
searching dependent graphs…