codegen-2 2.1.1__tar.gz → 2.1.3__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.1 → codegen_2-2.1.3}/PKG-INFO +1 -1
- {codegen_2-2.1.1 → codegen_2-2.1.3}/codegen/models/ast.py +2 -0
- {codegen_2-2.1.1 → codegen_2-2.1.3}/codegen/models/expr.py +9 -16
- {codegen_2-2.1.1 → codegen_2-2.1.3}/pyproject.toml +1 -1
- {codegen_2-2.1.1 → codegen_2-2.1.3}/LICENSE +0 -0
- {codegen_2-2.1.1 → codegen_2-2.1.3}/README.md +0 -0
- {codegen_2-2.1.1 → codegen_2-2.1.3}/codegen/__init__.py +0 -0
- {codegen_2-2.1.1 → codegen_2-2.1.3}/codegen/models/__init__.py +0 -0
- {codegen_2-2.1.1 → codegen_2-2.1.3}/codegen/models/program.py +0 -0
- {codegen_2-2.1.1 → codegen_2-2.1.3}/codegen/models/statement.py +0 -0
- {codegen_2-2.1.1 → codegen_2-2.1.3}/codegen/models/types.py +0 -0
- {codegen_2-2.1.1 → codegen_2-2.1.3}/codegen/models/var.py +0 -0
|
@@ -15,6 +15,7 @@ from codegen.models.statement import (
|
|
|
15
15
|
IfStatement,
|
|
16
16
|
ImportStatement,
|
|
17
17
|
LineBreak,
|
|
18
|
+
NoStatement,
|
|
18
19
|
PythonStatement,
|
|
19
20
|
ReturnStatement,
|
|
20
21
|
SingleExprStatement,
|
|
@@ -176,6 +177,7 @@ class AST:
|
|
|
176
177
|
else:
|
|
177
178
|
for ast in self.children:
|
|
178
179
|
if ast.find_ast(id) is not None:
|
|
180
|
+
yield self
|
|
179
181
|
yield from ast.find_ast_to(id)
|
|
180
182
|
break
|
|
181
183
|
|
|
@@ -13,6 +13,11 @@ class Expr(ABC):
|
|
|
13
13
|
def to_python(self):
|
|
14
14
|
raise NotImplementedError()
|
|
15
15
|
|
|
16
|
+
def to_wrapped_python(self):
|
|
17
|
+
if isinstance(self, (ExprVar, ExprConstant)):
|
|
18
|
+
return self.to_python()
|
|
19
|
+
return f"({self.to_python()})"
|
|
20
|
+
|
|
16
21
|
|
|
17
22
|
class ExceptionExpr(Expr):
|
|
18
23
|
pass
|
|
@@ -121,9 +126,7 @@ class ExprNegation(Expr):
|
|
|
121
126
|
expr: Expr
|
|
122
127
|
|
|
123
128
|
def to_python(self):
|
|
124
|
-
|
|
125
|
-
return f"not {self.expr.to_python()}"
|
|
126
|
-
return f"not ({self.expr.to_python()})"
|
|
129
|
+
return f"not {self.expr.to_wrapped_python()}"
|
|
127
130
|
|
|
128
131
|
|
|
129
132
|
class PredefinedFn:
|
|
@@ -175,17 +178,7 @@ class PredefinedFn:
|
|
|
175
178
|
item: Expr
|
|
176
179
|
|
|
177
180
|
def to_python(self):
|
|
178
|
-
|
|
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}"
|
|
181
|
+
return f"{self.item.to_wrapped_python()} in {self.set_.to_wrapped_python()}"
|
|
189
182
|
|
|
190
183
|
@dataclass
|
|
191
184
|
class list_append(Expr):
|
|
@@ -193,7 +186,7 @@ class PredefinedFn:
|
|
|
193
186
|
item: Expr
|
|
194
187
|
|
|
195
188
|
def to_python(self):
|
|
196
|
-
return f"{self.lst.
|
|
189
|
+
return f"{self.lst.to_wrapped_python()}.append({self.item.to_python()})"
|
|
197
190
|
|
|
198
191
|
@dataclass
|
|
199
192
|
class has_item(Expr):
|
|
@@ -201,7 +194,7 @@ class PredefinedFn:
|
|
|
201
194
|
item: Expr
|
|
202
195
|
|
|
203
196
|
def to_python(self):
|
|
204
|
-
return f"
|
|
197
|
+
return f"{self.item.to_wrapped_python()} in {self.collection.to_wrapped_python()}"
|
|
205
198
|
|
|
206
199
|
@dataclass
|
|
207
200
|
class base_error(ExceptionExpr):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|