mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
GH-111485: Delete the old generator code. (GH-113321)
This commit is contained in:
parent
fae096cd4b
commit
723f4d6698
18 changed files with 210 additions and 3723 deletions
|
@ -1,10 +1,24 @@
|
|||
import sys
|
||||
import re
|
||||
from analyzer import StackItem, Instruction, Uop
|
||||
from dataclasses import dataclass
|
||||
from formatting import maybe_parenthesize
|
||||
from cwriter import CWriter
|
||||
|
||||
|
||||
def maybe_parenthesize(sym: str) -> str:
|
||||
"""Add parentheses around a string if it contains an operator
|
||||
and is not already parenthesized.
|
||||
|
||||
An exception is made for '*' which is common and harmless
|
||||
in the context where the symbolic size is used.
|
||||
"""
|
||||
if sym.startswith("(") and sym.endswith(")"):
|
||||
return sym
|
||||
if re.match(r"^[\s\w*]+$", sym):
|
||||
return sym
|
||||
else:
|
||||
return f"({sym})"
|
||||
|
||||
|
||||
def var_size(var: StackItem) -> str:
|
||||
if var.condition:
|
||||
# Special case simplification
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue