Exemplo n.º 1
0
        public void ReadSuccess(string input)
        {
            var factory    = new DigitLexerFactory(new ValueRangeLexerFactory());
            var digitLexer = factory.Create();

            using (var scanner = new TextScanner(new StringTextSource(input)))
            {
                var result = digitLexer.Read(scanner);
                Assert.NotNull(result);
                Assert.True(result.Success);
                Assert.NotNull(result.Element);
                Assert.Equal(input, result.Element.Text);
            }
        }
Exemplo n.º 2
0
        public void ReadSuccess(string input)
        {
            var valueRangeLexerFactory  = new ValueRangeLexerFactory();
            var digitLexerFactory       = new DigitLexerFactory(valueRangeLexerFactory);
            var terminalLexerFactory    = new TerminalLexerFactory();
            var alternativeLexerFactory = new AlternativeLexerFactory();
            var factory = new HexadecimalDigitLexerFactory(digitLexerFactory, terminalLexerFactory, alternativeLexerFactory);
            var lexer   = factory.Create();

            using (var scanner = new TextScanner(new StringTextSource(input)))
            {
                var result = lexer.Read(scanner);
                Assert.NotNull(result);
                Assert.True(result.Success);
                Assert.NotNull(result.Element);
                Assert.Equal(input, result.Element.Text);
            }
        }