Esempio n. 1
0
        public void WithSplittingOnPunctuation_ShouldSetTheSplitOnPunctuationPropertyCorrectly(bool setting)
        {
            var builder = new TokenizerBuilder();

            builder.SplitOnPunctuation(setting);
            builder.Build().Should().BeOfType <Tokenizer>().Subject.Options.SplitOnPunctuation.Should().Be(setting);
        }
Esempio n. 2
0
        public static Tokenizer <AsmToken> Create()
        {
            var tokenizerBuilder = new TokenizerBuilder <AsmToken>()
                                   .Ignore(Span.WhiteSpace)
                                   .Match(Span.EqualTo("MOVE"), AsmToken.Move, true)
                                   .Match(Span.EqualTo("LOAD"), AsmToken.Load, true)
                                   .Match(Span.EqualTo("STORE"), AsmToken.Store, true)
                                   .Match(Span.EqualTo("ADD"), AsmToken.Add, true)
                                   .Match(Span.EqualTo("SUB"), AsmToken.Subtract, true)
                                   .Match(Span.EqualTo("MULT"), AsmToken.Multiply, true)
                                   .Match(Span.EqualTo("BEQ"), AsmToken.BranchEqual, true)
                                   .Match(Span.EqualTo("BLT"), AsmToken.BranchLessThan, true)
                                   .Match(Span.EqualTo("BLE"), AsmToken.BranchLessThanOrEqualTo, true)
                                   .Match(Character.EqualTo(':'), AsmToken.Colon)
                                   .Match(Character.EqualTo('+'), AsmToken.Plus)
                                   .Match(Character.EqualTo('#'), AsmToken.Hash)
                                   .Match(Character.EqualTo(','), AsmToken.Comma)
                                   .Match(Character.EqualTo('\n'), AsmToken.NewLine)
                                   .Match(Span.Regex(@"\d*"), AsmToken.Number)
                                   .Match(Span.Regex(@"R\d*"), AsmToken.Register, true)
                                   .Match(Span.Regex(@"\w[\w\d]*"), AsmToken.Text, true);


            return(tokenizerBuilder.Build());
        }
Esempio n. 3
0
        public void WithAdditionalSplitCharacters_ShouldSetAdditionalSplitCharactersCorrectly()
        {
            var builder = new TokenizerBuilder();

            builder.SplitOnCharacters('$', '%', '|');
            builder.Build().Should().BeOfType <Tokenizer>().Subject.Options.AdditionalSplitCharacters.Should().BeEquivalentTo(new[] { '$', '%', '|' });
        }
Esempio n. 4
0
        public void WithAccentInsensitivity_ShouldSetTheAccentInsensitivityPropertyCorrectly(bool setting)
        {
            var builder = new TokenizerBuilder();

            builder.AccentInsensitive(setting);
            builder.Build().Should().BeOfType <Tokenizer>().Subject.Options.AccentInsensitive.Should().Be(setting);
        }
Esempio n. 5
0
        public void WithStemming_ShouldSetTheStemmingPropertyCorrectly(bool setting)
        {
            var builder = new TokenizerBuilder();

            builder.WithStemming(setting);
            builder.Build().Should().BeOfType <Tokenizer>().Subject.Options.Stemming.Should().Be(setting);
        }
Esempio n. 6
0
        public void WithoutApplyingAnyOptions_ShouldSetDefaultsCorrectly()
        {
            var builder = new TokenizerBuilder();

            builder.Build().Should().BeOfType <Tokenizer>().Subject
            .Options.Should().BeEquivalentTo(expectedDefaultOptions);
        }
Esempio n. 7
0
        public void WithSpecifiedTokenizerFactory_ShouldReturnConfiguredType()
        {
            var builder = new TokenizerBuilder();

            builder.WithFactory(o => new FakeTokenizer(o));
            builder.Build().Should().BeOfType <FakeTokenizer>().Subject
            .Options.Should().BeEquivalentTo(expectedDefaultOptions);
        }
Esempio n. 8
0
 public Tokenizer <TokenType> GetTokenizer() => syntaxBuilder.Build();
Esempio n. 9
0
        public void WithoutChangingTokenizerFactory_ShouldBuildTokenizer()
        {
            var builder = new TokenizerBuilder();

            builder.Build().Should().BeOfType <Tokenizer>();
        }