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:
Jan Lindemann 2025-07-11 10:46:19 +02:00
commit ceea557a61

View file

@ -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)