codegen-2 2.1.0__tar.gz → 2.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {codegen_2-2.1.0 → codegen_2-2.1.1}/PKG-INFO +1 -1
- {codegen_2-2.1.0 → codegen_2-2.1.1}/codegen/models/ast.py +3 -1
- {codegen_2-2.1.0 → codegen_2-2.1.1}/codegen/models/expr.py +14 -2
- {codegen_2-2.1.0 → codegen_2-2.1.1}/pyproject.toml +1 -1
- {codegen_2-2.1.0 → codegen_2-2.1.1}/LICENSE +0 -0
- {codegen_2-2.1.0 → codegen_2-2.1.1}/README.md +0 -0
- {codegen_2-2.1.0 → codegen_2-2.1.1}/codegen/__init__.py +0 -0
- {codegen_2-2.1.0 → codegen_2-2.1.1}/codegen/models/__init__.py +0 -0
- {codegen_2-2.1.0 → codegen_2-2.1.1}/codegen/models/program.py +0 -0
- {codegen_2-2.1.0 → codegen_2-2.1.1}/codegen/models/statement.py +0 -0
- {codegen_2-2.1.0 → codegen_2-2.1.1}/codegen/models/types.py +0 -0
- {codegen_2-2.1.0 → codegen_2-2.1.1}/codegen/models/var.py +0 -0
|
@@ -128,7 +128,9 @@ class AST:
|
|
|
128
128
|
return self._add_stmt(IfStatement(condition))
|
|
129
129
|
|
|
130
130
|
def else_(self):
|
|
131
|
-
assert len(self.children) > 0 and isinstance(
|
|
131
|
+
assert len(self.children) > 0 and isinstance(
|
|
132
|
+
self.children[-1].stmt, IfStatement
|
|
133
|
+
)
|
|
132
134
|
return self._add_stmt(ElseStatement())
|
|
133
135
|
|
|
134
136
|
def python_stmt(self, stmt: str) -> AST:
|
|
@@ -121,7 +121,9 @@ class ExprNegation(Expr):
|
|
|
121
121
|
expr: Expr
|
|
122
122
|
|
|
123
123
|
def to_python(self):
|
|
124
|
-
|
|
124
|
+
if isinstance(self.expr, (ExprVar, ExprConstant)):
|
|
125
|
+
return f"not {self.expr.to_python()}"
|
|
126
|
+
return f"not ({self.expr.to_python()})"
|
|
125
127
|
|
|
126
128
|
|
|
127
129
|
class PredefinedFn:
|
|
@@ -173,7 +175,17 @@ class PredefinedFn:
|
|
|
173
175
|
item: Expr
|
|
174
176
|
|
|
175
177
|
def to_python(self):
|
|
176
|
-
|
|
178
|
+
if isinstance(self.set_, (ExprVar, ExprConstant)):
|
|
179
|
+
set_py = self.set_.to_python()
|
|
180
|
+
else:
|
|
181
|
+
set_py = f"({self.set_.to_python()})"
|
|
182
|
+
|
|
183
|
+
if isinstance(self.item, (ExprVar, ExprConstant)):
|
|
184
|
+
item_py = self.item.to_python()
|
|
185
|
+
else:
|
|
186
|
+
item_py = f"({self.item.to_python()})"
|
|
187
|
+
|
|
188
|
+
return f"{item_py} in {set_py}"
|
|
177
189
|
|
|
178
190
|
@dataclass
|
|
179
191
|
class list_append(Expr):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|