Exemplo n.º 1
0
        public KeywordTokenizer(LanguageConfig languageConfig) : base(languageConfig)
        {
            var candidatesMap = languageConfig.Syntax.KeywordsMap
                                .ToDictionary(x => x.Value, x => x.Key);

            _keywordsTrie = SearchTrie <KeywordBase> .Create(languageConfig.Syntax.KeywordCaseSensitive, candidatesMap);
        }
Exemplo n.º 2
0
        public void Should_work_with_basic_test_cases(TestCase testCase)
        {
            var trie = SearchTrie <Person> .Create(testCase.CaseSensitive, testCase.Map);

            var reader = new LexerStringReader(testCase.Query, testCase.StartPosition);

            var found = trie.TryFind(reader, out var person, out var readLength);

            found.Should().Be(testCase.ShouldBeFound);
            person.Should().Be(testCase.ExpectedValue);
            readLength.Should().Be(testCase.ExpectedReadLength);
        }