public static Snippets AsCode(this AttributeNode attr)
        {
            Position position             = new Position(new SourceContext(attr.Value));
            ParseResult <Snippets> result = _grammar.Expression(position);
            int count = result.Rest.PotentialLength();

            if (count == 0)
            {
                return(result.Value);
            }
            Snippets snippets = new Snippets(result.Value);
            Snippet  item     = new Snippet {
                Value = result.Rest.Peek(count),
                Begin = result.Rest,
                End   = result.Rest.Advance(count)
            };

            snippets.Add(item);
            return(snippets);
        }
Esempio n. 2
0
        public static Snippets AsCode(this AttributeNode attr)
        {
            //TODO: recapture original position to get correct files/offsets in the result
            var position = new Position(new SourceContext(attr.Value));
            var result   = _grammar.Expression(position);

            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);
        }