From 024b78a87fe0cb47030ed175ead0de95a00f359f Mon Sep 17 00:00:00 2001 From: "alexandre.aboulin" Date: Wed, 22 Feb 2023 13:49:01 +0100 Subject: [PATCH] fix shutting_yard --- main.py | 8 +++++++- misc/parser.py | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 0507578..9f83172 100644 --- a/main.py +++ b/main.py @@ -4,11 +4,17 @@ app = Window() app.mainloop() #from misc.parser import * -#from misc.tokenizer import * +#from misc.tokenizer import *# #while True: # calcul = str(input("Entrez votre calcul en NPI : ")) # tokens = tokenize(calcul) +# for t in tokens: +# print(t.val) # npi = shutting_yard(tokens) +# print(npi) # expression = npi2tree(npi) +# print("-----------------------") +# print(expression) +# print("-----------------------") # print(expression.evalue()) \ No newline at end of file diff --git a/misc/parser.py b/misc/parser.py index 638e094..25c98fb 100644 --- a/misc/parser.py +++ b/misc/parser.py @@ -24,7 +24,7 @@ def shutting_yard(tokens: list) -> File: output.enfiler(opertator.depiler()) assert opertator.sommet().val == "(" opertator.depiler() - if opertator.sommet().type == Token.FUNCTION: + if not opertator.est_vide() and opertator.sommet().type == Token.FUNCTION: output.enfiler(opertator.depiler()) while not opertator.est_vide():