codegen-2 2.1.2__py3-none-any.whl → 2.1.3__py3-none-any.whl
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/models/ast.py +0 -2
- codegen/models/expr.py +9 -16
- {codegen_2-2.1.2.dist-info → codegen_2-2.1.3.dist-info}/METADATA +1 -1
- {codegen_2-2.1.2.dist-info → codegen_2-2.1.3.dist-info}/RECORD +6 -6
- {codegen_2-2.1.2.dist-info → codegen_2-2.1.3.dist-info}/LICENSE +0 -0
- {codegen_2-2.1.2.dist-info → codegen_2-2.1.3.dist-info}/WHEEL +0 -0
codegen/models/ast.py
CHANGED
|
@@ -213,8 +213,6 @@ class AST:
|
|
|
213
213
|
return VarScope(self.id, len(self.children))
|
|
214
214
|
|
|
215
215
|
def _add_stmt(self, stmt: Statement):
|
|
216
|
-
if isinstance(stmt, NoStatement):
|
|
217
|
-
return self
|
|
218
216
|
if self._is_frozen:
|
|
219
217
|
raise Exception("The AST is frozen and cannot be modified")
|
|
220
218
|
ast = AST(self.next_child_id(), self.prog, stmt)
|
codegen/models/expr.py
CHANGED
|
@@ -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):
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
codegen/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
codegen/models/__init__.py,sha256=j__FrDdGOILIo9jqEDElL3YP69h0xkL2SqrMxSqgpTc,457
|
|
3
|
-
codegen/models/ast.py,sha256=
|
|
4
|
-
codegen/models/expr.py,sha256=
|
|
3
|
+
codegen/models/ast.py,sha256=pYdZZgaIgFuLnJznz4kR6KZ1ca1pvRzwACdXiMskiKo,7750
|
|
4
|
+
codegen/models/expr.py,sha256=bGc-ZTbgGLmepPs-Zef4VP07WMfvCQb2AFeM7JDPKHc,5032
|
|
5
5
|
codegen/models/program.py,sha256=6ggzINtk1i9WeSFsiI8Qa6TiNJEafXbXwYqKoq4k_xA,4471
|
|
6
6
|
codegen/models/statement.py,sha256=egKy8wAutHnOqZbRFZGSASQSpjQWpFc4l9-P5mTjx-k,2899
|
|
7
7
|
codegen/models/types.py,sha256=Dl-wzGB1viA7EZj2CuTrZe1F133Q6ENVr_yRqxhde8M,178
|
|
8
8
|
codegen/models/var.py,sha256=3T-GEv5z6T31HfAUOJ7TTjN3WF3ejY3rfRNvrIUfLP8,1771
|
|
9
|
-
codegen_2-2.1.
|
|
10
|
-
codegen_2-2.1.
|
|
11
|
-
codegen_2-2.1.
|
|
12
|
-
codegen_2-2.1.
|
|
9
|
+
codegen_2-2.1.3.dist-info/LICENSE,sha256=Ea6itrykT9pvPGd0Kgl6FbrqdDwKswPZJmXMFVjUBqw,1064
|
|
10
|
+
codegen_2-2.1.3.dist-info/METADATA,sha256=hhR-fWoE9phVJFhFgieS3m2rxeRbJtMF18vvM87B6YQ,436
|
|
11
|
+
codegen_2-2.1.3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
12
|
+
codegen_2-2.1.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|