3 types derived from SyntaxToken
Microsoft.CodeAnalysis.CSharp (3)
Syntax\InternalSyntax\SyntaxToken.SyntaxIdentifier.cs (1)
13
internal class SyntaxIdentifier :
SyntaxToken
Syntax\InternalSyntax\SyntaxToken.SyntaxLiteral.cs (1)
14
internal class SyntaxTokenWithValue<T> :
SyntaxToken
Syntax\InternalSyntax\SyntaxToken.SyntaxTokenWithTrivia.cs (1)
11
internal class SyntaxTokenWithTrivia :
SyntaxToken
2 instantiations of SyntaxToken
Microsoft.CodeAnalysis.CSharp (2)
Binder\Semantics\Conversions\ConversionsBase.cs (1)
1755
var greenNode = new Syntax.InternalSyntax.LiteralExpressionSyntax(SyntaxKind.NumericLiteralExpression, new Syntax.InternalSyntax.
SyntaxToken
(SyntaxKind.NumericLiteralToken));
Syntax\InternalSyntax\SyntaxToken.cs (1)
156
s_tokensWithNoTrivia[(int)kind].Value = new
SyntaxToken
(kind);
836 references to SyntaxToken
Microsoft.CodeAnalysis.CSharp (832)
Parser\BlendedNode.cs (2)
16
internal readonly
SyntaxToken
Token;
19
internal BlendedNode(CSharp.CSharpSyntaxNode node,
SyntaxToken
token, Blender blender)
Parser\Blender.Cursor.cs (1)
148
var
greenToken = Lexer.RescanInterpolatedString((InterpolatedStringExpressionSyntax)node.Green);
Parser\Blender.Reader.cs (5)
144
var
token = this.LexNewToken(mode);
163
private
SyntaxToken
LexNewToken(LexerMode mode)
175
var
token = _lexer.Lex(ref mode);
211
token: (InternalSyntax.
SyntaxToken
)currentNodeOrToken.AsToken().Node);
314
private BlendedNode CreateBlendedNode(CSharp.CSharpSyntaxNode node,
SyntaxToken
token)
Parser\DirectiveParser.cs (92)
37
var
hash = this.EatToken(SyntaxKind.HashToken, false);
88
var
lineKeyword = this.EatContextualToken(contextualKind);
117
var
id = this.EatToken(SyntaxKind.IdentifierToken, false);
118
var
end = this.ParseEndOfDirective(ignoreErrors: true);
137
private DirectiveTriviaSyntax ParseIfDirective(
SyntaxToken
hash,
SyntaxToken
keyword, bool isActive)
140
var
eod = this.ParseEndOfDirective(ignoreErrors: false);
146
private DirectiveTriviaSyntax ParseElifDirective(
SyntaxToken
hash,
SyntaxToken
keyword, bool isActive, bool endIsActive)
149
var
eod = this.ParseEndOfDirective(ignoreErrors: false);
174
private DirectiveTriviaSyntax ParseElseDirective(
SyntaxToken
hash,
SyntaxToken
keyword, bool isActive, bool endIsActive)
176
var
eod = this.ParseEndOfDirective(ignoreErrors: false);
196
private DirectiveTriviaSyntax ParseEndIfDirective(
SyntaxToken
hash,
SyntaxToken
keyword, bool isActive, bool endIsActive)
198
var
eod = this.ParseEndOfDirective(ignoreErrors: false);
215
private DirectiveTriviaSyntax ParseRegionDirective(
SyntaxToken
hash,
SyntaxToken
keyword, bool isActive)
220
private DirectiveTriviaSyntax ParseEndRegionDirective(
SyntaxToken
hash,
SyntaxToken
keyword, bool isActive)
222
var
eod = this.ParseEndOfDirectiveWithOptionalPreprocessingMessage();
237
private DirectiveTriviaSyntax ParseDefineOrUndefDirective(
SyntaxToken
hash,
SyntaxToken
keyword, bool isActive, bool isFollowingToken)
244
var
name = this.EatToken(SyntaxKind.IdentifierToken, ErrorCode.ERR_IdentifierExpected);
246
var
end = this.ParseEndOfDirective(ignoreErrors: name.IsMissing);
279
private DirectiveTriviaSyntax ParseErrorOrWarningDirective(
SyntaxToken
hash,
SyntaxToken
keyword, bool isActive)
281
var
eod = this.ParseEndOfDirectiveWithOptionalPreprocessingMessage();
361
private DirectiveTriviaSyntax ParseLineDirective(
SyntaxToken
hash,
SyntaxToken
id, bool isActive)
363
SyntaxToken
line;
364
SyntaxToken
file = null;
397
var
end = this.ParseEndOfDirective(ignoreErrors: line.IsMissing || !isActive, afterLineNumber: sawLineButNotFile);
401
private LineSpanDirectiveTriviaSyntax ParseLineSpanDirective(
SyntaxToken
hash,
SyntaxToken
lineKeyword, bool isActive)
412
var
minus = EatToken(SyntaxKind.MinusToken, reportError: reportError);
422
var
characterOffset = (CurrentToken.Kind == SyntaxKind.NumericLiteralToken) ?
431
var
file = EatToken(SyntaxKind.StringLiteralToken, ErrorCode.ERR_MissingPPFile, reportError: reportError);
439
var
endOfDirective = this.ParseEndOfDirective(ignoreErrors: !reportError);
442
static bool noTriviaBetween(
SyntaxToken
token1,
SyntaxToken
token2)
452
var
openParen = EatToken(SyntaxKind.OpenParenToken, reportError);
455
var
lineToken = ParseLineDirectiveNumericLiteral(ref reportError, minValue: 1, maxValue: MaxLineValue, out line);
457
var
comma = EatToken(SyntaxKind.CommaToken, reportError);
460
var
characterToken = ParseLineDirectiveNumericLiteral(ref reportError, minValue: 1, maxValue: MaxCharacterValue, out character);
462
var
closeParen = EatToken(SyntaxKind.CloseParenToken, reportError);
468
private
SyntaxToken
ParseLineDirectiveNumericLiteral(ref bool reportError, int minValue, int maxValue, out int value)
470
var
token = this.EatToken(SyntaxKind.NumericLiteralToken, ErrorCode.ERR_LineSpanDirectiveInvalidValue, reportError: reportError);
488
private DirectiveTriviaSyntax ParseReferenceDirective(
SyntaxToken
hash,
SyntaxToken
keyword, bool isActive, bool isFollowingToken)
502
SyntaxToken
file = this.EatToken(SyntaxKind.StringLiteralToken, ErrorCode.ERR_ExpectedPPFile, reportError: isActive);
504
var
end = this.ParseEndOfDirective(ignoreErrors: file.IsMissing || !isActive);
508
private DirectiveTriviaSyntax ParseLoadDirective(
SyntaxToken
hash,
SyntaxToken
keyword, bool isActive, bool isFollowingToken)
522
SyntaxToken
file = this.EatToken(SyntaxKind.StringLiteralToken, ErrorCode.ERR_ExpectedPPFile, reportError: isActive);
524
var
end = this.ParseEndOfDirective(ignoreErrors: file.IsMissing || !isActive);
528
private DirectiveTriviaSyntax ParseNullableDirective(
SyntaxToken
hash,
SyntaxToken
token, bool isActive)
535
SyntaxToken
setting = this.CurrentToken.Kind switch
543
SyntaxToken
target = this.CurrentToken.Kind switch
552
var
end = this.ParseEndOfDirective(ignoreErrors: setting.IsMissing || target?.IsMissing == true || !isActive);
556
private DirectiveTriviaSyntax ParsePragmaDirective(
SyntaxToken
hash,
SyntaxToken
pragma, bool isActive)
566
var
warning = this.EatContextualToken(SyntaxKind.WarningKeyword);
567
SyntaxToken
style;
575
SyntaxToken
id;
619
var
end = this.ParseEndOfDirective(hasError || !isActive, afterPragma: true);
625
var
end = this.ParseEndOfDirective(ignoreErrors: true, afterPragma: true);
631
var
checksum = this.EatToken();
632
var
file = this.EatToken(SyntaxKind.StringLiteralToken, ErrorCode.WRN_IllegalPPChecksum, reportError: isActive);
633
var
guid = this.EatToken(SyntaxKind.StringLiteralToken, ErrorCode.WRN_IllegalPPChecksum, reportError: isActive && !file.IsMissing);
643
var
bytes = this.EatToken(SyntaxKind.StringLiteralToken, ErrorCode.WRN_IllegalPPChecksum, reportError: isActive && !guid.IsMissing);
664
var
eod = this.ParseEndOfDirective(ignoreErrors: hasError, afterPragma: true);
669
var
warning = this.EatToken(SyntaxKind.WarningKeyword, ErrorCode.WRN_IllegalPragma, reportError: isActive);
670
var
style = this.EatToken(SyntaxKind.DisableKeyword, reportError: false);
671
var
eod = this.ParseEndOfDirective(ignoreErrors: true, afterPragma: true);
676
private DirectiveTriviaSyntax ParseShebangDirective(
SyntaxToken
hash,
SyntaxToken
exclamation, bool isActive)
684
private
SyntaxToken
ParseEndOfDirectiveWithOptionalPreprocessingMessage()
687
private
SyntaxToken
ParseEndOfDirective(bool ignoreErrors, bool afterPragma = false, bool afterLineNumber = false)
689
var skippedTokens = new SyntaxListBuilder<
SyntaxToken
>();
695
skippedTokens = new SyntaxListBuilder<
SyntaxToken
>(10);
720
SyntaxToken
endOfDirective = this.CurrentToken.Kind == SyntaxKind.EndOfDirectiveToken
743
var
op = this.EatToken();
756
var
op = this.EatToken();
769
var
op = this.EatToken();
781
var
op = this.EatToken();
794
var
open = this.EatToken();
796
var
close = this.EatToken(SyntaxKind.CloseParenToken);
799
var
identifier = TruncateIdentifier(this.EatToken());
811
private static
SyntaxToken
TruncateIdentifier(
SyntaxToken
identifier)
Parser\DocumentationCommentParser.cs (83)
86
var
eoc = this.EatToken(SyntaxKind.EndOfDocumentationCommentToken);
110
var
token = this.EatToken();
204
var
lessThan = this.EatToken(SyntaxKind.LessThanToken); // guaranteed
228
SyntaxToken
greaterThan;
231
var
lessThanSlash = this.EatToken(SyntaxKind.LessThanSlashToken, reportError: false);
281
var
slashGreater = this.EatToken(SyntaxKind.SlashGreaterThanToken, false);
379
var badTokens = default(SyntaxListBuilder<
SyntaxToken
>);
396
badTokens = _pool.Allocate<
SyntaxToken
>();
399
var
token = this.EatToken();
447
var
equals = this.EatToken(SyntaxKind.EqualsToken, false);
464
default(SyntaxList<
SyntaxToken
>),
469
SyntaxToken
startQuote;
470
SyntaxToken
endQuote;
489
var textTokens = _pool.Allocate<
SyntaxToken
>();
525
SyntaxToken
openQuote = EatToken(this.CurrentToken.Kind == SyntaxKind.SingleQuoteToken
532
SyntaxToken
current = this.CurrentToken;
553
private void ParseCrefAttribute(out
SyntaxToken
startQuote, out CrefSyntax cref, out
SyntaxToken
endQuote)
571
private void ParseNameAttribute(out
SyntaxToken
startQuote, out IdentifierNameSyntax identifier, out
SyntaxToken
endQuote)
589
private void ParseXmlAttributeText(out
SyntaxToken
startQuote, SyntaxListBuilder<
SyntaxToken
> textTokens, out
SyntaxToken
endQuote)
611
var
token = this.EatToken();
629
private
SyntaxToken
ParseXmlAttributeStartQuote()
640
var
startQuote = this.EatToken(quoteKind, reportError: false);
648
private
SyntaxToken
ParseXmlAttributeEndQuote(SyntaxKind quoteKind)
655
var
endQuote = this.EatToken(quoteKind, reportError: false);
663
private
SyntaxToken
SkipNonAsciiQuotationMark()
665
var
quote = SyntaxFactory.MissingToken(SyntaxKind.DoubleQuoteToken);
676
private static bool IsNonAsciiQuotationMark(
SyntaxToken
token)
683
var
id = this.EatToken(SyntaxKind.IdentifierToken);
687
var
colon = this.EatToken();
722
var
lessThanExclamationMinusMinusToken = this.EatToken(SyntaxKind.XmlCommentStartToken);
724
var textTokens = _pool.Allocate<
SyntaxToken
>();
729
var
token = this.EatToken();
742
var
minusMinusGreaterThanToken = this.EatToken(SyntaxKind.XmlCommentEndToken);
749
var
startCDataToken = this.EatToken(SyntaxKind.XmlCDataStartToken);
751
var textTokens = new SyntaxListBuilder<
SyntaxToken
>(10);
758
var
endCDataToken = this.EatToken(SyntaxKind.XmlCDataEndToken);
765
var
startProcessingInstructionToken = this.EatToken(SyntaxKind.XmlProcessingInstructionStartToken);
773
var textTokens = new SyntaxListBuilder<
SyntaxToken
>(10);
777
var
textToken = this.EatToken();
785
var
endProcessingInstructionToken = this.EatToken(SyntaxKind.XmlProcessingInstructionEndToken);
841
private
SyntaxToken
WithXmlParseError(
SyntaxToken
node, XmlParseErrorCode code, params string[] args)
908
SyntaxToken
dot = EatToken(SyntaxKind.DotToken);
917
var badTokens = _pool.Allocate<
SyntaxToken
>();
972
SyntaxToken
thisKeyword = EatToken();
984
SyntaxToken
operatorKeyword = EatToken();
985
SyntaxToken
checkedKeyword = TryEatCheckedKeyword(isConversion: false, ref operatorKeyword);
987
SyntaxToken
operatorToken;
1019
var
operatorToken2 = this.EatToken();
1024
var
operatorToken3 = this.EatToken();
1039
var
nonOverloadableOperator = SyntaxFactory.Token(
1071
var
operatorToken2 = this.EatToken();
1081
var
operatorToken2 = this.EatToken();
1082
var
nonOverloadableOperator = SyntaxFactory.Token(
1110
private
SyntaxToken
TryEatCheckedKeyword(bool isConversion, ref
SyntaxToken
operatorKeyword)
1112
SyntaxToken
checkedKeyword = tryEatCheckedOrHandleUnchecked(ref operatorKeyword);
1122
SyntaxToken
tryEatCheckedOrHandleUnchecked(ref
SyntaxToken
operatorKeyword)
1127
var
misplacedToken = AddErrorAsWarning(EatToken(), ErrorCode.ERR_MisplacedUnchecked);
1143
SyntaxToken
implicitOrExplicit = EatToken();
1145
SyntaxToken
operatorKeyword = EatToken(SyntaxKind.OperatorKeyword);
1146
SyntaxToken
checkedKeyword = TryEatCheckedKeyword(isConversion: true, ref operatorKeyword);
1184
SyntaxToken
open = EatToken(openKind);
1195
SyntaxToken
comma = EatToken(SyntaxKind.CommaToken);
1212
SyntaxToken
close = EatToken(closeKind);
1250
SyntaxToken
refKindOpt = null;
1260
SyntaxToken
readOnlyOpt = null;
1266
var
misplacedToken = AddErrorAsWarning(EatToken(), ErrorCode.ERR_RefReadOnlyWrongOrdering);
1286
SyntaxToken
identifierToken = EatToken(SyntaxKind.IdentifierToken);
1293
var
open = EatToken();
1324
SyntaxToken
close = EatToken(SyntaxKind.GreaterThanToken);
1384
SyntaxToken
alias = EatToken();
1392
SyntaxToken
colonColon = EatToken();
1418
SyntaxToken
dot = EatToken();
1462
SyntaxToken
open = EatToken();
1491
var
close = this.EatToken(SyntaxKind.CloseBracketToken);
1563
SyntaxToken
identifierToken = this.EatToken(SyntaxKind.IdentifierToken, reportError: false);
1567
var badTokens = _pool.Allocate<
SyntaxToken
>();
Parser\DocumentationCommentXmlTokens.cs (24)
16
private static readonly
SyntaxToken
s_seeToken = Identifier(DocumentationCommentXmlNames.SeeElementName);
17
private static readonly
SyntaxToken
s_codeToken = Identifier(DocumentationCommentXmlNames.CodeElementName);
18
private static readonly
SyntaxToken
s_listToken = Identifier(DocumentationCommentXmlNames.ListElementName);
19
private static readonly
SyntaxToken
s_paramToken = Identifier(DocumentationCommentXmlNames.ParameterElementName);
20
private static readonly
SyntaxToken
s_valueToken = Identifier(DocumentationCommentXmlNames.ValueElementName);
21
private static readonly
SyntaxToken
s_exampleToken = Identifier(DocumentationCommentXmlNames.ExampleElementName);
22
private static readonly
SyntaxToken
s_includeToken = Identifier(DocumentationCommentXmlNames.IncludeElementName);
23
private static readonly
SyntaxToken
s_remarksToken = Identifier(DocumentationCommentXmlNames.RemarksElementName);
24
private static readonly
SyntaxToken
s_seealsoToken = Identifier(DocumentationCommentXmlNames.SeeAlsoElementName);
25
private static readonly
SyntaxToken
s_summaryToken = Identifier(DocumentationCommentXmlNames.SummaryElementName);
26
private static readonly
SyntaxToken
s_exceptionToken = Identifier(DocumentationCommentXmlNames.ExceptionElementName);
27
private static readonly
SyntaxToken
s_typeparamToken = Identifier(DocumentationCommentXmlNames.TypeParameterElementName);
28
private static readonly
SyntaxToken
s_permissionToken = Identifier(DocumentationCommentXmlNames.PermissionElementName);
29
private static readonly
SyntaxToken
s_typeparamrefToken = Identifier(DocumentationCommentXmlNames.TypeParameterReferenceElementName);
32
private static readonly
SyntaxToken
s_crefToken = IdentifierWithLeadingSpace(DocumentationCommentXmlNames.CrefAttributeName);
33
private static readonly
SyntaxToken
s_fileToken = IdentifierWithLeadingSpace(DocumentationCommentXmlNames.FileAttributeName);
34
private static readonly
SyntaxToken
s_nameToken = IdentifierWithLeadingSpace(DocumentationCommentXmlNames.NameAttributeName);
35
private static readonly
SyntaxToken
s_pathToken = IdentifierWithLeadingSpace(DocumentationCommentXmlNames.PathAttributeName);
36
private static readonly
SyntaxToken
s_typeToken = IdentifierWithLeadingSpace(DocumentationCommentXmlNames.TypeAttributeName);
38
private static
SyntaxToken
Identifier(string text)
43
private static
SyntaxToken
IdentifierWithLeadingSpace(string text)
60
public static
SyntaxToken
? LookupToken(string text, SyntaxListBuilder? leading)
75
private static
SyntaxToken
? LookupXmlElementTag(string text)
157
private static
SyntaxToken
? LookupXmlAttribute(string text)
Parser\LanguageParser.cs (350)
183
SyntaxToken
? tmp = null;
190
var
eof = this.EatToken(SyntaxKind.EndOfFileToken);
231
var fileAsTrivia = _syntaxFactory.SkippedTokensTrivia(builder.ToList<
SyntaxToken
>());
253
var
namespaceToken = this.EatToken(SyntaxKind.NamespaceKeyword);
262
SyntaxToken
? openBrace = null;
263
SyntaxToken
? semicolon = null;
363
ref
SyntaxToken
? openBraceOrSemicolon,
412
[NotNullIfNotNull(nameof(openBraceOrSemicolon))] ref
SyntaxToken
? openBraceOrSemicolon,
564
[NotNullIfNotNull(nameof(openBraceOrSemicolon))] ref
SyntaxToken
? openBraceOrSemicolon,
616
var
token = this.EatToken();
731
var
skippedToken = EatToken();
817
ref
SyntaxToken
? openBrace,
851
ref
SyntaxToken
? openBraceOrSemicolon,
957
var
globalToken = this.CurrentToken.ContextualKind == SyntaxKind.GlobalKeyword
963
var
usingToken = this.EatToken(SyntaxKind.UsingKeyword);
964
var
staticToken = this.TryEatToken(SyntaxKind.StaticKeyword);
965
var
unsafeToken = this.TryEatToken(SyntaxKind.UnsafeKeyword);
978
SyntaxToken
semicolon;
1027
private static bool IsGlobalAttributeTarget(
SyntaxToken
token)
1123
var
openBracket = this.EatToken(SyntaxKind.OpenBracketToken);
1140
var
closeBracket = this.EatToken(SyntaxKind.CloseBracketToken);
1175
LanguageParser @this, ref
SyntaxToken
openBracket, SeparatedSyntaxListBuilder<AttributeSyntax> list, SyntaxKind expectedKind, SyntaxKind closeKind)
1211
var
openParen = this.EatToken(SyntaxKind.OpenParenToken);
1230
LanguageParser @this, ref
SyntaxToken
openParen, SeparatedSyntaxListBuilder<AttributeArgumentSyntax> list, SyntaxKind expectedKind, SyntaxKind closeKind)
1291
private static DeclarationModifiers GetModifierExcludingScoped(
SyntaxToken
token)
1366
SyntaxToken
scopedKeyword = ParsePossibleScopedKeyword(isFunctionPointerParameter: false);
1378
SyntaxToken
modTok;
1382
var
nextToken = PeekToken(1);
1413
var
next = PeekToken(1);
1474
bool isStructOrRecordKeyword(
SyntaxToken
token)
1607
private static bool IsNonContextualModifier(
SyntaxToken
nextToken)
1615
var
nextToken = this.PeekToken(1);
1727
if (!tryScanRecordStart(out
var
keyword, out
var
recordModifier))
1738
var
name = this.ParseIdentifierToken();
1761
SyntaxToken
semicolon;
1762
SyntaxToken
? openBrace;
1763
SyntaxToken
? closeBrace;
1851
bool tryScanRecordStart([NotNullWhen(true)] out
SyntaxToken
? keyword, out
SyntaxToken
? recordModifier)
1868
var
misplacedToken = this.EatToken();
1885
static TypeDeclarationSyntax constructTypeDeclaration(ContextAwareSyntax syntaxFactory, SyntaxList<AttributeListSyntax> attributes, SyntaxListBuilder modifiers,
SyntaxToken
keyword,
SyntaxToken
? recordModifier,
1886
SyntaxToken
name, TypeParameterListSyntax typeParameters, ParameterListSyntax? paramList, BaseListSyntax baseList, SyntaxListBuilder<TypeParameterConstraintClauseSyntax> constraints,
1887
SyntaxToken
? openBrace, SyntaxListBuilder<MemberDeclarationSyntax> members,
SyntaxToken
? closeBrace,
SyntaxToken
semicolon)
1889
var modifiersList = (SyntaxList<
SyntaxToken
>)modifiers.ToList();
1968
private void SkipBadMemberListTokens(ref
SyntaxToken
openBrace, SyntaxListBuilder members)
1980
openBrace = (
SyntaxToken
)tmp;
1992
var
token = this.EatToken();
2060
var
colon = this.TryEatToken(SyntaxKind.ColonToken);
2115
PostSkipAction skipBadBaseListTokens(ref
SyntaxToken
colon, SeparatedSyntaxListBuilder<BaseTypeSyntax> list, SyntaxKind expected)
2142
var
where = this.EatContextualToken(SyntaxKind.WhereKeyword);
2147
var
colon = this.EatToken(SyntaxKind.ColonToken);
2175
SyntaxToken
separatorToken = this.EatToken(SyntaxKind.CommaToken);
2285
var
allows = this.EatContextualToken(SyntaxKind.AllowsKeyword);
2454
new SyntaxList<
SyntaxToken
>(),
2591
var
identifier = this.EatToken();
2738
SyntaxToken
identifierOrThisOpt;
2923
var
misplacedModifier = this.CurrentToken;
2940
ExplicitInterfaceSpecifierSyntax explicitInterfaceOpt,
SyntaxToken
identifierOrThisOpt, TypeParameterListSyntax typeParameterListOpt,
2981
ref ExplicitInterfaceSpecifierSyntax explicitInterfaceOpt, ref
SyntaxToken
identifierOrThisOpt,
3004
ExplicitInterfaceSpecifierSyntax explicitInterfaceOpt,
SyntaxToken
identifierOrThisOpt,
3151
SyntaxToken
identifierOrThisOpt;
3203
SyntaxToken
identifierOrThisOpt)
3282
if (child is not
SyntaxToken
token)
3306
var
name = this.ParseIdentifierToken();
3316
this.ParseBlockAndExpressionBodiesWithSemicolon(out var body, out var expressionBody, out
var
semicolon);
3328
var
colon = this.EatToken(SyntaxKind.ColonToken);
3335
SyntaxToken
token;
3361
var
tilde = this.EatToken(SyntaxKind.TildeToken);
3363
var
name = this.ParseIdentifierToken();
3370
out BlockSyntax body, out ArrowExpressionClauseSyntax expressionBody, out
SyntaxToken
semicolon);
3382
out
SyntaxToken
semicolon,
3470
SyntaxToken
identifier,
3488
var
colonToken = this.CurrentToken;
3509
this.ParseBlockAndExpressionBodiesWithSemicolon(out var blockBody, out var expressionBody, out
var
semicolon);
3635
var
style = this.CurrentToken.Kind is SyntaxKind.ImplicitKeyword or SyntaxKind.ExplicitKeyword
3642
SyntaxToken
opKeyword;
3672
var
checkedKeyword = TryEatCheckedOrHandleUnchecked(ref opKeyword);
3691
this.ParseBlockAndExpressionBodiesWithSemicolon(out var blockBody, out var expressionBody, out
var
semicolon);
3719
SyntaxToken
separator = null;
3777
private
SyntaxToken
TryEatCheckedOrHandleUnchecked(ref
SyntaxToken
operatorKeyword)
3798
var
firstToken = this.CurrentToken;
3825
var
opKeyword = this.EatToken(SyntaxKind.OperatorKeyword);
3826
var
checkedKeyword = TryEatCheckedOrHandleUnchecked(ref opKeyword);
3827
SyntaxToken
opToken;
3874
var
tk = this.CurrentToken;
3878
var
opToken2 = this.EatToken();
3935
this.ParseBlockAndExpressionBodiesWithSemicolon(out var blockBody, out var expressionBody, out
var
semicolon);
3965
SyntaxToken
thisKeyword,
3981
SyntaxToken
semicolon = null;
4025
SyntaxToken
identifier,
4062
var
equals = this.EatToken(SyntaxKind.EqualsToken);
4067
SyntaxToken
semicolon = null;
4116
var
openBrace = this.EatToken(SyntaxKind.OpenBraceToken);
4161
var
refKeyword = this.CurrentToken.Kind == SyntaxKind.RefKeyword && !this.IsPossibleLambdaExpression(Precedence.Expression)
4169
private PostSkipAction SkipBadAccessorListTokens(ref
SyntaxToken
openBrace, SyntaxListBuilder<AccessorDeclarationSyntax> list, ErrorCode error)
4216
var
token = this.PeekToken(peekIndex);
4353
var
token = (first && !this.CurrentToken.ContainsDiagnostics) ? this.EatTokenWithPrejudice(expected) : this.EatToken();
4379
var
token = (first && !this.CurrentToken.ContainsDiagnostics) ? this.EatTokenWithPrejudice(errorCode) : this.EatToken();
4402
var
accessorName = this.EatToken(SyntaxKind.IdentifierToken,
4433
SyntaxToken
semicolon = null;
4487
private
SyntaxToken
EatAccessorSemicolon()
4493
private static SyntaxKind GetAccessorKind(
SyntaxToken
accessorName)
4513
var parameters = this.ParseParameterList(out
var
open, out
var
close, SyntaxKind.OpenParenToken, SyntaxKind.CloseParenToken);
4524
var parameters = this.ParseParameterList(out
var
open, out
var
close, SyntaxKind.OpenBracketToken, SyntaxKind.CloseBracketToken);
4585
out
SyntaxToken
open,
4586
out
SyntaxToken
close,
4611
LanguageParser @this, ref
SyntaxToken
open, SeparatedSyntaxListBuilder<ParameterSyntax> list, SyntaxKind expectedKind, SyntaxKind closeKind)
4700
SyntaxToken
identifier;
4719
var
equalsToken = TryEatToken(SyntaxKind.EqualsToken);
4729
internal static bool NoTriviaBetween(
SyntaxToken
token1,
SyntaxToken
token2)
4734
private static bool IsParameterModifierExcludingScoped(
SyntaxToken
token)
4766
SyntaxToken
scopedKeyword = ParsePossibleScopedKeyword(isFunctionPointerParameter);
4806
var
eventToken = this.EatToken();
4817
SyntaxToken
eventToken,
4821
SyntaxToken
identifierOrThisOpt;
4847
SyntaxToken
identifier;
4878
SyntaxToken
semicolon = null;
4909
var
semi = this.EatToken();
4926
if (modifiers is [..,
SyntaxToken
{ Kind: SyntaxKind.ScopedKeyword } scopedKeyword])
4942
SyntaxToken
eventToken,
5019
SyntaxList<
SyntaxToken
> mods,
5206
SyntaxList<
SyntaxToken
> mods,
5277
var
missingIdentifier = CreateMissingIdentifierToken();
5295
var
name = this.ParseIdentifierToken();
5322
var
equals = this.EatToken();
5325
var
refKeyword = isLocalOrField && !isConst && this.CurrentToken.Kind == SyntaxKind.RefKeyword && !this.IsPossibleLambdaExpression(Precedence.Expression)
5393
args.AddSeparator((
SyntaxToken
)item);
5497
var
delegateToken = this.EatToken(SyntaxKind.DelegateKeyword);
5501
var
name = this.ParseIdentifierToken();
5530
var
enumToken = this.EatToken(SyntaxKind.EnumKeyword);
5531
var
name = this.ParseIdentifierToken();
5545
var
colon = this.EatToken(SyntaxKind.ColonToken);
5555
SyntaxToken
semicolon;
5556
SyntaxToken
openBrace;
5557
SyntaxToken
closeBrace;
5601
LanguageParser @this, ref
SyntaxToken
openBrace, SeparatedSyntaxListBuilder<EnumMemberDeclarationSyntax> list, SyntaxKind expectedKind, SyntaxKind closeKind)
5618
var
memberName = this.ParseIdentifierToken();
5654
private static
SyntaxToken
CreateMissingIdentifierToken()
5696
private bool IsTrueIdentifier(
SyntaxToken
token)
5717
private
SyntaxToken
ParseIdentifierToken(ErrorCode code = ErrorCode.ERR_IdentifierExpected)
5730
var
result = CreateMissingIdentifierToken();
5735
SyntaxToken
identifierToken = this.EatToken();
5785
var
open = this.EatToken(SyntaxKind.LessThanToken);
5804
LanguageParser @this, ref
SyntaxToken
open, SeparatedSyntaxListBuilder<TypeParameterSyntax> list, SyntaxKind expectedKind, SyntaxKind closeKind)
5880
this.ParseTypeArgumentList(out
var
open, types, out
var
close);
5934
out
var
greaterThanToken, out bool isDefinitelyTypeArgumentList);
6030
out
SyntaxToken
greaterThanToken,
6043
var
start = this.EatToken();
6218
private void ParseTypeArgumentList(out
SyntaxToken
open, SeparatedSyntaxListBuilder<TypeSyntax> types, out
SyntaxToken
close)
6291
static bool tokenBreaksTypeArgumentList(
SyntaxToken
token)
6436
out
SyntaxToken
identifierOrThisOpt,
6452
SyntaxToken
separator = null;
6572
private void AccumulateExplicitInterfaceName(ref NameSyntax explicitInterfaceName, ref
SyntaxToken
separator)
6634
SyntaxToken
separator = null;
6721
var
separator = this.EatToken();
6731
SyntaxToken
separator)
6773
private
SyntaxToken
ConvertToMissingWithTrailingTrivia(
SyntaxToken
token, SyntaxKind expectedKind)
6775
var
newToken = SyntaxFactory.MissingToken(expectedKind);
6843
private ScanTypeFlags ScanType(out
SyntaxToken
lastTokenOfType, bool forPattern = false)
6853
private ScanTypeFlags ScanNamedTypePart(out
SyntaxToken
lastTokenOfType)
6872
private ScanTypeFlags ScanType(ParseTypeMode mode, out
SyntaxToken
lastTokenOfType)
7046
private ScanTypeFlags ScanTupleType(out
SyntaxToken
lastTokenOfType)
7090
private ScanTypeFlags ScanFunctionPointerType(out
SyntaxToken
lastTokenOfType)
7100
var
peek1 = PeekToken(1);
7160
var ignoredModifiers = _pool.Allocate<
SyntaxToken
>();
7298
var
question = TryEatNullableQualifierIfApplicable(type, mode);
7360
private
SyntaxToken
TryEatNullableQualifierIfApplicable(
7374
var
questionToken = this.EatToken();
7452
var
nextToken = PeekToken(1);
7542
var
open = this.EatToken(SyntaxKind.OpenBracketToken);
7604
var
open = this.EatToken(SyntaxKind.OpenParenToken);
7643
private PostSkipAction SkipBadArrayRankSpecifierTokens(ref
SyntaxToken
openBracket, SeparatedSyntaxListBuilder<ExpressionSyntax> list, SyntaxKind expected)
7656
var
token = this.EatToken();
7689
var
@delegate = EatToken(SyntaxKind.DelegateKeyword);
7690
var
asterisk = EatToken(SyntaxKind.AsteriskToken);
7696
var
lessThanTokenError = WithAdditionalDiagnostics(SyntaxFactory.MissingToken(SyntaxKind.LessThanToken), GetExpectedTokenError(SyntaxKind.LessThanToken, SyntaxKind.None));
7714
var
lessThanToken = EatTokenAsKind(SyntaxKind.LessThanToken);
7723
var modifiers = _pool.Allocate<
SyntaxToken
>();
7773
SyntaxToken
managedSpecifier;
7774
SyntaxToken
peek1 = PeekToken(1);
7801
var
openBracket = EatToken(SyntaxKind.OpenBracketToken);
7821
var
closeBracket = EatToken(SyntaxKind.CloseBracketToken);
7849
private static bool IsPossibleFunctionPointerParameterListStart(
SyntaxToken
token)
8251
var
token1 = PeekToken(1);
8371
SyntaxToken
identifierOrThisOpt;
8534
SyntaxToken
nextToken = PeekToken(1);
8615
private bool? IsPossibleTypedIdentifierStart(
SyntaxToken
current,
SyntaxToken
next, bool allowThisKeyword)
8689
(
SyntaxToken
)openBrace,
8720
(
SyntaxToken
)openBrace,
8854
var
@fixed = this.EatToken(SyntaxKind.FixedKeyword);
8855
var
openParen = this.EatToken(SyntaxKind.OpenParenToken);
8939
var
@try = this.EatToken(SyntaxKind.TryKeyword);
9014
var
@catch = this.EatToken();
9021
var
openParen = this.EatToken();
9025
SyntaxToken
name = null;
9033
var
closeParen = this.EatToken(SyntaxKind.CloseParenToken);
9042
var
whenKeyword = this.EatContextualToken(SyntaxKind.WhenKeyword);
9054
var
openParen = this.EatToken(SyntaxKind.OpenParenToken);
9058
var
closeParen = this.EatToken(SyntaxKind.CloseParenToken);
9102
var
keyword = this.EatToken();
9113
var
@do = this.EatToken(SyntaxKind.DoKeyword);
9115
var
@while = this.EatToken(SyntaxKind.WhileKeyword);
9116
var
openParen = this.EatToken(SyntaxKind.OpenParenToken);
9179
var
forToken = this.EatToken(SyntaxKind.ForKeyword);
9180
var
openParen = this.EatToken(SyntaxKind.OpenParenToken);
9183
var
firstSemicolonToken = eatCommaOrSemicolon();
9189
var
secondSemicolonToken = eatCommaOrSemicolon();
9266
SyntaxToken
eatCommaOrSemicolon()
9271
SyntaxToken
eatUnexpectedTokensAndCloseParenToken()
9278
var
result = this.EatToken(SyntaxKind.CloseParenToken);
9285
SeparatedSyntaxList<ExpressionSyntax> parseForStatementExpressionList(ref
SyntaxToken
startToken, bool allowSemicolonAsSeparator)
9297
LanguageParser @this, ref
SyntaxToken
startToken, SeparatedSyntaxListBuilder<ExpressionSyntax> list, SyntaxKind expectedKind, SyntaxKind closeKind)
9315
SyntaxList<AttributeListSyntax> attributes,
SyntaxToken
awaitTokenOpt)
9325
SyntaxToken
@foreach;
9331
var
skippedForToken = this.EatToken();
9340
var
openParen = this.EatToken(SyntaxKind.OpenParenToken);
9343
var
@in = this.EatToken(SyntaxKind.InKeyword, ErrorCode.ERR_InExpected);
9350
var
closeParen = this.EatToken(SyntaxKind.CloseParenToken);
9358
SyntaxToken
identifier;
9368
identifier =
SyntaxToken
.WithValue(SyntaxKind.IdentifierToken, discard.LeadingTrivia.Node, discard.Text, discard.ValueText, discard.TrailingTrivia.Node);
9466
SyntaxToken
lastTokenOfType;
9537
var
@goto = this.EatToken(SyntaxKind.GotoKeyword);
9539
SyntaxToken
caseOrDefault = null;
9570
var stack = ArrayBuilder<(
SyntaxToken
,
SyntaxToken
, ExpressionSyntax,
SyntaxToken
, StatementSyntax,
SyntaxToken
)>.GetInstance();
9575
var
ifKeyword = this.EatToken(SyntaxKind.IfKeyword);
9576
var
openParen = this.EatToken(SyntaxKind.OpenParenToken);
9578
var
closeParen = this.EatToken(SyntaxKind.CloseParenToken);
9581
var
elseKeyword = this.CurrentToken.Kind != SyntaxKind.ElseKeyword ?
9680
var
yieldToken = ConvertToKeyword(this.EatToken());
9681
SyntaxToken
returnOrBreak;
9717
parseSwitchHeader(out
var
switchKeyword, out
var
openParen, out var expression, out
var
closeParen, out
var
openBrace);
9734
out
SyntaxToken
switchKeyword,
9735
out
SyntaxToken
openParen,
9737
out
SyntaxToken
closeParen,
9738
out
SyntaxToken
openBrace)
9802
var
caseKeyword = this.EatToken();
9880
private UsingStatementSyntax ParseUsingStatement(SyntaxList<AttributeListSyntax> attributes,
SyntaxToken
awaitTokenOpt = null)
9882
var
@using = this.EatToken(SyntaxKind.UsingKeyword);
9883
var
openParen = this.EatToken(SyntaxKind.OpenParenToken);
9921
SyntaxToken
scopedKeyword = ParsePossibleScopedKeyword(isFunctionPointerParameter: false);
10037
SyntaxToken
awaitKeyword, usingKeyword;
10062
SyntaxToken
scopedKeyword = ParsePossibleScopedKeyword(isFunctionPointerParameter: false);
10094
if (attributes.Count == 0 && mods.Count > 0 && IsAccessibilityModifier(((
SyntaxToken
)mods[0]).ContextualKind))
10112
var
mod = (
SyntaxToken
)mods[i];
10135
private
SyntaxToken
ParsePossibleScopedKeyword(bool isFunctionPointerParameter)
10141
SyntaxToken
scopedKeyword = this.EatContextualToken(SyntaxKind.ScopedKeyword);
10174
var
openParen = this.EatToken(SyntaxKind.OpenParenToken);
10247
VariableFlags initialFlags,
SyntaxToken
? scopedKeyword)
10273
SyntaxList<
SyntaxToken
> mods,
10274
SyntaxToken
? scopedKeyword,
10329
SyntaxToken
mod;
10448
SyntaxList<
SyntaxToken
> modifiers,
10450
SyntaxToken
identifier)
10475
var
modifier = modifiers[i];
10538
SyntaxToken
semicolon;
10571
SyntaxToken
semicolon;
10914
var
next = PeekToken(1);
11106
var
operatorToken = eatOperatorToken(operatorTokenKind);
11185
var
token1 = this.CurrentToken;
11239
SyntaxToken
eatOperatorToken(SyntaxKind operatorTokenKind)
11251
var
token1 = EatToken();
11252
var
token2 = EatToken();
11264
var
token1 = EatToken();
11266
var
token3 = EatToken();
11289
var
questionToken = this.EatToken();
11378
public static bool IsAtDotDotToken(
SyntaxToken
token1,
SyntaxToken
token2)
11386
public
SyntaxToken
EatDotDotToken()
11389
var
token1 = this.EatToken();
11390
var
token2 = this.EatToken();
11392
var
dotDotToken = SyntaxFactory.Token(token1.GetLeadingTrivia(), SyntaxKind.DotDotToken, token2.GetTrailingTrivia());
11424
var
scopedKeyword = isScoped
11441
private ExpressionSyntax ParseIsExpression(ExpressionSyntax leftOperand,
SyntaxToken
opToken)
11582
var
refKeyword = this.EatToken();
11795
var
nextToken = this.PeekToken(1);
11896
openToken: out
SyntaxToken
openToken,
11898
closeToken: out
SyntaxToken
closeToken,
11912
openToken: out
SyntaxToken
openToken,
11914
closeToken: out
SyntaxToken
closeToken,
11921
out
SyntaxToken
openToken,
11923
out
SyntaxToken
closeToken,
11991
LanguageParser @this, ref
SyntaxToken
open, SeparatedSyntaxListBuilder<ArgumentSyntax> list, SyntaxKind expectedKind, SyntaxKind closeKind)
12034
SyntaxToken
refKindKeyword = null;
12080
var
keyword = this.EatToken();
12124
var
checkedOrUnchecked = this.EatToken();
12167
var
tk = this.PeekToken(curTk++);
12216
var
token1 = this.PeekToken(1);
12224
var
token2 = this.PeekToken(2);
12283
var
identifier = this.IsTrueIdentifier() ? this.EatToken() : CreateMissingIdentifierToken();
12285
var
equalsToken = TryEatToken(SyntaxKind.EqualsToken);
12343
var
openParen = this.EatToken(SyntaxKind.OpenParenToken);
12371
private TupleExpressionSyntax ParseTupleExpressionTail(
SyntaxToken
openParen, ArgumentSyntax firstArg)
12536
var
token1 = this.PeekToken(1);
12739
var
openBracket = this.EatToken(SyntaxKind.OpenBracketToken);
12756
LanguageParser @this, ref
SyntaxToken
openBracket, SeparatedSyntaxListBuilder<CollectionElementSyntax> list, SyntaxKind expectedKind, SyntaxKind closeKind)
12785
var
@new = this.EatToken(SyntaxKind.NewKeyword);
12789
var
openBrace = this.EatToken(SyntaxKind.OpenBraceToken);
12839
SyntaxToken
@new = this.EatToken(SyntaxKind.NewKeyword);
12912
private WithExpressionSyntax ParseWithExpression(ExpressionSyntax receiverExpression,
SyntaxToken
withKeyword)
12914
var
openBrace = this.EatToken(SyntaxKind.OpenBraceToken);
12939
var
openBrace = this.EatToken(SyntaxKind.OpenBraceToken);
13013
LanguageParser @this, ref
SyntaxToken
startToken, SeparatedSyntaxListBuilder<T> list, SyntaxKind expectedKind, SyntaxKind closeKind)
13046
var
openBrace = this.EatToken(SyntaxKind.OpenBraceToken);
13073
var
@new = this.EatToken(SyntaxKind.NewKeyword);
13074
var
openBracket = this.EatToken(SyntaxKind.OpenBracketToken);
13113
var
openBrace = this.EatToken(SyntaxKind.OpenBraceToken);
13131
LanguageParser @this, ref
SyntaxToken
openBrace, SeparatedSyntaxListBuilder<ExpressionSyntax> list, SyntaxKind expectedKind, SyntaxKind closeKind)
13149
var
@stackalloc = this.EatToken(SyntaxKind.StackAllocKeyword);
13150
var
openBracket = this.EatToken(SyntaxKind.OpenBracketToken);
13208
var
@delegate = this.EatToken(SyntaxKind.DelegateKeyword);
13227
var
openBrace = this.EatToken(SyntaxKind.OpenBraceToken);
13249
private SyntaxList<
SyntaxToken
> ParseAnonymousFunctionModifiers()
13348
var
arrow = this.EatToken(SyntaxKind.EqualsGreaterThanToken);
13358
var
identifier = (this.CurrentToken.Kind != SyntaxKind.IdentifierToken && this.PeekToken(1).Kind == SyntaxKind.EqualsGreaterThanToken)
13363
var
arrow = this.EatToken(SyntaxKind.EqualsGreaterThanToken);
13381
var
openParen = this.EatToken(SyntaxKind.OpenParenToken);
13403
LanguageParser @this, ref
SyntaxToken
openParen, SeparatedSyntaxListBuilder<ParameterSyntax> list, SyntaxKind expectedKind, SyntaxKind closeKind)
13453
var
identifier = this.ParseIdentifierToken();
13456
var
equalsToken = TryEatToken(SyntaxKind.EqualsToken);
13498
var
peek1 = this.PeekToken(1);
13515
private static bool IsTokenQueryContextualKeyword(
SyntaxToken
token)
13535
private static bool IsTokenStartOfNewQueryClause(
SyntaxToken
token)
13677
var
@from = this.EatContextualToken(SyntaxKind.FromKeyword);
13683
SyntaxToken
name;
13748
var
@orderby = this.EatContextualToken(SyntaxKind.OrderByKeyword);
13793
SyntaxToken
direction = null;
13889
LanguageParser parser, ref
SyntaxToken
openToken, SeparatedSyntaxListBuilder<TNode> builder, SyntaxKind expectedKind, SyntaxKind closeTokenKind) where TNode : GreenNode;
13921
ref
SyntaxToken
openToken,
13943
ref
SyntaxToken
openToken,
14119
SyntaxListBuilder<
SyntaxToken
> b = _pool.Allocate<
SyntaxToken
>();
Parser\LanguageParser_InterpolatedString.cs (10)
41
var
originalToken = this.EatToken();
78
SyntaxToken
getOpenQuote()
238
SyntaxToken
getCloseQuote()
319
private static
SyntaxToken
TokenOrMissingToken(GreenNode? leading, SyntaxKind kind, string text, GreenNode? trailing)
395
SyntaxToken
openBraceToken)
421
(InterpolationFormatClauseSyntax? format,
SyntaxToken
closeBraceToken) getFormatAndCloseBrace()
437
SyntaxToken
getInterpolationCloseToken(GreenNode? leading)
452
private
SyntaxToken
MakeInterpolatedStringTextToken(Lexer.InterpolatedStringKind kind, string text)
467
var
token = tempLexer.Lex(ref mode);
469
var
result = SyntaxFactory.Literal(leading: null, text, SyntaxKind.InterpolatedStringTextToken, token.ValueText, trailing: null);
Parser\LanguageParser_Patterns.cs (9)
279
var
varToken = ConvertToKeyword(typeIdentifierToken);
289
var
openParenToken = this.EatToken(SyntaxKind.OpenParenToken);
299
var
closeParenToken = this.EatToken(SyntaxKind.CloseParenToken);
486
var
openBraceToken = this.EatToken(SyntaxKind.OpenBraceToken);
511
var
colon = EatToken();
540
LanguageParser @this, ref
SyntaxToken
open, SeparatedSyntaxListBuilder<T> list, SyntaxKind expectedKind, SyntaxKind closeKind)
568
private SwitchExpressionSyntax ParseSwitchExpression(ExpressionSyntax governingExpression,
SyntaxToken
switchKeyword)
624
var
commaToken = this.CurrentToken.Kind == SyntaxKind.SemicolonToken
637
var
openBracket = this.EatToken(SyntaxKind.OpenBracketToken);
Parser\Lexer.cs (19)
229
public
SyntaxToken
Lex(ref LexerMode mode)
231
var
result = Lex(mode);
240
public
SyntaxToken
Lex(LexerMode mode)
303
private
SyntaxToken
LexSyntaxToken()
338
private
SyntaxToken
Create(in TokenInfo info, SyntaxListBuilder? leading, SyntaxListBuilder? trailing, SyntaxDiagnosticInfo[]? errors)
345
SyntaxToken
token;
2490
private
SyntaxToken
LexDirectiveToken()
2503
var
token = Create(in info, null, directiveTriviaCache, errors);
2509
public
SyntaxToken
LexEndOfDirectiveWithOptionalPreprocessingMessage()
2546
var
endOfDirective = SyntaxFactory.Token(leading, SyntaxKind.EndOfDirectiveToken, trailing);
2826
private
SyntaxToken
LexXmlToken()
3182
private
SyntaxToken
LexXmlElementTagToken()
3197
SyntaxToken
? token = DocumentationCommentXmlTokens.LookupToken(tagInfo.Text, leading);
3368
private
SyntaxToken
LexXmlAttributeTextToken()
3521
private
SyntaxToken
LexXmlCharacter()
3577
private
SyntaxToken
LexXmlCrefOrNameToken()
3990
private
SyntaxToken
LexXmlCDataSectionTextToken()
4112
private
SyntaxToken
LexXmlCommentTextToken()
4242
private
SyntaxToken
LexXmlProcessingInstructionTextToken()
Parser\Lexer_StringLiteral.cs (1)
300
internal static
SyntaxToken
RescanInterpolatedString(InterpolatedStringExpressionSyntax interpolatedString)
Parser\LexerCache.cs (4)
34
private readonly TextKeyedCache<
SyntaxToken
> _tokenMap;
41
_tokenMap = TextKeyedCache<
SyntaxToken
>.GetInstance();
104
internal
SyntaxToken
LookupToken<TArg>(
109
Func<TArg,
SyntaxToken
> createTokenFunction,
Parser\QuickScanner.cs (4)
192
private
SyntaxToken
? QuickScanSyntaxToken()
237
var
token = _cache.LookupToken(
253
private static
SyntaxToken
CreateQuickToken(Lexer lexer)
259
var
token = lexer.LexSyntaxToken();
Parser\SyntaxParser.cs (55)
29
private
SyntaxToken
_currentToken;
30
private ArrayElement<
SyntaxToken
>[] _lexedTokens;
39
private static readonly ObjectPool<ArrayElement<
SyntaxToken
>[]> s_lexedTokensPool = new ObjectPool<ArrayElement<
SyntaxToken
>[]>(() => new ArrayElement<
SyntaxToken
>[CachedTokenArraySize], 2);
149
var
token = lexer.Lex(mode);
316
protected
SyntaxToken
CurrentToken
324
private
SyntaxToken
FetchCurrentToken()
380
private void AddLexedToken(
SyntaxToken
token)
454
private void ReturnLexedTokensToPool(ArrayElement<
SyntaxToken
>[] lexedTokens)
466
protected
SyntaxToken
PeekToken(int n)
486
protected
SyntaxToken
EatToken()
488
var
ct = this.CurrentToken;
497
protected
SyntaxToken
TryEatToken(SyntaxKind kind)
521
protected
SyntaxToken
EatToken(SyntaxKind kind)
525
var
ct = this.CurrentToken;
537
protected
SyntaxToken
EatTokenAsKind(SyntaxKind expected)
541
var
ct = this.CurrentToken;
548
var
replacement = CreateMissingToken(expected, this.CurrentToken.Kind, reportError: true);
552
private
SyntaxToken
CreateMissingToken(SyntaxKind expected, SyntaxKind actual, bool reportError)
555
var
token = SyntaxFactory.MissingToken(expected);
564
private
SyntaxToken
CreateMissingToken(SyntaxKind expected, ErrorCode code, bool reportError)
567
var
token = SyntaxFactory.MissingToken(expected);
576
protected
SyntaxToken
EatToken(SyntaxKind kind, bool reportError)
595
protected
SyntaxToken
EatToken(SyntaxKind kind, ErrorCode code, bool reportError = true)
608
protected
SyntaxToken
EatTokenWithPrejudice(SyntaxKind kind)
610
var
token = this.CurrentToken;
621
protected
SyntaxToken
EatTokenWithPrejudice(ErrorCode errorCode, params object[] args)
623
var
token = this.EatToken();
628
protected
SyntaxToken
EatContextualToken(SyntaxKind kind, ErrorCode code, bool reportError = true)
642
protected
SyntaxToken
EatContextualToken(SyntaxKind kind, bool reportError = true)
736
SyntaxToken
ct = this.CurrentToken;
778
SyntaxToken
token = node as
SyntaxToken
;
834
var
firstToken = node.GetFirstToken();
840
var
firstToken = node.GetFirstToken();
862
var
lastToken = node.GetLastNonmissingToken();
900
var
oldToken = node as
SyntaxToken
?? node.GetFirstToken();
901
var
newToken = AddSkippedSyntax(oldToken, skippedSyntax, trailing: false);
919
var
token = node as
SyntaxToken
;
926
var
lastToken = node.GetLastToken();
927
var
newToken = AddSkippedSyntax(lastToken, skippedSyntax, trailing: true);
936
internal
SyntaxToken
AddSkippedSyntax(
SyntaxToken
target, GreenNode skippedSyntax, bool trailing)
949
SyntaxToken
token = node as
SyntaxToken
;
957
SyntaxToken
tk = token.TokenWithLeadingTrivia(null).TokenWithTrailingTrivia(null);
1096
protected static
SyntaxToken
ConvertToKeyword(
SyntaxToken
token)
1115
protected static
SyntaxToken
ConvertToIdentifier(
SyntaxToken
token)
1119
var
identifier =
SyntaxToken
.Identifier(token.Kind, token.LeadingTrivia.Node, token.Text, token.ValueText, token.TrailingTrivia.Node);
Symbols\Source\AttributeLocation.cs (1)
123
internal static AttributeLocation ToAttributeLocation(this Syntax.InternalSyntax.
SyntaxToken
token)
Syntax\InternalSyntax\CSharpSyntaxNode.cs (8)
98
public
SyntaxToken
GetFirstToken()
100
return (
SyntaxToken
)this.GetFirstTerminal();
103
public
SyntaxToken
GetLastToken()
105
return (
SyntaxToken
)this.GetLastTerminal();
108
public
SyntaxToken
GetLastNonmissingToken()
110
return (
SyntaxToken
)this.GetLastNonmissingTerminal();
199
var
t = node as
SyntaxToken
;
Syntax\InternalSyntax\CSharpSyntaxRewriter.cs (1)
21
public override CSharpSyntaxNode VisitToken(
SyntaxToken
token)
Syntax\InternalSyntax\CSharpSyntaxVisitor.cs (2)
25
public virtual TResult VisitToken(
SyntaxToken
token)
53
public virtual void VisitToken(
SyntaxToken
token)
Syntax\InternalSyntax\SyntaxFactory.cs (55)
32
private static
SyntaxToken
s_xmlCarriageReturnLineFeed;
33
private static
SyntaxToken
XmlCarriageReturnLineFeed
116
public static
SyntaxToken
Token(SyntaxKind kind)
118
return
SyntaxToken
.Create(kind);
121
internal static
SyntaxToken
Token(GreenNode leading, SyntaxKind kind, GreenNode trailing)
123
return
SyntaxToken
.Create(kind, leading, trailing);
127
/// Creates a token whose <see cref="
SyntaxToken
.Text"/> and <see cref="
SyntaxToken
.ValueText"/> are the same.
129
internal static
SyntaxToken
Token(GreenNode leading, SyntaxKind kind, string text, GreenNode trailing)
134
internal static
SyntaxToken
Token(GreenNode leading, SyntaxKind kind, string text, string valueText, GreenNode trailing)
142
return kind >=
SyntaxToken
.FirstTokenWithWellKnownText && kind <=
SyntaxToken
.LastTokenWithWellKnownText && text == defaultText && valueText == defaultText
144
:
SyntaxToken
.WithValue(kind, leading, text, valueText, trailing);
147
internal static
SyntaxToken
MissingToken(SyntaxKind kind)
149
return
SyntaxToken
.CreateMissing(kind);
152
internal static
SyntaxToken
MissingToken(GreenNode leading, SyntaxKind kind, GreenNode trailing)
154
return
SyntaxToken
.CreateMissing(kind, leading, trailing);
157
internal static
SyntaxToken
Identifier(string text)
162
internal static
SyntaxToken
Identifier(GreenNode leading, string text, GreenNode trailing)
167
internal static
SyntaxToken
Identifier(SyntaxKind contextualKind, GreenNode leading, string text, string valueText, GreenNode trailing)
169
return
SyntaxToken
.Identifier(contextualKind, leading, text, valueText, trailing);
172
internal static
SyntaxToken
Literal(GreenNode leading, string text, int value, GreenNode trailing)
174
return
SyntaxToken
.WithValue(SyntaxKind.NumericLiteralToken, leading, text, value, trailing);
177
internal static
SyntaxToken
Literal(GreenNode leading, string text, uint value, GreenNode trailing)
179
return
SyntaxToken
.WithValue(SyntaxKind.NumericLiteralToken, leading, text, value, trailing);
182
internal static
SyntaxToken
Literal(GreenNode leading, string text, long value, GreenNode trailing)
184
return
SyntaxToken
.WithValue(SyntaxKind.NumericLiteralToken, leading, text, value, trailing);
187
internal static
SyntaxToken
Literal(GreenNode leading, string text, ulong value, GreenNode trailing)
189
return
SyntaxToken
.WithValue(SyntaxKind.NumericLiteralToken, leading, text, value, trailing);
192
internal static
SyntaxToken
Literal(GreenNode leading, string text, float value, GreenNode trailing)
194
return
SyntaxToken
.WithValue(SyntaxKind.NumericLiteralToken, leading, text, value, trailing);
197
internal static
SyntaxToken
Literal(GreenNode leading, string text, double value, GreenNode trailing)
199
return
SyntaxToken
.WithValue(SyntaxKind.NumericLiteralToken, leading, text, value, trailing);
202
internal static
SyntaxToken
Literal(GreenNode leading, string text, decimal value, GreenNode trailing)
204
return
SyntaxToken
.WithValue(SyntaxKind.NumericLiteralToken, leading, text, value, trailing);
207
internal static
SyntaxToken
Literal(GreenNode leading, string text, string value, GreenNode trailing)
209
return
SyntaxToken
.WithValue(SyntaxKind.StringLiteralToken, leading, text, value, trailing);
212
internal static
SyntaxToken
Literal(GreenNode leading, string text, SyntaxKind kind, string value, GreenNode trailing)
214
return
SyntaxToken
.WithValue(kind, leading, text, value, trailing);
217
internal static
SyntaxToken
Literal(GreenNode leading, string text, char value, GreenNode trailing)
219
return
SyntaxToken
.WithValue(SyntaxKind.CharacterLiteralToken, leading, text, value, trailing);
222
internal static
SyntaxToken
BadToken(GreenNode leading, string text, GreenNode trailing)
224
return
SyntaxToken
.WithValue(SyntaxKind.BadToken, leading, text, text, trailing);
227
internal static
SyntaxToken
XmlTextLiteral(GreenNode leading, string text, string value, GreenNode trailing)
229
return
SyntaxToken
.WithValue(SyntaxKind.XmlTextLiteralToken, leading, text, value, trailing);
232
internal static
SyntaxToken
XmlTextNewLine(GreenNode leading, string text, string value, GreenNode trailing)
239
return
SyntaxToken
.WithValue(SyntaxKind.XmlTextLiteralNewLineToken, leading, text, value, trailing);
242
internal static
SyntaxToken
XmlTextNewLine(string text)
244
return
SyntaxToken
.WithValue(SyntaxKind.XmlTextLiteralNewLineToken, null, text, text, null);
247
internal static
SyntaxToken
XmlEntity(GreenNode leading, string text, string value, GreenNode trailing)
249
return
SyntaxToken
.WithValue(SyntaxKind.XmlEntityLiteralToken, leading, text, value, trailing);
307
public static SeparatedSyntaxList<TNode> SeparatedList<TNode>(
SyntaxToken
token) where TNode : CSharpSyntaxNode
312
public static SeparatedSyntaxList<TNode> SeparatedList<TNode>(TNode node1,
SyntaxToken
token, TNode node2) where TNode : CSharpSyntaxNode
344
internal static IEnumerable<
SyntaxToken
> GetWellKnownTokens()
346
return
SyntaxToken
.GetWellKnownTokens();
Syntax\InternalSyntax\SyntaxFirstTokenReplacer.cs (8)
16
private readonly
SyntaxToken
_oldToken;
17
private readonly
SyntaxToken
_newToken;
21
private SyntaxFirstTokenReplacer(
SyntaxToken
oldToken,
SyntaxToken
newToken, int diagnosticOffsetDelta)
29
internal static TRoot Replace<TRoot>(TRoot root,
SyntaxToken
oldToken,
SyntaxToken
newToken, int diagnosticOffsetDelta)
44
var
token = node as
SyntaxToken
;
Syntax\InternalSyntax\SyntaxLastTokenReplacer.cs (8)
16
private readonly
SyntaxToken
_oldToken;
17
private readonly
SyntaxToken
_newToken;
21
private SyntaxLastTokenReplacer(
SyntaxToken
oldToken,
SyntaxToken
newToken)
27
internal static TRoot Replace<TRoot>(TRoot root,
SyntaxToken
newToken)
30
var
oldToken = root.GetLastToken();
49
var
token = node as
SyntaxToken
;
Syntax\InternalSyntax\SyntaxListPoolExtensions.cs (2)
11
public static SyntaxList<
SyntaxToken
> ToTokenListAndFree(this SyntaxListPool pool, SyntaxListBuilder builder)
15
return new SyntaxList<
SyntaxToken
>(listNode);
Syntax\InternalSyntax\SyntaxToken.cs (29)
70
internal static
SyntaxToken
Create(SyntaxKind kind)
85
internal static
SyntaxToken
Create(SyntaxKind kind, GreenNode leading, GreenNode trailing)
121
internal static
SyntaxToken
CreateMissing(SyntaxKind kind)
135
internal static
SyntaxToken
CreateMissing(SyntaxKind kind, GreenNode leading, GreenNode trailing)
144
private static readonly ArrayElement<
SyntaxToken
>[] s_tokensWithNoTrivia = new ArrayElement<
SyntaxToken
>[(int)LastTokenWithWellKnownText + 1];
145
private static readonly ArrayElement<
SyntaxToken
>[] s_tokensWithElasticTrivia = new ArrayElement<
SyntaxToken
>[(int)LastTokenWithWellKnownText + 1];
146
private static readonly ArrayElement<
SyntaxToken
>[] s_tokensWithSingleTrailingSpace = new ArrayElement<
SyntaxToken
>[(int)LastTokenWithWellKnownText + 1];
147
private static readonly ArrayElement<
SyntaxToken
>[] s_tokensWithSingleTrailingCRLF = new ArrayElement<
SyntaxToken
>[(int)LastTokenWithWellKnownText + 1];
148
private static readonly ArrayElement<
SyntaxToken
>[] s_missingTokensWithNoTrivia = new ArrayElement<
SyntaxToken
>[(int)LastTokenWithWellKnownText + 1];
150
private static readonly
SyntaxToken
s_missingIdentifierTokenWithNoTrivia = new MissingTokenWithTrivia(SyntaxKind.IdentifierToken, leading: null, trailing: null);
164
internal static IEnumerable<
SyntaxToken
> GetWellKnownTokens()
199
internal static
SyntaxToken
Identifier(string text)
204
internal static
SyntaxToken
Identifier(GreenNode leading, string text, GreenNode trailing)
221
internal static
SyntaxToken
Identifier(SyntaxKind contextualKind, GreenNode leading, string text, string valueText, GreenNode trailing)
231
internal static
SyntaxToken
WithValue<T>(SyntaxKind kind, string text, T value)
236
internal static
SyntaxToken
WithValue<T>(SyntaxKind kind, GreenNode leading, string text, T value, GreenNode trailing)
241
internal static
SyntaxToken
StringLiteral(string text)
246
internal static
SyntaxToken
StringLiteral(CSharpSyntaxNode leading, string text, CSharpSyntaxNode trailing)
347
public virtual
SyntaxToken
TokenWithLeadingTrivia(GreenNode trivia)
357
public virtual
SyntaxToken
TokenWithTrailingTrivia(GreenNode trivia)
364
System.Diagnostics.Debug.Assert(this.GetType() == typeof(
SyntaxToken
));
370
System.Diagnostics.Debug.Assert(this.GetType() == typeof(
SyntaxToken
));
435
var
otherToken = (
SyntaxToken
)other;
Syntax\InternalSyntax\SyntaxToken.MissingTokenWithTrivia.cs (2)
47
public override
SyntaxToken
TokenWithLeadingTrivia(GreenNode trivia)
52
public override
SyntaxToken
TokenWithTrailingTrivia(GreenNode trivia)
Syntax\InternalSyntax\SyntaxToken.SyntaxIdentifier.cs (2)
44
public override
SyntaxToken
TokenWithLeadingTrivia(GreenNode trivia)
49
public override
SyntaxToken
TokenWithTrailingTrivia(GreenNode trivia)
Syntax\InternalSyntax\SyntaxToken.SyntaxIdentifierExtended.cs (2)
47
public override
SyntaxToken
TokenWithLeadingTrivia(GreenNode trivia)
52
public override
SyntaxToken
TokenWithTrailingTrivia(GreenNode trivia)
Syntax\InternalSyntax\SyntaxToken.SyntaxIdentifierWithTrailingTrivia.cs (2)
40
public override
SyntaxToken
TokenWithLeadingTrivia(GreenNode trivia)
45
public override
SyntaxToken
TokenWithTrailingTrivia(GreenNode trivia)
Syntax\InternalSyntax\SyntaxToken.SyntaxIdentifierWithTrivia.cs (2)
68
public override
SyntaxToken
TokenWithLeadingTrivia(GreenNode trivia)
73
public override
SyntaxToken
TokenWithTrailingTrivia(GreenNode trivia)
Syntax\InternalSyntax\SyntaxToken.SyntaxLiteral.cs (2)
57
public override
SyntaxToken
TokenWithLeadingTrivia(GreenNode trivia)
62
public override
SyntaxToken
TokenWithTrailingTrivia(GreenNode trivia)
Syntax\InternalSyntax\SyntaxToken.SyntaxLiteralWithTrivia.cs (2)
63
public override
SyntaxToken
TokenWithLeadingTrivia(GreenNode trivia)
68
public override
SyntaxToken
TokenWithTrailingTrivia(GreenNode trivia)
Syntax\InternalSyntax\SyntaxToken.SyntaxTokenWithTrivia.cs (2)
56
public override
SyntaxToken
TokenWithLeadingTrivia(GreenNode trivia)
61
public override
SyntaxToken
TokenWithTrailingTrivia(GreenNode trivia)
Syntax\InternalSyntax\TypeDeclarationSyntax.cs (30)
15
CoreSyntax.SyntaxList<
SyntaxToken
> modifiers,
16
SyntaxToken
keyword,
17
SyntaxToken
identifier,
22
SyntaxToken
openBraceToken,
24
SyntaxToken
closeBraceToken,
25
SyntaxToken
semicolonToken);
32
CoreSyntax.SyntaxList<
SyntaxToken
> modifiers,
33
SyntaxToken
keyword,
34
SyntaxToken
identifier,
39
SyntaxToken
openBraceToken,
41
SyntaxToken
closeBraceToken,
42
SyntaxToken
semicolonToken)
64
CoreSyntax.SyntaxList<
SyntaxToken
> modifiers,
65
SyntaxToken
keyword,
66
SyntaxToken
identifier,
71
SyntaxToken
openBraceToken,
73
SyntaxToken
closeBraceToken,
74
SyntaxToken
semicolonToken)
96
CoreSyntax.SyntaxList<
SyntaxToken
> modifiers,
97
SyntaxToken
keyword,
98
SyntaxToken
identifier,
103
SyntaxToken
openBraceToken,
105
SyntaxToken
closeBraceToken,
106
SyntaxToken
semicolonToken)
129
CoreSyntax.SyntaxList<
SyntaxToken
> modifiers,
130
SyntaxToken
keyword,
131
SyntaxToken
identifier,
136
SyntaxToken
openBraceToken,
138
SyntaxToken
closeBraceToken,
139
SyntaxToken
semicolonToken)
Syntax\SyntaxEquivalence.cs (4)
80
if (((Green.
SyntaxToken
)before).ValueText != ((Green.
SyntaxToken
)after).ValueText)
95
if (((Green.
SyntaxToken
)before).Text != ((Green.
SyntaxToken
)after).Text)
Syntax\SyntaxFactory.cs (1)
1663
var
token = lexer.Lex(InternalSyntax.LexerMode.Syntax);
Syntax\SyntaxFacts.cs (2)
443
internal static bool IsIdentifierVar(this Syntax.InternalSyntax.
SyntaxToken
node)
448
internal static bool IsIdentifierVarOrPredefinedType(this Syntax.InternalSyntax.
SyntaxToken
node)
Syntax\SyntaxTokenParser.cs (3)
55
var
token = _lexer.Lex(InternalSyntax.LexerMode.Syntax);
70
var
containingToken = InternalSyntax.SyntaxFactory.MissingToken(leading: leadingTrivia.Node, SyntaxKind.None, trailing: null);
85
var
containingToken = InternalSyntax.SyntaxFactory.MissingToken(leading: null, SyntaxKind.None, trailing: trailingTrivia.Node);
Syntax\SyntaxTreeDiagnosticEnumerator.cs (3)
142
var
token = node as Syntax.InternalSyntax.
SyntaxToken
;
153
private void PushToken(Syntax.InternalSyntax.
SyntaxToken
token)
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (4)
IncrementalParsing\IncrementalParsingTests.cs (2)
3074
var
oldToken = ((Syntax.InternalSyntax.ClassDeclarationSyntax)oldClassC).Identifier;
3075
var
newToken = ((Syntax.InternalSyntax.ClassDeclarationSyntax)newClassC).Identifier;
LexicalAndXml\CrefLexerTests.cs (1)
448
var
token = lexer.Lex(InternalSyntax.LexerMode.XmlCrefQuote | InternalSyntax.LexerMode.XmlDocCommentStyleSingleLine | InternalSyntax.LexerMode.XmlDocCommentLocationInterior);
LexicalAndXml\NameAttributeValueLexerTests.cs (1)
412
var
token = lexer.Lex(InternalSyntax.LexerMode.XmlNameQuote | InternalSyntax.LexerMode.XmlDocCommentStyleSingleLine | InternalSyntax.LexerMode.XmlDocCommentLocationInterior);