示例#1
0
bool Etat23::transition(Automate & automate, Symbole * s ){
	int idSym = *s ; 
	switch (idSym) {
		case pf :
		case add :
		case moins :
		case fois :
		case divise :
		case pv :
			//Reduction r20 : F -> num
		{
			Num* num= (Num*) automate.getNthSymbole(0);
			num->setF();

			automate.popAndDeleteState();
			automate.popSymbole();

			automate.reduction(num);
			break;
		}
			
		default : break;
	}
	return false;
}
示例#2
0
bool Etat20::transition(Automate & automate, Symbole * s ){
	int idSym = *s ; 
	switch (idSym) {
		case fois :
			automate.decalage(s, new Etat33("33"));
		break;
		case divise :
			automate.decalage(s, new Etat34("34"));
		break;
		case pf :
		case add :
		case moins :
		case pv :
		{
			//TODO : r16 E → T
			Expression* expr = (Expression*)automate.getNthSymbole(0);
			expr->setE();

			automate.popAndDeleteState();
			automate.popSymbole();

			automate.reduction(expr);
			break;
		}
		case OM : 
			automate.decalage(s, new Etat32("32"));
		break;
		default:
		break;
	}
	return false;
}
示例#3
0
bool Etat41::transition(Automate & automate, Symbole * s ){
	int idSym = *s ; 
	switch (idSym) {
		// R21 : F -> ( E )
		case pf :
		case add :
		case moins :
		case fois :
		case divise :
		case pv :
		{
			int nbSymboles = 3;
			Expression* expr = (Expression*) automate.getNthSymbole(1);
			OpParenthese* opPar = new OpParenthese(expr);

			for (unsigned int i = 0; i < nbSymboles; ++i)
			{
				automate.popAndDeleteState();
			}

			automate.popAndDeleteSymbole();
			automate.popSymbole(); // on garde E
			automate.popAndDeleteSymbole();

			automate.reduction(opPar);
		}
		break;
		default:

		break;
	}
	return false;
}
示例#4
0
bool Etat16::transition(Automate & automate, Symbole * s ){
	int idSym = *s ; 
	switch (idSym) {
		case id :
		case r :
		case w : 
		case dollar :
		{
			// TODO r10 LI → LI I pv
			int nbSymboles = 3;
			Instruction* inst = (Instruction*) automate.getNthSymbole(1);
			BlocInstruction* blocInst = (BlocInstruction*) automate.getNthSymbole(2);
			blocInst->addInstruction(inst);

			// réduction manuelle ici
			for (unsigned int i = 0; i < nbSymboles; ++i) 
			{
				automate.popAndDeleteState();
			}

			automate.popAndDeleteSymbole();
			automate.popSymbole(); // on garde I
			automate.popSymbole(); // on le pop sans le supprimer car il s'agit de blocDec

			automate.reduction(blocInst); // réduction manuelle
			break;
		}
		default : break;
	}
	return false;
}
示例#5
0
bool Etat38::transition(Automate & automate, Symbole * s ){
	int idSym = *s ; 
	switch (idSym) {
		case v :
		case pv :
		{
			//Regle R8 : V → V v id
			int nbSymboles = 3;
			Identificateur* identif = (Identificateur*) automate.getNthSymbole(0);
			DeclarationVar* declaV = ((DeclarationVar*) automate.getNthSymbole(2));
			declaV->addIdentificateur(identif);

			// check doublons
			bool ok = Identificateur::checkDouble((string)*identif);
			if (!ok)
			{
				return false;
			}

			// réduction manuelle ici
			for (unsigned int i = 0; i < nbSymboles; ++i) 
			{
				automate.popAndDeleteState();
			}

			automate.popSymbole(); // id
			automate.popAndDeleteSymbole();
			automate.popSymbole(); // on le pop sans le supprimer car il s'agit de declaV

			automate.reduction(declaV); // réduction manuelle
			break;
		}
		default : break;
	}
	return false;
}