Beispiel #1
0
        private static ISymbolicExpressionGrammar CreateTestGrammar3()
        {
            var grammar = new SimpleSymbolicExpressionGrammar();
            var x       = new SimpleSymbol("<x>", 1);

            grammar.AddSymbol(x);

            grammar.AddAllowedChildSymbol(grammar.StartSymbol, x);
            grammar.AddAllowedChildSymbol(x, x);
            return(grammar);
        }
Beispiel #2
0
        private static ISymbolicExpressionGrammar CreateTestGrammar2()
        {
            var grammar = new SimpleSymbolicExpressionGrammar();
            var x       = new SimpleSymbol("<x>", 2);
            var z       = new SimpleSymbol("<z>", 6);
            var a       = new SimpleSymbol("<a>", 1);
            var b       = new SimpleSymbol("<b>", 1);
            var c       = new SimpleSymbol("<c>", 1);
            var d       = new SimpleSymbol("<d>", 1);

            var _x = new SimpleSymbol("x", 0);
            var _y = new SimpleSymbol("y", 0);

            grammar.AddSymbol(x);
            grammar.AddSymbol(z);
            grammar.AddSymbol(a);
            grammar.AddSymbol(b);
            grammar.AddSymbol(c);
            grammar.AddSymbol(d);
            grammar.AddSymbol(_x);
            grammar.AddSymbol(_y);

            grammar.AddAllowedChildSymbol(grammar.StartSymbol, x);
            //uncommenting the line below changes the minimum expression length for the symbol <x>
            grammar.AddAllowedChildSymbol(x, z);
            grammar.AddAllowedChildSymbol(z, _x);
            grammar.AddAllowedChildSymbol(x, a);
            grammar.AddAllowedChildSymbol(a, b);
            grammar.AddAllowedChildSymbol(b, c);
            grammar.AddAllowedChildSymbol(c, d);
            grammar.AddAllowedChildSymbol(d, _y);

            return(grammar);
        }
Beispiel #3
0
        private ISymbolicExpressionTreeGrammar GenerateSimpleGrammar()
        {
            var branch = new SimpleSymbol("branch", "", 2, 2);
            var leaf   = new SimpleSymbol("leaf", "", 0, 0);

            var grammar = new SimpleSymbolicExpressionGrammar();

            grammar.AddSymbol(branch);
            grammar.AddSymbol(leaf);
            grammar.AddAllowedChildSymbol(branch, leaf);
            return(grammar.CreateExpressionTreeGrammar());;
        }
Beispiel #4
0
        private static ISymbolicExpressionGrammar CreateTestGrammar6()
        {
            var grammar = new SimpleSymbolicExpressionGrammar();
            var x       = new SimpleSymbol("<x>", 1);
            var s       = new SimpleSymbol("<s>", 1);
            var a       = new SimpleSymbol("<a>", 1);
            var b       = new SimpleSymbol("<b>", 1);
            var c       = new SimpleSymbol("<c>", 1);
            var d       = new SimpleSymbol("<d>", 1);
            var e       = new SimpleSymbol("<e>", 1);

            var _x = new SimpleSymbol("x", 0);
            var _y = new SimpleSymbol("y", 0);

            grammar.AddSymbol(x);
            grammar.AddSymbol(s);
            grammar.AddSymbol(a);
            grammar.AddSymbol(b);
            grammar.AddSymbol(c);
            grammar.AddSymbol(d);
            grammar.AddSymbol(e);
            grammar.AddSymbol(_x);
            grammar.AddSymbol(_y);

            grammar.AddAllowedChildSymbol(grammar.StartSymbol, x);
            grammar.AddAllowedChildSymbol(x, s);
            grammar.AddAllowedChildSymbol(x, _x);
            grammar.AddAllowedChildSymbol(s, a);
            grammar.AddAllowedChildSymbol(a, b);
            grammar.AddAllowedChildSymbol(a, c);
            grammar.AddAllowedChildSymbol(b, x);
            grammar.AddAllowedChildSymbol(c, d);
            grammar.AddAllowedChildSymbol(d, e);
            grammar.AddAllowedChildSymbol(e, _y);

            return(grammar);
        }
Beispiel #5
0
        private static ISymbolicExpressionGrammar CreateTestGrammar5()
        {
            var grammar = new SimpleSymbolicExpressionGrammar();
            var x       = new SimpleSymbol("<x>", 1);
            var y       = new SimpleSymbol("<y>", 1);
            var _x      = new SimpleSymbol("x", 0);

            grammar.AddSymbol(x);
            grammar.AddSymbol(y);
            grammar.AddSymbol(_x);

            grammar.AddAllowedChildSymbol(grammar.StartSymbol, x);
            grammar.AddAllowedChildSymbol(x, x);
            grammar.AddAllowedChildSymbol(x, y);
            grammar.AddAllowedChildSymbol(y, x);
            grammar.AddAllowedChildSymbol(y, y);
            grammar.AddAllowedChildSymbol(y, _x);
            return(grammar);
        }