KirillOsenkov / XmlParser

A Roslyn-inspired full-fidelity XML parser with no dependencies and a simple Visual Studio XML language service
Apache License 2.0
328 stars 49 forks source link

InvalidOperationException in MissingToken when parsing !DOCTYPE #32

Closed KirillOsenkov closed 4 years ago

KirillOsenkov commented 4 years ago

Paste this code: <x><!DOCTYPE

Exception:

System.InvalidOperationException: Operation is not valid due to the current state of the object.
   at Green Microsoft.Language.Xml.InternalSyntax.SyntaxFactory.MissingToken(SyntaxList<GreenNode> precedingTrivia, SyntaxKind kind)
   at Green Microsoft.Language.Xml.InternalSyntax.SyntaxFactory.MissingToken(SyntaxKind kind)
   at Green Microsoft.Language.Xml.Parser.ParseXmlElement(ScannerState enclosingState)
   at Green Microsoft.Language.Xml.Parser.ParseXmlDocument()
   at XmlDocumentSyntax Microsoft.Language.Xml.Parser.ParseDocument(Parser parser)
   at XmlDocumentSyntax Microsoft.Language.Xml.Parser.Parse(Buffer buffer)
FrediKats commented 4 years ago

I'm not sure about problem and fix but looks like you just missed case SyntaxKind.XmlTextLiteralToken in MissingToken. 🤔