public void ProductionGetHashCodeShouldProduceSameValueForSameRightHandSides() { var production1 = new Production(new NonTerminal("A"), new CharacterTerminal('a'), new NonTerminal("B")); var production2 = new Production(new NonTerminal("A"), new CharacterTerminal('a'), new NonTerminal("B")); Assert.AreEqual(production1.GetHashCode(), production2.GetHashCode()); }
public void ProductionGetHashCodeShouldProduceSameValueForSameObject() { var production = new Production(new NonTerminal("Z"), new CharacterTerminal('a'), new NonTerminal("B"), new SetTerminal('a','z')); var hashCode = production.GetHashCode(); Assert.AreEqual(hashCode, production.GetHashCode()); }
public IGrammarBuilder Production(string name, Action<IRuleBuilder> rules) { if (rules == null) _productions.Add(new Production(name)); else { var ruleBuilder = new RuleBuilder(); rules(ruleBuilder); foreach (var rule in ruleBuilder.GetRules()) { var production = new Production(name, rule.ToArray()); _productions.Add(production); } } return this; }
public void Test_Production_That_A_B_ToString_Generates_Appropriate_String() { var production = new Production("A", new NonTerminal("B")); Assert.AreEqual("A -> B", production.ToString()); }
private IGrammarLexerRule CreateGrammarLexerRule(IList<ITerminal> terminalNeighborList) { var startNonTerminal = new NonTerminal("S"); var production = new Production( startNonTerminal, terminalNeighborList.ToArray()); var grammar = new Grammar(startNonTerminal, new[] { production }, null, null); return new GrammarLexerRule(Guid.NewGuid().ToString(), grammar); }
public void ProductionToStringShouldGenerateCorrectlyFormattedString() { var production = new Production(new NonTerminal("A"), new NonTerminal("B")); Assert.AreEqual("A -> B", production.ToString()); }
public void ProductionGetHashCodeShouldProduceSameValueForEmptyProductionWithSameLeftHandSide() { var production1 = new Production(new NonTerminal("A")); var production2 = new Production(new NonTerminal("A")); Assert.AreEqual(production1.GetHashCode(), production2.GetHashCode()); }
public void ProductionGetHashCodeShouldNotProduceSameValueForDifferentLeftHandSides() { var production1 = new Production(new NonTerminal("A")); var production2 = new Production(new NonTerminal("B")); Assert.AreNotEqual(production1.GetHashCode(), production2.GetHashCode()); }