Fixing loop variables

This commit is contained in:
Anthony Debucquoy
2025-04-29 21:38:31 +02:00
parent e2e058c8ac
commit 69d2bbaaf3
3 changed files with 22 additions and 5 deletions

4
spf.py
View File

@@ -19,7 +19,7 @@ class SPFInterpreter(lark.visitors.Interpreter):
old = self.variables.variables.copy()
while self.visit_children(el.children[0])[0]:
self.visit_children(el.children[1])
self.variables.variables = old.copy()
self.variables.variables = old.copy()
def for_loop(self, el):
type = el.children[0].value
@@ -30,6 +30,7 @@ class SPFInterpreter(lark.visitors.Interpreter):
except SPFException as e:
e.errorline = el.meta.line
raise e
old_inloop = self.variables.variables.copy()
target = self.visit_children(el.children[2])[0]
for i in target:
@@ -39,6 +40,7 @@ class SPFInterpreter(lark.visitors.Interpreter):
e.errorline = el.meta.line
raise e
self.visit_children(el.children[3])
self.variables.variables = old_inloop.copy()
self.variables.variables = old.copy()
def afficher(self, el):