示例#1
0
        private ParsingEvent ParseDocumentStart(bool isImplicit)
        {
            if (!isImplicit)
            {
                while (this.GetCurrentToken() is DocumentEnd)
                {
                    this.Skip();
                }
            }
            if (isImplicit && (!(this.GetCurrentToken() is VersionDirective) && (!(this.GetCurrentToken() is TagDirective) && (!(this.GetCurrentToken() is DocumentStart) && !(this.GetCurrentToken() is StreamEnd)))))
            {
                TagDirectiveCollection directives = new TagDirectiveCollection();
                this.ProcessDirectives(directives);
                this.states.Push(ParserState.DocumentEnd);
                this.state = ParserState.BlockNode;
                return(new DocumentStart(null, directives, true, this.GetCurrentToken().Start, this.GetCurrentToken().End));
            }
            if (this.GetCurrentToken() is StreamEnd)
            {
                this.state = ParserState.StreamEnd;
                ParsingEvent event3 = new StreamEnd(this.GetCurrentToken().Start, this.GetCurrentToken().End);
                if (this.scanner.MoveNextWithoutConsuming())
                {
                    throw new InvalidOperationException("The scanner should contain no more tokens.");
                }
                return(event3);
            }
            Mark start = this.GetCurrentToken().Start;
            TagDirectiveCollection tags    = new TagDirectiveCollection();
            VersionDirective       version = this.ProcessDirectives(tags);
            Token currentToken             = this.GetCurrentToken();

            if (!(currentToken is DocumentStart))
            {
                throw new SemanticErrorException(currentToken.Start, currentToken.End, "Did not find expected <document start>.");
            }
            this.states.Push(ParserState.DocumentEnd);
            this.state = ParserState.DocumentContent;
            ParsingEvent event2 = new DocumentStart(version, tags, false, start, currentToken.End);

            this.Skip();
            return(event2);
        }
示例#2
0
 void IParsingEventVisitor.Visit(DocumentStart e)
 {
     throw new NotSupportedException();
 }
示例#3
0
 public void Visit(DocumentStart e)
 {
 }
 public void Visit(DocumentStart e)
 {
     _emitter.Emit(e);
 }