From 32518f6fbf7f8b26db8e3b5266150a6be0b59e70 Mon Sep 17 00:00:00 2001 From: portnov Date: Sat, 13 Dec 2008 20:17:50 +0500 Subject: [PATCH] Add equations numbering --- data.py | 5 +++++ syntax.py | 2 +- 2 files changed, 6 insertions(+), 1 deletions(-) diff --git a/data.py b/data.py index 83dfea5..a58068b 100644 --- a/data.py +++ b/data.py @@ -11,6 +11,8 @@ segments = dict() conditions = [] unknowns = dict() +eqn = 0 + def trace(f): def wrapper(x): t = x @@ -368,9 +370,12 @@ class Condition(object): COND_EQ: '='} def __init__(self,kind,x,y): + global eqn self.kind = kind self.x = x self.y = y + eqn += 1 + self.number = eqn def __repr__(self): return "C:[%s %s %s]" % (self.x, self._kinds[self.kind], self.y) diff --git a/syntax.py b/syntax.py index 643657d..d1bd88a 100644 --- a/syntax.py +++ b/syntax.py @@ -58,6 +58,6 @@ if __name__ == '__main__': s = s.strip() ob = yacc.parse(s) if isinstance(ob,Condition): - print ob.equation() + print "(%s)\t%s" % (ob.number, ob.equation()) -- 1.7.2.3