Fixed PSTL construction

This commit is contained in:
Marcell Vazquez-Chanlatte 2017-10-26 16:14:45 -07:00
parent d5985406ad
commit eda63fd6f0
3 changed files with 38 additions and 30 deletions

View file

@ -97,7 +97,13 @@ class Var(namedtuple("Var", ["coeff", "id"])):
__slots__ = ()
def __repr__(self):
return f"{self.coeff}*{self.id}"
if self.coeff == -1:
coeff_str = "-"
elif self.coeff == +1:
coeff_str = ""
else:
coeff_str = f"{self.coeff}*"
return f"{coeff_str}{self.id}"
class Interval(namedtuple('I', ['lower', 'upper'])):
@ -217,3 +223,15 @@ class Next(namedtuple('Next', ['arg']), AST):
def __hash__(self):
# TODO: compute hash based on contents
return hash(repr(self))
class Param(namedtuple('Param', ['name']), AST):
__slots__ = ()
def __repr__(self):
return self.name
def __hash__(self):
# TODO: compute hash based on contents
return hash(repr(self))