public compiler(string gFile = null, string inFile = null, int cType = 0) { //compiler tasks, must do in order grammarFile = gFile; inputFile = inFile; compilerType = cType; init(grammarFile, inFile); switch (cType) { case (0): //LL_Grammar LL_0_ produceLL_0 = new LL_0_(productionDict, productions, nullables, tokens, ref LLTable, ref productionTreeRoot, inputFile != null); break; case (1): //LR_Grammar SLR_1_ produceSLR_1 = new SLR_1_(productionDict, productions, nullables, Follows, tokens, ref LRTable, ref productionTreeRoot, ref startState, inputFile != null); break; } }
public void produceTreeRoot() { switch (compilerType) { case (0): //LL_Grammar LL_0_ produceLL_0 = new LL_0_(productionDict, productions, nullables, tokens, ref LLTable, ref productionTreeRoot, inputFile != null); break; case (1): //LR_Grammar SLR_1_ produceSLR_1 = new SLR_1_(productionDict, productions[0].lhs, Follows, tokens, ref LRTable, ref productionTreeRoot, ref startState, inputFile != null); break; case (2): GLR produceGLR = new GLR(productionDict, productions[0].lhs, Follows, tokens, ref GLRTable, ref productionTreeRoot, ref startState, inputFile != null); break; default: throw new Exception("Invalid Grammar Parse type!! Please Specify cType = {0,1,2} = {LL(0), SLR(1), GLR}!! Got cType: " + compilerType); } }