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()
#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())

2
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():

Loading…
Cancel
Save