drop unecessary dt

This commit is contained in:
Marcell Vazquez-Chanlatte 2017-02-25 23:27:06 -08:00
parent 877523d531
commit 21ff366d24

View file

@ -48,7 +48,7 @@ const_or_unbound = unbound / const
lineq = terms _ op _ const_or_unbound lineq = terms _ op _ const_or_unbound
term = coeff? var term = coeff? var
coeff = (dt __ "*" __)? const __ "*" __ coeff = ((dt __ "*" __)? const __ "*" __) / (dt __ "*")
terms = (term __ pm __ terms) / term terms = (term __ pm __ terms) / term
var = id time? var = id time?
@ -150,9 +150,12 @@ class STLVisitor(NodeVisitor):
return ast.Var(coeff=c, id=iden, time=time) return ast.Var(coeff=c, id=iden, time=time)
def visit_coeff(self, _, children): def visit_coeff(self, _, children):
dt, coeff, *_ = children dt, coeff, *_ = children[0]
dt = dt[0][0] if dt else Number(1) if not isinstance(dt, Symbol):
return dt * coeff dt = dt[0][0] if dt else Number(1)
return dt * coeff
else:
return dt
def visit_terms(self, _, children): def visit_terms(self, _, children):
if isinstance(children[0], list): if isinstance(children[0], list):