Example #1
0
 public DfaLexeme(IDfaLexerRule dfaLexerRule, int position)
 {
     LexerRule      = dfaLexerRule;
     Position       = position;
     _stringBuilder = SharedPools.Default <StringBuilder>().AllocateAndClear();
     _currentState  = dfaLexerRule.Start;
 }
Example #2
0
 private static void AssertLexerRuleMatches(IDfaLexerRule lexerRule, string input)
 {
     var lexeme = _factory.Create(lexerRule);
     for (int i = 0; i < input.Length; i++)
         Assert.IsTrue(lexeme.Scan(input[i]), $"character '{input[i]}' not recognized at position {i}.");
     Assert.IsTrue(lexeme.IsAccepted(), $"input {input} not accepted.");
 }
Example #3
0
 public void Reset(IDfaLexerRule dfaLexerRule)
 {
     _capture = null;
     if(IsStringBuilderAllocated())
         _stringBuilder.Clear();
     _currentState = dfaLexerRule.Start;
     LexerRule = dfaLexerRule;
 }
Example #4
0
        private static void AssertLexerRuleMatches(IDfaLexerRule lexerRule, string input)
        {
            var lexeme = _factory.Create(lexerRule, 0);

            for (int i = 0; i < input.Length; i++)
            {
                Assert.IsTrue(lexeme.Scan(input[i]), $"character '{input[i]}' not recognized at position {i}.");
            }
            Assert.IsTrue(lexeme.IsAccepted(), $"input {input} not accepted.");
        }
Example #5
0
 public void Reset(IDfaLexerRule dfaLexerRule)
 {
     _capture = null;
     if (IsStringBuilderAllocated())
     {
         _stringBuilder.Clear();
     }
     _currentState = dfaLexerRule.Start;
     LexerRule     = dfaLexerRule;
 }
Example #6
0
 public DfaLexeme(IDfaLexerRule dfaLexerRule)
 {
     LexerRule = dfaLexerRule;
     _stringBuilder = SharedPools.Default<StringBuilder>().AllocateAndClear();
     _currentState = dfaLexerRule.Start;
 }