Exemplo n.º 1
0
        public override Snippets ParseFragment(Position begin, Position end)
        {
            var result = _grammar.Expression(begin.Constrain(end));

            var unparsedLength = result.Rest.PotentialLength();

            if (unparsedLength == 0)
            {
                return(result.Value);
            }

            var snippets = new Snippets(result.Value);

            snippets.Add(new Snippet
            {
                Value = result.Rest.Peek(unparsedLength),
                Begin = result.Rest,
                End   = result.Rest.Advance(unparsedLength)
            });

            return(snippets);
        }