void removeUnitaryProductionsTest(){ printf("\nTesting Remove Unitary Productions Method \n"); printGrammar(g1); removeUnitaryProductions(g1); printGrammar(g1); printf("productions quant: %d\n", getQuant(getProductions(g1))); }
void grammarToAutomata(){ printf("\nTesting Grammar to Automata Conversion "); printGrammar(g1); formalize(g1); printf("\nFormalized"); printGrammar(g1); AutomataADT a = toAutomata(g1); printAutomata(a); printf("productions quant: %d\n", getQuant(getProductions(g1))); }
void grammar4Test(){ //Gramatica4 = ({S, B, C}, {a,b,c}, S, //{S->B | a, //B->cS | \, //C->bC | \}) GrammarADT grammar4 = newGrammar(); grammar4 = newGrammar(); setDistinguished(grammar4, 'S'); char * nonterminals1 = malloc(sizeof(char)*3); nonterminals1[0] = 'S'; nonterminals1[1] = 'B'; nonterminals1[2] = 'C'; setNonTerminals(grammar4,nonterminals1,3); char * term1 = malloc(sizeof(char)*3); term1[0] = 'a'; term1[1] = 'b'; term1[2] = 'c'; setTerminals(grammar4,term1,3); ProductionADT prod1 = newProduction('S',LAMDA,'B'); ProductionADT prod2 = newProduction('S','a',LAMDA); ProductionADT prod3 = newProduction('B','c','S'); ProductionADT prod4 = newProduction('B',LAMDA, LAMDA); ProductionADT prod5 = newProduction('C', 'b', 'C'); ProductionADT prod6 = newProduction('C',LAMDA, LAMDA); //ProductionsADT productions1 = newProductions(0); ProductionsADT productions1 = newProductions(6); setProduction(productions1,0,prod1); setProduction(productions1,1,prod2); setProduction(productions1,2,prod3); setProduction(productions1,3,prod4); setProduction(productions1,4,prod5); setProduction(productions1,5,prod6); /*addProduction(productions1,prod1); addProduction(productions1,prod2); addProduction(productions1,prod3); addProduction(productions1,prod4);*/ setProductions(grammar4,productions1); printf("Before Nomalization\n"); printGrammar(grammar4); /*Conversion*/ AutomataADT automata1 = toAutomata(grammar4); printf("After Nomalization\n"); printGrammar(grammar4); printAutomata(automata1); }
void grammar1Test(){ //G1 = ({A, B, C}, {a, b, c},A, {A -> aB|c, B -> aA|b}) /*Initialization*/ GrammarADT grammar1 = newGrammar(); grammar1 = newGrammar(); setDistinguished(grammar1, 'A'); char * nonterminals1 = malloc(sizeof(char)*3); nonterminals1[0] = 'A'; nonterminals1[1] = 'B'; nonterminals1[2] = 'C'; setNonTerminals(grammar1,nonterminals1,3); char * term1 = malloc(sizeof(char)*3); term1[0] = 'a'; term1[1] = 'b'; term1[2] = 'c'; setTerminals(grammar1,term1,3); ProductionADT prod1 = newProduction('A','a','B'); ProductionADT prod2 = newProduction('A','c',LAMDA); ProductionADT prod3 = newProduction('B','a','A'); ProductionADT prod4 = newProduction('B',LAMDA,'b'); //ProductionsADT productions1 = newProductions(0); ProductionsADT productions1 = newProductions(4); setProduction(productions1,0,prod1); setProduction(productions1,1,prod2); setProduction(productions1,2,prod3); setProduction(productions1,3,prod4); /*addProduction(productions1,prod1); addProduction(productions1,prod2); addProduction(productions1,prod3); addProduction(productions1,prod4);*/ setProductions(grammar1,productions1); printf("Before Nomalization\n"); printGrammar(grammar1); /*Conversion*/ AutomataADT automata1 = toAutomata(grammar1); printf("After Nomalization\n"); printGrammar(grammar1); printAutomata(automata1); }
void addProductionsTest(){ printf("\nTesting Add Productions Method \n"); addProduction(getProductions(g1), newProduction('S',LAMDA,'A')); addProduction(getProductions(g1), newProduction('B',LAMDA,'C')); addProduction(getProductions(g1), newProduction('C',LAMDA,'D')); printGrammar(g1); printf("productions quant: %d\n", getQuant(getProductions(g1))); }
void basicTest(){ printf("Testing Grammar Structures / Basic \n"); /*remove non terminals and terminals that are no longer there */ actualizeTerminals(g1); actualizeNonTerminals(g1); printGrammar(g1); printf("productions quant: %d\n", getQuant(getProductions(g1))); }
void removeParticularProductionTest(){ printf("\nTesting Remove Particular Productions Method \n"); removeParticularProduction(getProductions(g1), newProduction('A',LAMDA,'b')); /*remove non terminals and terminals that are no longer there */ actualizeTerminals(g1); actualizeNonTerminals(g1); printGrammar(g1); printf("productions quant: %d\n", getQuant(getProductions(g1))); }
void removeProductionsTest(){ printf("\nTesting Remove Productions Method \n"); printf("to remove: all starting with 'A' \n"); removeProduction(getProductions(g1),'A'); /*remove non terminals and terminals that are no longer there */ actualizeTerminals(g1); actualizeNonTerminals(g1); printGrammar(g1); printf("productions quant: %d\n", getQuant(getProductions(g1))); }
void LSystem::displaySystem() const { cout << "levels: " << levels << endl; cout << "startSymbol: " << startSymbol << endl; cout << "startX: " << startX << endl; cout << "startY: " << startY << endl; cout << "angle: " << angle << endl; cout << "facing: " << state.facing << endl; cout << "strokeLength: " << strokeLength << endl; cout << "strokeWidth: " << strokeWidth << endl; cout << "strokecolor: " << strokeColor << endl; printGrammar(); }
void convertToRightTest(){ printf("\nTesting Convert To Right Method\n"); convertToRight(g1); printGrammar(g1); printf("productions quant: %d\n", getQuant(getProductions(g1))); }
void removeOnlyRightTerminalsTest(){ printf("\nTesting Remove Only Right Terminals Method \n"); printGrammar(g1); removeOnlyRightTerminals(g1); printGrammar(g1); }