Browse Source

fix shutting_yard

master
alexandre.aboulin 2 years ago
parent
commit
024b78a87f
  1. 8
      main.py
  2. 2
      misc/parser.py

8
main.py

@ -4,11 +4,17 @@ app = Window()
app.mainloop() app.mainloop()
#from misc.parser import * #from misc.parser import *
#from misc.tokenizer import * #from misc.tokenizer import *#
#while True: #while True:
# calcul = str(input("Entrez votre calcul en NPI : ")) # calcul = str(input("Entrez votre calcul en NPI : "))
# tokens = tokenize(calcul) # tokens = tokenize(calcul)
# for t in tokens:
# print(t.val)
# npi = shutting_yard(tokens) # npi = shutting_yard(tokens)
# print(npi)
# expression = npi2tree(npi) # expression = npi2tree(npi)
# print("-----------------------")
# print(expression)
# print("-----------------------")
# print(expression.evalue()) # print(expression.evalue())

2
misc/parser.py

@ -24,7 +24,7 @@ def shutting_yard(tokens: list) -> File:
output.enfiler(opertator.depiler()) output.enfiler(opertator.depiler())
assert opertator.sommet().val == "(" assert opertator.sommet().val == "("
opertator.depiler() opertator.depiler()
if opertator.sommet().type == Token.FUNCTION: if not opertator.est_vide() and opertator.sommet().type == Token.FUNCTION:
output.enfiler(opertator.depiler()) output.enfiler(opertator.depiler())
while not opertator.est_vide(): while not opertator.est_vide():

Loading…
Cancel
Save