static SimpleExpressionGrammar()
 {
     var digit = new DigitTerminal();
     ProductionExpression E = "E";
     E.Rule =
         E + "+" + E
         | E + "*" + E
         | digit;
     _innerGrammar = new GrammarExpression(E, new[] { E }).ToGrammar();
 }
Example #2
0
 public void Test_DigitTerminal_That_IsMatch_Returns_True_When_Number()
 {
     var digitTerminal = new DigitTerminal();
     Assert.IsTrue (digitTerminal.IsMatch('0'));
 }
Example #3
0
 public void Test_DigitTerminal_That_IsMatch_Returns_False_When_Letter()
 {
     var digitTerminal = new DigitTerminal();
     Assert.IsFalse(digitTerminal.IsMatch('a'));
 }
Example #4
0
 public void DigitTerminalGivenNumberShouldMatch()
 {
     var digitTerminal = new DigitTerminal();
     Assert.IsTrue(digitTerminal.IsMatch('0'));
 }
Example #5
0
 public void DigitTerminalGivenLetterShouldFailMatch()
 {
     var digitTerminal = new DigitTerminal();
     Assert.IsFalse(digitTerminal.IsMatch('a'));
 }
Example #6
0
 public ITerminalBuilder Digit()
 {
     var digitTerminal = new DigitTerminal();
     _terminals.Add(digitTerminal);
     return this;
 }