public class AutomateMicroLangage: AEFDAbstr
{
//-- constructeurs :
public AutomateIdentif (int end)
{
if (end >= 2 & end <= fin)
EtatFinal = end;
else
EtatFinal = fin;
FMot = sentinelle.ToString();
init_table();
}
public AutomateMicroLangage() { }
protected override int transition(int q, char car)
// par matrice de transition
{
Console.Write("(" + car + "," + q + ")");
q = table[q, car];
Console.WriteLine("--> " + q);
return q;
}
protected override void init_table()
{ //par défaut tout est non reconnu:
for (int i = non; i < fin; i++)
for (int j = 0; j < 256; j++)
table[i, j] = non;
//Les règles de l'AEFD :
for (char k = 'a'; k <= 'z'; k++)
{
table[2, k] = 5;
table[3, k] = 4;
table[6, k] = 7;
table[8, k] = 4;
}
table[1, '{'] = 2; table[2, '}'] = EtatFinal;
table[2, 'E'] = 3; table[2, 'L'] = 3;
table[4, ';'] = 2; table[5, '='] = 6;
table[7, '+'] = 8; table[7, '*'] = 8;
table[7, '-'] = 8; table[7, '%'] = 8;
table[7, '/'] = 8; table[7, ';'] = 2;
}
}
Partager