mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-python
synced 2026-01-15 01:52:56 +01:00
algo.ShuntingYard: Increase debug logging
Make ShuntingYard log more. Might be overkill in which case the change should be reversed. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
1e16c0ffb1
commit
ceea557a61
1 changed files with 6 additions and 4 deletions
|
|
@ -27,6 +27,9 @@ class Stack:
|
|||
def __init__(self, itemlist=[]):
|
||||
self.items = itemlist
|
||||
|
||||
def __repr__(self):
|
||||
return str(self.items)
|
||||
|
||||
def isEmpty(self):
|
||||
if self.items == []:
|
||||
return True
|
||||
|
|
@ -45,8 +48,7 @@ class Stack:
|
|||
class ShuntingYard(object): # export
|
||||
|
||||
def __init__(self, operators = None):
|
||||
self.do_debug = False
|
||||
#self.do_debug = True
|
||||
self.do_debug = prio_gets_logged(DEBUG)
|
||||
self.__ops = {}
|
||||
if operators is not None:
|
||||
for k, v in operators.items():
|
||||
|
|
@ -238,7 +240,7 @@ class ShuntingYard(object): # export
|
|||
|
||||
op = self.__ops[token]
|
||||
args = []
|
||||
self.debug("Adding %d arguments" % (op.nargs))
|
||||
self.debug(f'Adding {op.nargs} arguments: {vals}')
|
||||
for i in range(0, op.nargs):
|
||||
self.debug("Adding argument %d" % (i))
|
||||
args.append(vals.pop())
|
||||
|
|
@ -253,7 +255,7 @@ class ShuntingYard(object): # export
|
|||
if not isinstance(infix, basestring):
|
||||
return infix
|
||||
postfix = self.infix_to_postfix(infix)
|
||||
self.debug(infix, "-->", postfix)
|
||||
self.debug(f'"{infix}" --> {postfix}')
|
||||
for token in postfix:
|
||||
self.debug("Token is %s" % (token))
|
||||
return self.eval_postfix(postfix)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue