protected IEnumerable <ParsingEvent> DocumentWithCustomTags(params ParsingEvent[] events)
        {
            var parts = FooTag.Split(' ');
            var tags  = new TagDirective(parts[1], parts[2]);

            return(Wrap(events, DocumentStart(Explicit, null, tags), DocumentEnd(Implicit)));
        }
Example #2
0
        private VersionDirective ProcessDirectives(TagDirectiveCollection tags)
        {
            VersionDirective directive = null;
            bool             flag      = false;

            while (true)
            {
                VersionDirective currentToken = this.GetCurrentToken() as VersionDirective;
                if (currentToken != null)
                {
                    if (directive != null)
                    {
                        throw new SemanticErrorException(currentToken.Start, currentToken.End, "Found duplicate %YAML directive.");
                    }
                    if ((currentToken.Version.Major != 1) || (currentToken.Version.Minor != 1))
                    {
                        throw new SemanticErrorException(currentToken.Start, currentToken.End, "Found incompatible YAML document.");
                    }
                    directive = currentToken;
                    flag      = true;
                }
                else
                {
                    TagDirective item = this.GetCurrentToken() as TagDirective;
                    if (item == null)
                    {
                        AddTagDirectives(tags, Constants.DefaultTagDirectives);
                        if (flag)
                        {
                            this.tagDirectives.Clear();
                        }
                        AddTagDirectives(this.tagDirectives, tags);
                        return(directive);
                    }
                    if (tags.Contains(item.Handle))
                    {
                        throw new SemanticErrorException(item.Start, item.End, "Found duplicate %TAG directive.");
                    }
                    tags.Add(item);
                    flag = true;
                }
                this.Skip();
            }
        }