public virtual bool ParseChildren(ChildCollection c) { Contract.Assume(c.Parser == this); c.Clear(); var res = true; var cl = CurrentToken.Class; while (cl != TokenClass.EndOfDocument && (cl == TokenClass.Literal || cl == TokenClass.Identifier || cl == TokenClass.Equals || cl == TokenClass.CDataStart || cl == TokenClass.String || cl == TokenClass.TagStart || cl == TokenClass.ServerTagStart || cl == TokenClass.DoctypeStart || cl == TokenClass.XmlDocTagStart)) { switch (cl) { case TokenClass.Identifier: case TokenClass.Literal: case TokenClass.Equals: case TokenClass.CDataStart: case TokenClass.String: var literal = c.New<Literal>(); if (!ParseLiteral(literal, true)) res = false; break; case TokenClass.TagStart: var p = PeekToken(); if (p.Class == TokenClass.Identifier && p.Value.ToLower() == "script") { var script = c.New<Script>(); if (!ParseScript(script)) res = false; } else if (p.Class == TokenClass.Identifier && p.Value.ToLower() == "style") { var style = c.New<Style>(); if (!ParseStyle(style)) res = false; } else { var elem = c.New<Element>(); if (!ParseElement(elem)) res = false; } break; case TokenClass.ServerTagStart: if (CurrentToken.ServerTagClass == ServerTagClass.PersistentObject) { var t = c.New<PersistentObject>(); if (!ParsePersistentObject(t)) res = false; } else { var serverTag = c.New<ServerTag>(); if (!ParseServerTag(serverTag)) res = false; } break; case TokenClass.DoctypeStart: var doctype = c.New<Doctype>(); if (!ParseDoctype(doctype)) res = false; break; case TokenClass.XmlDocTagStart: var xmldoc = c.New<XmlDocHeader>(); if (!ParseXmlDocHeader(xmldoc)) res = false; break; } cl = CurrentToken.Class; } return res; }