public boolean doDerivationGeneration(int depth, String parseTableFile) {
		DerivationGenerator dg = null;
		switch (config.derivGenMethod) {
		case PG:
			dg = new ScannerlessDerivGen2(config.threads);
			((ParallelDerivationGenerator) dg).setDealerLength(config.derivGenDealLength);
			break;
		}
		dg.setScannerless(grammar.scannerless);
		dg.setConfig(config);
		dg.setMonitor(monitor);
		if (config.outputAmbiguities) {
			dg.setOutputFilePrefix(grammar.name + "." + config.filterFile);
		}

		if (config.readDFA) {
			@SuppressWarnings("rawtypes")
			PDA dfa = new ItemPDA();
			dfa.deserialize(config.filename + "." + config.dfaName + ".idfa", grammar);
			dg.setDFA(dfa);
		} else {
			NFA nfa;
			nfa = buildNFA(config.precision, config.doRejects, false, config.doFollowRestrictions);
			if (!nfa.shiftsInSets) {
				nfa.moveShiftsToSets();
			}
			
			if (AmbiDexterConfig.outputGraphs) {
				nfa.toDot(config.filename + "." + AmbiDexterConfig.precisionName[config.precision] + ".gnfa.dot");
			}
			dg.build(nfa);
		}
		dg.optimize();
		dg.verify();
		
		if (AmbiDexterConfig.outputGraphs) {
			dg.getDFA().toDot("dfa.dot");
		}
		
		dg.setLength(depth);
		dg.setIncremental(config.incrementalDerivGen);
		if (parseTableFile == null) {
			dg.setParser(new SimpleSGLRParser(buildNFA(AmbiDexterConfig.LR0, config.doRejects, false, false)));
		} else {
			dg.setParser(new SGLRStub(parseTableFile));
		}
		
		return dg.detectAmbiguities(config.derivGenMethod);
	}