Tp 2 compilation TP AutomatePredictive calcul les ?rst et les follow d ? une grammaire Le programme permet de construire une grammaire et de calculer les ?rst el les follows Les problèmes rencontrées le programme s ? arrête à une certaine phase de compila

TP AutomatePredictive calcul les ?rst et les follow d ? une grammaire Le programme permet de construire une grammaire et de calculer les ?rst el les follows Les problèmes rencontrées le programme s ? arrête à une certaine phase de compilation package automatepredictive import java util Scanner public class AutomatePredictive int cont char EnFirst char EnFollow char Synch char Vt 'a' 'b' 'c' 'd' char Vn 'A' 'B' 'C' 'D' static char tampon static char Ftampon static char partieGauche static char partieDroite char tabTerm char tabNonTerm public static void main String args AutomatePredictive aut new AutomatePredictive Scanner sc new Scanner System in aut construireGrammaire CTP System out println calcul de ?rst int k do tampon aut ?rst partieGauche k k while partieGauche k ' ' System out println calcul de follow do Ftampon aut follow partieGauche k k while partieGauche k ' ' public void construireGrammaire int m int noc partieDroite new char char a ?che Scanner sk new Scanner System in remplirTerminal remplirNonTerminal while tabNonTerm m ' ' System out println Partie gauche tabNonTerm m System out println Partie droite CTP a ?che sk next charAt problème je veux a ?cher une chaine de caractères partieDroite noc a ?che noc pas sure m public void remplirNonTerminal char a ? int j tabNonTerm new char Scanner sc new Scanner System in do System out println Saisir un non terminal a ? sc nextLine charAt tabNonTerm j a ? j while a ? ' ' public void remplirTerminal char a ? int i tabTerm new char Scanner sc new Scanner System in do System out println Saisir un terminal a ? sc nextLine charAt tabTerm i a ? i CTP while a ? ' ' public boolean XEpsilon int m char X 'X' char eps ' ' if partieDroite m X partieGauche m eps déclarer un char X alternative m est pour une variables m return true return false public boolean XAlpha int m char X 'X' char alpha 'f' if partieDroite m X partieGauche m alpha m return true return false CTP public void add char table char X int n table length table n X public char ?rst char X int n char Y new char char f 'f' choisir autre quue ça int i int j int noc tampon new char EnFirst ' ' EnFirst ? EnFirst est un ensemble qui va contenir les ?rsts de X if X Vt noc add EnFirst X EnFirst X noc else if X Vn noc if XEpsilon X ? est une production add EnFirst ' ' EnFirst EnFirst do tampon ?rst f CTP for int m m CTP else return false return true public char follow char X char beta 'b' à s'assurer d initialisation tampon ?rst beta int k char A 'A' char S 'S' Ftampon follow A EnFollow ' ' EnFollow ? EnFollow est un ensemble qui va contenir les follows de X if X axiome S avec S est laxiome add EnFollow ' ' EnFollow EnFollow if AalphaBeta

  • 33
  • 0
  • 0
Afficher les détails des licences
Licence et utilisation
Gratuit pour un usage personnel Aucune attribution requise
Partager
  • Détails
  • Publié le Fev 12, 2021
  • Catégorie Law / Droit
  • Langue French
  • Taille du fichier 29.1kB