Exemple #1
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);
        }
 public Snippets(Snippets collection) : base(collection)
 {
 }