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;
 }
예제 #5
0
 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);
 }
예제 #6
0
 private PunctuationSyntax XmlMakeRightParenToken(SyntaxList<SyntaxNode> precedingTrivia)
 {
     AdvanceChar();
     var followingTrivia = ScanXmlWhitespace();
     return MakePunctuationToken(SyntaxKind.CloseParenToken, ")", precedingTrivia, followingTrivia);
 }
예제 #7
0
 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);
 }
예제 #8
0
        private SyntaxToken XmlMakeLessToken(SyntaxList<SyntaxNode> precedingTrivia)
        {
            AdvanceChar();

            var followingTrivia = ScanXmlWhitespace();
            return MakePunctuationToken(SyntaxKind.LessThanToken, "<", precedingTrivia, followingTrivia);
        }
예제 #9
0
 private SyntaxToken XmlMakeEqualsToken(SyntaxList<SyntaxNode> leadingTrivia)
 {
     AdvanceChar();
     var followingTrivia = ScanXmlWhitespace();
     return MakePunctuationToken(SyntaxKind.EqualsToken, "=", leadingTrivia, followingTrivia);
 }
예제 #10
0
 private PunctuationSyntax XmlMakeEndProcessingInstructionToken(
     SyntaxList<SyntaxNode> precedingTrivia)
 {
     Debug.Assert(PeekChar() == '?');
     Debug.Assert(PeekAheadChar(1) == '>');
     AdvanceChar(2);
     return MakePunctuationToken(
         SyntaxKind.QuestionGreaterThanToken,
         "?>",
         precedingTrivia,
         null);
 }
예제 #11
0
 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);
 }
예제 #12
0
 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);
 }
예제 #13
0
        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;
        }
예제 #14
0
 private BadTokenSyntax XmlMakeBadToken(SyntaxList<SyntaxNode> precedingTrivia, int length, ERRID id)
 {
     return XmlMakeBadToken(SyntaxSubKind.None, precedingTrivia, length, id);
 }
예제 #15
0
 private XmlTextTokenSyntax XmlMakeAmpLiteralToken(SyntaxList<SyntaxNode> precedingTrivia)
 {
     AdvanceChar(5); // "&amp;".Length
     return precedingTrivia.Node == null ? _xmlAmpToken : SyntaxFactory.XmlEntityLiteralToken("&amp;", "&", precedingTrivia.Node, null);
 }
예제 #16
0
 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);
 }
예제 #17
0
        private SyntaxToken XmlMakeEndEmptyElementToken(SyntaxList<SyntaxNode> precedingTrivia)
        {
            AdvanceChar(2);

            return MakePunctuationToken(SyntaxKind.SlashGreaterThanToken, "/>", precedingTrivia, null);
        }
예제 #18
0
 private SyntaxToken XmlMakeBeginDTDToken(SyntaxList<SyntaxNode> precedingTrivia)
 {
     return XmlMakeBadToken(SyntaxSubKind.BeginDocTypeToken, precedingTrivia, 9, ERRID.ERR_DTDNotSupported);
 }
예제 #19
0
 private XmlTextTokenSyntax XmlMakeEntityLiteralToken(SyntaxList<SyntaxNode> precedingTrivia, int tokenWidth, string value)
 {
     return SyntaxFactory.XmlEntityLiteralToken(GetText(tokenWidth), value, precedingTrivia.Node, null);
 }
예제 #20
0
 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);
 }
예제 #21
0
        private SyntaxToken XmlMakeGreaterToken(SyntaxList<SyntaxNode> precedingTrivia)
        {
            AdvanceChar();

            // Note: > does not consume following trivia
            return MakePunctuationToken(SyntaxKind.GreaterThanToken, ">", precedingTrivia, null);
        }
예제 #22
0
 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);
 }
예제 #23
0
 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);
 }
예제 #24
0
 private XmlTextTokenSyntax XmlMakeCDataToken(SyntaxList<SyntaxNode> precedingTrivia, int TokenWidth, StringBuilder scratch)
 {
     return XmlMakeTextLiteralToken(precedingTrivia, TokenWidth, scratch);
 }
예제 #25
0
 private XmlTextTokenSyntax XmlMakeQuotLiteralToken(SyntaxList<SyntaxNode> precedingTrivia)
 {
     AdvanceChar(6); // "&quot;".Length
     return precedingTrivia.Node == null ? _xmlQuotToken : SyntaxFactory.XmlEntityLiteralToken("&quot;", "\"", precedingTrivia.Node, null);
 }
예제 #26
0
 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);
 }
예제 #27
0
        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);
        }
예제 #28
0
 private PunctuationSyntax XmlMakeDivToken(SyntaxList<SyntaxNode> precedingTrivia)
 {
     AdvanceChar();
     var followingTrivia = ScanXmlWhitespace();
     return MakePunctuationToken(SyntaxKind.SlashToken, "/", precedingTrivia, followingTrivia);
 }
예제 #29
0
 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));
 }
예제 #30
0
 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);
 }