NextCNF() public method

Generates a new, random CNF grammar
public NextCNF ( int numNonterminals, int numProductions, IList terminals, bool useNull = true ) : CNFGrammar
numNonterminals int
numProductions int
terminals IList
useNull bool
return CNFGrammar
Esempio n. 1
0
        public void RandomTesting()
        {
            var randg = new GrammarGenerator();

            int _maxNonterminals = 8;
            int _maxProductions  = 8;
            int _maxTerminals    = 20;
            int _step            = 1;

            for (int numProductions = 0; numProductions < _maxProductions; numProductions += _step)
            {
                for (int numNonterminals = 1; numNonterminals < _maxNonterminals; numNonterminals += _step)
                {
                    for (int numTerminals = 1; numTerminals < _maxTerminals; numTerminals += _step)
                    {
                        var range     = Enumerable.Range(0, numTerminals);
                        var terminals = new List <Terminal>(range.Select((x) => Terminal.Of("x" + x)));
                        Console.WriteLine("{0}, {1}, {2}", numNonterminals, numProductions, numTerminals);
                        var rg = randg.NextCNF(numNonterminals, numProductions, terminals);
                        TestGrammar(rg);
                    }
                }
            }
        }
Esempio n. 2
0
		public void RandomTesting() {
			var randg = new GrammarGenerator();

			int _maxNonterminals = 8;
			int _maxProductions = 8;
			int _maxTerminals = 20;
			int _step = 1;

			for (int numProductions = 0; numProductions < _maxProductions; numProductions += _step) {
				for (int numNonterminals = 1; numNonterminals < _maxNonterminals; numNonterminals += _step) {
					for (int numTerminals = 1; numTerminals < _maxTerminals; numTerminals += _step) {
						var range = Enumerable.Range(0, numTerminals);
						var terminals = new List<Terminal>(range.Select((x) => Terminal.Of("x" + x)));
						Console.WriteLine("{0}, {1}, {2}", numNonterminals, numProductions, numTerminals);
						var rg = randg.NextCNF(numNonterminals, numProductions, terminals);
						TestGrammar(rg);
					}
				}
			}
		}