mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-03-22 08:50:24 +00:00
19 lines
484 B
Python
19 lines
484 B
Python
|
|
import MathParser
|
||
|
|
|
||
|
|
class MyMathParser(MathParser.MathParser):
|
||
|
|
def addfunc(self, left, plus, right):
|
||
|
|
print "%d + %d" % (left, right)
|
||
|
|
return left + right
|
||
|
|
def parenfunc(self, lp, expr, rp):
|
||
|
|
print "handling parens"
|
||
|
|
return expr
|
||
|
|
def timesfunc(self, left, times, right):
|
||
|
|
print "%d * %d" % (left, right)
|
||
|
|
return left * right
|
||
|
|
|
||
|
|
def _test():
|
||
|
|
p = MyMathParser()
|
||
|
|
p.parse("4 * (3 + 2 * 5)", 1)
|
||
|
|
|
||
|
|
if __name__=='__main__':
|
||
|
|
_test()
|