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++; } } }
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++; } } }
public NonTerminalCounts(NonTerminalCounts other) { lhsCounts = other.lhsCounts; rhsCounts = other.rhsCounts; }