Fixing variable name not showing when error
This commit is contained in:
parent
1a181095c6
commit
312f4cd125
@ -49,19 +49,19 @@ class Variables:
|
|||||||
self.trace = trace
|
self.trace = trace
|
||||||
|
|
||||||
def get(self, name):
|
def get(self, name):
|
||||||
assert name in self.variables, "la variable {name} n'éxiste pas"
|
assert name in self.variables, f"la variable {name} n'éxiste pas"
|
||||||
if self.trace:
|
if self.trace:
|
||||||
print(f"{trace_format}accède {name}{reset_format}", file=sys.stderr)
|
print(f"{trace_format}accède {name}{reset_format}", file=sys.stderr)
|
||||||
return self.variables[name].value
|
return self.variables[name].value
|
||||||
|
|
||||||
def declare(self, typ, name, value=None):
|
def declare(self, typ, name, value=None):
|
||||||
assert name not in self.variables, "la variable {name} existe déjà"
|
assert name not in self.variables, f"la variable {name} existe déjà"
|
||||||
self.variables[name] = self.Variable(typ, value)
|
self.variables[name] = self.Variable(typ, value)
|
||||||
if self.trace:
|
if self.trace:
|
||||||
print(f"{trace_format}déclare {name} = {value}{reset_format}", file=sys.stderr)
|
print(f"{trace_format}déclare {name} = {value}{reset_format}", file=sys.stderr)
|
||||||
|
|
||||||
def assign(self, name, value):
|
def assign(self, name, value):
|
||||||
assert name in self.variables, "la variable n'éxiste pas"
|
assert name in self.variables, f"la variable n'éxiste pas"
|
||||||
self.variables[name].set(value)
|
self.variables[name].set(value)
|
||||||
if self.trace:
|
if self.trace:
|
||||||
print(f"{trace_format}modifie {name} = {value}{reset_format}", file=sys.stderr)
|
print(f"{trace_format}modifie {name} = {value}{reset_format}", file=sys.stderr)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user