Exemplo n.º 1
0
        public void Reconhece_ListaValida_AoAvaliar()
        {
            var charList = new[]
            {
                new CharGrammarElement('h'),
                new CharGrammarElement('h'),
                new CharGrammarElement('h')
            };

            var grammar   = new CharListGrammarElement(charList);
            var extractor = TokenExtractor.FromString("hhh");
            var token     = grammar.Eval(extractor);

            Assert.NotNull(token);
            Assert.Equal("hhh", (string)token.Content);
        }
Exemplo n.º 2
0
        public void Consome_SoOsCaracteres_Necessarios()
        {
            var charList = new[]
            {
                new CharGrammarElement('h'),
                new CharGrammarElement('h'),
                new CharGrammarElement('h')
            };

            var grammar   = new CharListGrammarElement(charList);
            var extractor = TokenExtractor.FromString("hhhhhh");
            var posBegin  = extractor.SaveCursor();
            var token     = grammar.Eval(extractor);

            Assert.NotNull(token);
            Assert.Equal("hhh", (string)token.Content);
            Assert.Equal(0, posBegin.Position);
            Assert.Equal(3, extractor.SaveCursor().Position);
        }