Exemplo n.º 1
0
        public void IsNullableTest()
        {
            var grammar = new Grammar();

            var S = grammar.Symbols.Add("S");
            var a = grammar.Symbols.Add("a");
            var b = grammar.Symbols.Add("b");
            var A = grammar.Symbols.Add("A");
            var B = grammar.Symbols.Add("B");

            grammar.Start = S;
            grammar.Productions.Define(S, new[] { b, A });
            grammar.Productions.Define(A, new[] { a, A, B });
            grammar.Productions.Define(A, new Symbol[0]);
            grammar.Productions.Define(B, new Symbol[0]);

            var target = new RuntimeGrammar(grammar);

            Assert.IsTrue(target.IsNullable(A.Index));
            Assert.IsTrue(target.IsNullable(B.Index));

            Assert.IsFalse(target.IsNullable(a.Index));
            Assert.IsFalse(target.IsNullable(b.Index));
            Assert.IsFalse(target.IsNullable(S.Index));
        }
Exemplo n.º 2
0
 public void Init()
 {
     this.runtimeGrammar = new RuntimeGrammar(data.Grammar);
     this.allocator      = new ResourceAllocator(runtimeGrammar);
 }
Exemplo n.º 3
0
 public ResourceAllocator(RuntimeGrammar grammar)
 {
     this.grammar = grammar;
 }
Exemplo n.º 4
0
 public ResourceAllocator(RuntimeGrammar grammar)
 {
     this.grammar = grammar;
 }