public static SyntaxToken MissingToken(SyntaxKind kind, SyntaxList<SyntaxNode> precedingTrivia = default(SyntaxList<SyntaxNode>)) { switch (kind) { case SyntaxKind.LessThanQuestionToken: case SyntaxKind.XmlKeyword: case SyntaxKind.LessThanToken: case SyntaxKind.LessThanGreaterThanToken: case SyntaxKind.LessThanSlashToken: case SyntaxKind.BeginCDataToken: case SyntaxKind.LessThanExclamationMinusMinusToken: case SyntaxKind.LessThanPercentEqualsToken: case SyntaxKind.SlashToken: case SyntaxKind.GreaterThanToken: case SyntaxKind.EqualsToken: case SyntaxKind.SingleQuoteToken: case SyntaxKind.DoubleQuoteToken: case SyntaxKind.QuestionGreaterThanToken: case SyntaxKind.OpenParenToken: case SyntaxKind.CloseParenToken: case SyntaxKind.ColonToken: case SyntaxKind.SlashGreaterThanToken: case SyntaxKind.EndCDataToken: case SyntaxKind.MinusMinusGreaterThanToken: return MissingPunctuation(kind, precedingTrivia.Node); case SyntaxKind.XmlNameToken: return SyntaxFactory.XmlNameToken("", null, null); default: break; } throw new InvalidOperationException(); }
public XmlStringSyntax(SyntaxKind kind, PunctuationSyntax startQuoteToken, SyntaxList<SyntaxNode> textTokens, PunctuationSyntax endQuoteToken) : base(kind) { this.StartQuoteToken = startQuoteToken; this.TextTokens = textTokens; this.EndQuoteToken = endQuoteToken; this.SlotCount = 3; }
public static XmlDocumentSyntax XmlDocument( XmlDeclarationSyntax prologue, SyntaxList<SyntaxNode> precedingMisc, XmlNodeSyntax body, SyntaxList<XmlNodeSyntax> followingMisc, SyntaxToken eof) { return new XmlDocumentSyntax(SyntaxKind.XmlDocument, prologue, precedingMisc.Node, body, followingMisc.Node, eof); }
public XmlProcessingInstructionSyntax( PunctuationSyntax beginProcessingInstruction, XmlNameTokenSyntax name, SyntaxList<SyntaxNode> toList, PunctuationSyntax endProcessingInstruction) : base(SyntaxKind.XmlProcessingInstruction) { LessThanQuestionToken = beginProcessingInstruction; Name = name; TextTokens = toList.Node; QuestionGreaterThanToken = endProcessingInstruction; SlotCount = 4; }
private XmlTextTokenSyntax XmlMakeTextLiteralToken(SyntaxList<SyntaxNode> precedingTrivia, int TokenWidth, StringBuilder Scratch) { Debug.Assert(TokenWidth > 0); var text = GetText(TokenWidth); var value = _stringTable.Add(Scratch); Scratch.Clear(); return SyntaxFactory.XmlTextLiteralToken(text, value, precedingTrivia.Node, null); }
private PunctuationSyntax XmlMakeRightParenToken(SyntaxList<SyntaxNode> precedingTrivia) { AdvanceChar(); var followingTrivia = ScanXmlWhitespace(); return MakePunctuationToken(SyntaxKind.CloseParenToken, ")", precedingTrivia, followingTrivia); }
private XmlTextTokenSyntax XmlMakeProcessingInstructionToken(SyntaxList<SyntaxNode> precedingTrivia, int TokenWidth) { Debug.Assert(TokenWidth > 0); var text = GetText(TokenWidth); // was GetTextNotInterned return SyntaxFactory.XmlTextLiteralToken(text, text, precedingTrivia.Node, null); }
private SyntaxToken XmlMakeLessToken(SyntaxList<SyntaxNode> precedingTrivia) { AdvanceChar(); var followingTrivia = ScanXmlWhitespace(); return MakePunctuationToken(SyntaxKind.LessThanToken, "<", precedingTrivia, followingTrivia); }
private SyntaxToken XmlMakeEqualsToken(SyntaxList<SyntaxNode> leadingTrivia) { AdvanceChar(); var followingTrivia = ScanXmlWhitespace(); return MakePunctuationToken(SyntaxKind.EqualsToken, "=", leadingTrivia, followingTrivia); }
private PunctuationSyntax XmlMakeEndProcessingInstructionToken( SyntaxList<SyntaxNode> precedingTrivia) { Debug.Assert(PeekChar() == '?'); Debug.Assert(PeekAheadChar(1) == '>'); AdvanceChar(2); return MakePunctuationToken( SyntaxKind.QuestionGreaterThanToken, "?>", precedingTrivia, null); }
private PunctuationSyntax XmlMakeBeginCommentToken(SyntaxList<SyntaxNode> precedingTrivia, Func<SyntaxList<SyntaxNode>> scanTrailingTrivia) { Debug.Assert(PeekChar() == '<'); Debug.Assert(PeekAheadChar(1) == '!'); Debug.Assert(PeekAheadChar(2) == '-'); Debug.Assert(PeekAheadChar(3) == '-'); AdvanceChar(4); var followingTrivia = scanTrailingTrivia(); return MakePunctuationToken(SyntaxKind.LessThanExclamationMinusMinusToken, "<!--", precedingTrivia, followingTrivia); }
private SyntaxToken XmlMakeBeginCDataToken( SyntaxList<SyntaxNode> leadingTrivia, Func<SyntaxList<SyntaxNode>> scanTrailingTrivia) { Debug.Assert(PeekChar() == '<'); Debug.Assert(PeekAheadChar(1) == '!'); Debug.Assert(PeekAheadChar(2) == '['); Debug.Assert(PeekAheadChar(3) == 'C'); Debug.Assert(PeekAheadChar(4) == 'D'); Debug.Assert(PeekAheadChar(5) == 'A'); Debug.Assert(PeekAheadChar(6) == 'T'); Debug.Assert(PeekAheadChar(7) == 'A'); Debug.Assert(PeekAheadChar(8) == '['); AdvanceChar(9); var followingTrivia = scanTrailingTrivia(); return MakePunctuationToken( SyntaxKind.BeginCDataToken, "<![CDATA[", leadingTrivia, followingTrivia); }
private BadTokenSyntax XmlMakeBadToken(SyntaxSubKind subkind, SyntaxList<SyntaxNode> precedingTrivia, int length, ERRID id) { var spelling = GetText(length); var followingTrivia = ScanXmlWhitespace(); var result1 = SyntaxFactory.BadToken(subkind, spelling, precedingTrivia.Node, followingTrivia); DiagnosticInfo diagnostic; switch (id) { case ERRID.ERR_IllegalXmlStartNameChar: case ERRID.ERR_IllegalXmlNameChar: Debug.Assert(length == 1); if (id == ERRID.ERR_IllegalXmlNameChar && (precedingTrivia.Any() || PrevToken == null || PrevToken.HasTrailingTrivia || PrevToken.Kind == SyntaxKind.LessThanToken || PrevToken.Kind == SyntaxKind.LessThanSlashToken || PrevToken.Kind == SyntaxKind.LessThanQuestionToken)) { id = ERRID.ERR_IllegalXmlStartNameChar; } var xmlCh = spelling[0]; var xmlChAsUnicode = UTF16ToUnicode(new XmlCharResult(xmlCh)); diagnostic = ErrorFactory.ErrorInfo(id, xmlCh, string.Format("&H{0:X}", xmlChAsUnicode)); break; default: diagnostic = ErrorFactory.ErrorInfo(id); break; } var errResult1 = ((BadTokenSyntax)result1.SetDiagnostics(new[] { diagnostic })); Debug.Assert(errResult1 != null); return errResult1; }
private BadTokenSyntax XmlMakeBadToken(SyntaxList<SyntaxNode> precedingTrivia, int length, ERRID id) { return XmlMakeBadToken(SyntaxSubKind.None, precedingTrivia, length, id); }
private XmlTextTokenSyntax XmlMakeAmpLiteralToken(SyntaxList<SyntaxNode> precedingTrivia) { AdvanceChar(5); // "&".Length return precedingTrivia.Node == null ? _xmlAmpToken : SyntaxFactory.XmlEntityLiteralToken("&", "&", precedingTrivia.Node, null); }
private PunctuationSyntax XmlMakeEndCommentToken(SyntaxList<SyntaxNode> precedingTrivia) { Debug.Assert(PeekChar() == '-'); Debug.Assert(PeekAheadChar(1) == '-'); Debug.Assert(PeekAheadChar(2) == '>'); AdvanceChar(3); return MakePunctuationToken(SyntaxKind.MinusMinusGreaterThanToken, "-->", precedingTrivia, null); }
private SyntaxToken XmlMakeEndEmptyElementToken(SyntaxList<SyntaxNode> precedingTrivia) { AdvanceChar(2); return MakePunctuationToken(SyntaxKind.SlashGreaterThanToken, "/>", precedingTrivia, null); }
private SyntaxToken XmlMakeBeginDTDToken(SyntaxList<SyntaxNode> precedingTrivia) { return XmlMakeBadToken(SyntaxSubKind.BeginDocTypeToken, precedingTrivia, 9, ERRID.ERR_DTDNotSupported); }
private XmlTextTokenSyntax XmlMakeEntityLiteralToken(SyntaxList<SyntaxNode> precedingTrivia, int tokenWidth, string value) { return SyntaxFactory.XmlEntityLiteralToken(GetText(tokenWidth), value, precedingTrivia.Node, null); }
private PunctuationSyntax XmlMakeBeginEndElementToken( SyntaxList<SyntaxNode> precedingTrivia, Func<SyntaxList<SyntaxNode>> scanTrailingTrivia) { Debug.Assert(PeekChar() == '<'); Debug.Assert(PeekAheadChar(1) == '/'); AdvanceChar(2); var followingTrivia = scanTrailingTrivia(); return MakePunctuationToken( SyntaxKind.LessThanSlashToken, "</", precedingTrivia, followingTrivia); }
private SyntaxToken XmlMakeGreaterToken(SyntaxList<SyntaxNode> precedingTrivia) { AdvanceChar(); // Note: > does not consume following trivia return MakePunctuationToken(SyntaxKind.GreaterThanToken, ">", precedingTrivia, null); }
private PunctuationSyntax XmlMakeBeginProcessingInstructionToken(SyntaxList<SyntaxNode> precedingTrivia, Func<SyntaxList<SyntaxNode>> scanTrailingTrivia) { Debug.Assert(PeekChar() == '<'); Debug.Assert(PeekAheadChar(1) == '?'); AdvanceChar(2); var followingTrivia = scanTrailingTrivia(); return MakePunctuationToken(SyntaxKind.LessThanQuestionToken, "<?", precedingTrivia, followingTrivia); }
private BadTokenSyntax XmlMakeOpenBracketToken(ScannerState state, SyntaxList<SyntaxNode> precedingTrivia) { Debug.Assert(PeekChar() == '['); return XmlMakeBadToken( SyntaxSubKind.OpenBracketToken, precedingTrivia, 1, state == ScannerState.DocType ? ERRID.ERR_DTDNotSupported : ERRID.ERR_IllegalXmlNameChar); }
private XmlTextTokenSyntax XmlMakeCDataToken(SyntaxList<SyntaxNode> precedingTrivia, int TokenWidth, StringBuilder scratch) { return XmlMakeTextLiteralToken(precedingTrivia, TokenWidth, scratch); }
private XmlTextTokenSyntax XmlMakeQuotLiteralToken(SyntaxList<SyntaxNode> precedingTrivia) { AdvanceChar(6); // """.Length return precedingTrivia.Node == null ? _xmlQuotToken : SyntaxFactory.XmlEntityLiteralToken(""", "\"", precedingTrivia.Node, null); }
private XmlTextTokenSyntax XmlMakeCommentToken(SyntaxList<SyntaxNode> precedingTrivia, int TokenWidth) { Debug.Assert(TokenWidth > 0); var text = GetText(TokenWidth); // GetTextNotInterned() in the original return SyntaxFactory.XmlTextLiteralToken(text, text, precedingTrivia.Node, null); }
private SyntaxToken XmlMakeSingleQuoteToken( SyntaxList<SyntaxNode> leadingTrivia, char spelling, bool isOpening) { Debug.Assert(PeekChar() == spelling); AdvanceChar(); SyntaxNode followingTrivia = null; if (!isOpening) { var ws = ScanXmlWhitespace(); followingTrivia = ws; } return MakePunctuationToken( SyntaxKind.SingleQuoteToken, Intern(spelling), leadingTrivia, followingTrivia); }
private PunctuationSyntax XmlMakeDivToken(SyntaxList<SyntaxNode> precedingTrivia) { AdvanceChar(); var followingTrivia = ScanXmlWhitespace(); return MakePunctuationToken(SyntaxKind.SlashToken, "/", precedingTrivia, followingTrivia); }
private SyntaxToken XmlMakeTextLiteralToken( SyntaxList<SyntaxNode> leadingTrivia, int tokenWidth, ERRID eRR_XmlEndCDataNotAllowedInContent) { var text = GetText(tokenWidth); return (SyntaxToken)SyntaxFactory .XmlTextLiteralToken(text, text, leadingTrivia.Node, null) .SetDiagnostics(ErrorFactory.ErrorInfo(eRR_XmlEndCDataNotAllowedInContent)); }
private PunctuationSyntax XmlMakeEndCDataToken(SyntaxList<SyntaxNode> precedingTrivia) { Debug.Assert(PeekChar() == ']'); Debug.Assert(PeekAheadChar(1) == ']'); Debug.Assert(PeekAheadChar(2) == '>'); AdvanceChar(3); return MakePunctuationToken(SyntaxKind.EndCDataToken, "]]>", precedingTrivia, null); }