Exemple #1
0
        public void AddNonTerminalCounts(Rule rule)
        {
            var lhs = rule.Name.NonTerminal;

            if (!nonTerminalCounts.ContainsKey(lhs))
            {
                nonTerminalCounts[lhs] = new NonTerminalCounts();
            }

            nonTerminalCounts[lhs].lhsCounts++;

            if (!rule.IsEpsilonRule())
            {
                int i = 0;
                foreach (var item in rule.Production)
                {
                    var rhs = item.NonTerminal;
                    if (!nonTerminalCounts.ContainsKey(rhs))
                    {
                        nonTerminalCounts[rhs] = new NonTerminalCounts();
                    }
                    nonTerminalCounts[rhs].rhsCounts++;

                    if (!RHSDictionary.ContainsKey(rhs))
                    {
                        RHSDictionary[rhs] = new HashSet <Tuple <int, int> >();
                    }
                    RHSDictionary[rhs].Add(Tuple.Create(rule.Number, i));
                    i++;
                }
            }
        }
Exemple #2
0
        public void AddNonTerminalCounts(Rule rule)
        {
            var lhs = rule.Name.NonTerminal;

            if (!nonTerminalCounts.ContainsKey(lhs))
                nonTerminalCounts[lhs] = new NonTerminalCounts();

            nonTerminalCounts[lhs].lhsCounts++;

            if (!rule.IsEpsilonRule())
            {
                foreach (var item in rule.Production)
                {
                    var rhs = item.NonTerminal;
                    if (!nonTerminalCounts.ContainsKey(rhs))
                        nonTerminalCounts[rhs] = new NonTerminalCounts();
                    nonTerminalCounts[rhs].rhsCounts++;
                }
            }
        }
Exemple #3
0
 public NonTerminalCounts(NonTerminalCounts other)
 {
     lhsCounts = other.lhsCounts;
     rhsCounts = other.rhsCounts;
 }
Exemple #4
0
 public NonTerminalCounts(NonTerminalCounts other)
 {
     lhsCounts = other.lhsCounts;
     rhsCounts = other.rhsCounts;
 }