1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
#LesCommandes : liste contenant des listes 'commande' de taille 1 ou 2 selon si l'instruction commande[0] admet un paramètre ou pas
def executer(commande,pile,LesCommandes):
if len(commande)==1: #si commande contient une instruction sans paramètre (commande=['Nom_Instruction'])
if commande[0] in Liste_des_Instructions_Arithmetiques:
InstructionsArithmetiques(pile,commande[0])
elif commande[0]=='SIN':
clavier=str(input())
InstructionSIN(pile,clavier)
elif commande[0] in InstructionsSansParametres:
Dico_InstructionsSansParametres[commande[0]](pile)
else: #commande contient une instruction agissant sur un paramètre (commande=['Nom_instruction',paramètre])
if commande[0] in Liste_des_Instructions_de_Branchement:
if commande[0]=='BRANCH':
InstructionBRANCH(LesCommandes,commande) #modifie la position de 'commande' dans la liste 'LesCommandes'
executer(commande,pile,LesCommandes)
else:
Dico_InstructionsDeBranchement[commande[0]](LesCommandes,commande,pile[len(pile)-1]) #idem
executer(commande,pile,LesCommandes)
elif commande[0] in InstructionsAgissantSurDesINT+InstructionsAgissantSurDesSTR:
Dico_InstructionsParametres[commande[0]](pile,commande[1])
def executerProgrammeSource(LesCommandes):
pile=[]
commande=LesCommandes[0]
while commande != ['STOP']:
executer(commande,pile,LesCommandes)
commande=LesCommandes[LesCommandes.index(commande)+1]
else: return None |
Partager