11588 lines
448 KiB
C#
11588 lines
448 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
using System.Globalization;
|
|
using System.IO;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using Microsoft.CodeAnalysis.CSharp.Symbols;
|
|
using Microsoft.CodeAnalysis.PooledObjects;
|
|
using Microsoft.CodeAnalysis.Syntax.InternalSyntax;
|
|
using Microsoft.CodeAnalysis.Text;
|
|
using Roslyn.Utilities;
|
|
|
|
namespace Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax;
|
|
|
|
internal class LanguageParser : SyntaxParser
|
|
{
|
|
[Flags]
|
|
internal enum TerminatorState
|
|
{
|
|
EndOfFile = 0,
|
|
IsNamespaceMemberStartOrStop = 1,
|
|
IsAttributeDeclarationTerminator = 2,
|
|
IsPossibleAggregateClauseStartOrStop = 4,
|
|
IsPossibleMemberStartOrStop = 8,
|
|
IsEndOfReturnType = 0x10,
|
|
IsEndOfParameterList = 0x20,
|
|
IsEndOfFieldDeclaration = 0x40,
|
|
IsPossibleEndOfVariableDeclaration = 0x80,
|
|
IsEndOfTypeArgumentList = 0x100,
|
|
IsPossibleStatementStartOrStop = 0x200,
|
|
IsEndOfFixedStatement = 0x400,
|
|
IsEndOfTryBlock = 0x800,
|
|
IsEndOfCatchClause = 0x1000,
|
|
IsEndOfFilterClause = 0x2000,
|
|
IsEndOfCatchBlock = 0x4000,
|
|
IsEndOfDoWhileExpression = 0x8000,
|
|
IsEndOfForStatementArgument = 0x10000,
|
|
IsEndOfDeclarationClause = 0x20000,
|
|
IsEndOfArgumentList = 0x40000,
|
|
IsSwitchSectionStart = 0x80000,
|
|
IsEndOfTypeParameterList = 0x100000,
|
|
IsEndOfMethodSignature = 0x200000,
|
|
IsEndOfNameInExplicitInterface = 0x400000,
|
|
IsEndOfFunctionPointerParameterList = 0x800000,
|
|
IsEndOfFunctionPointerParameterListErrored = 0x1000000,
|
|
IsEndOfFunctionPointerCallingConvention = 0x2000000,
|
|
IsEndOfRecordOrClassOrStructOrInterfaceSignature = 0x4000000,
|
|
IsExpressionOrPatternInCaseLabelOfSwitchStatement = 0x8000000,
|
|
IsPatternInSwitchExpressionArm = 0x10000000
|
|
}
|
|
|
|
private struct NamespaceBodyBuilder(SyntaxListPool pool)
|
|
{
|
|
public SyntaxListBuilder<ExternAliasDirectiveSyntax> Externs = pool.Allocate<ExternAliasDirectiveSyntax>();
|
|
|
|
public SyntaxListBuilder<UsingDirectiveSyntax> Usings = pool.Allocate<UsingDirectiveSyntax>();
|
|
|
|
public SyntaxListBuilder<AttributeListSyntax> Attributes = pool.Allocate<AttributeListSyntax>();
|
|
|
|
public SyntaxListBuilder<MemberDeclarationSyntax> Members = pool.Allocate<MemberDeclarationSyntax>();
|
|
|
|
internal void Free(SyntaxListPool pool)
|
|
{
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
|
|
pool.Free(SyntaxListBuilder<MemberDeclarationSyntax>.op_Implicit(Members));
|
|
pool.Free(SyntaxListBuilder<AttributeListSyntax>.op_Implicit(Attributes));
|
|
pool.Free(SyntaxListBuilder<UsingDirectiveSyntax>.op_Implicit(Usings));
|
|
pool.Free(SyntaxListBuilder<ExternAliasDirectiveSyntax>.op_Implicit(Externs));
|
|
}
|
|
}
|
|
|
|
private enum NamespaceParts
|
|
{
|
|
None,
|
|
ExternAliases,
|
|
Usings,
|
|
GlobalAttributes,
|
|
MembersAndStatements,
|
|
TypesAndNamespaces,
|
|
TopLevelStatementsAfterTypesAndNamespaces
|
|
}
|
|
|
|
private enum PostSkipAction
|
|
{
|
|
Continue,
|
|
Abort
|
|
}
|
|
|
|
[Flags]
|
|
private enum VariableFlags
|
|
{
|
|
Fixed = 1,
|
|
Const = 2,
|
|
LocalOrField = 4
|
|
}
|
|
|
|
[Flags]
|
|
private enum NameOptions
|
|
{
|
|
None = 0,
|
|
InExpression = 1,
|
|
InTypeList = 2,
|
|
PossiblePattern = 4,
|
|
AfterIs = 8,
|
|
DefinitePattern = 0x10,
|
|
AfterOut = 0x20,
|
|
AfterTupleComma = 0x40,
|
|
FirstElementOfPossibleTupleLiteral = 0x80
|
|
}
|
|
|
|
private enum ScanTypeArgumentListKind
|
|
{
|
|
NotTypeArgumentList,
|
|
PossibleTypeArgumentList,
|
|
DefiniteTypeArgumentList
|
|
}
|
|
|
|
private enum ScanTypeFlags
|
|
{
|
|
NotType,
|
|
MustBeType,
|
|
GenericTypeOrMethod,
|
|
GenericTypeOrExpression,
|
|
NonGenericTypeOrExpression,
|
|
AliasQualifiedName,
|
|
NullableType,
|
|
PointerOrMultiplication,
|
|
TupleType
|
|
}
|
|
|
|
private enum ParseTypeMode
|
|
{
|
|
Normal,
|
|
Parameter,
|
|
AfterIs,
|
|
DefinitePattern,
|
|
AfterOut,
|
|
AfterRef,
|
|
AfterTupleComma,
|
|
AsExpression,
|
|
NewExpression,
|
|
FirstElementOfPossibleTupleLiteral
|
|
}
|
|
|
|
private enum Precedence : uint
|
|
{
|
|
Expression = 0u,
|
|
Assignment = 0u,
|
|
Lambda = 0u,
|
|
Conditional = 1u,
|
|
Coalescing = 2u,
|
|
ConditionalOr = 3u,
|
|
ConditionalAnd = 4u,
|
|
LogicalOr = 5u,
|
|
LogicalXor = 6u,
|
|
LogicalAnd = 7u,
|
|
Equality = 8u,
|
|
Relational = 9u,
|
|
Shift = 10u,
|
|
Additive = 11u,
|
|
Multiplicative = 12u,
|
|
Switch = 13u,
|
|
Range = 14u,
|
|
Unary = 15u,
|
|
Cast = 16u,
|
|
PointerIndirection = 17u,
|
|
AddressOf = 18u,
|
|
Primary = 19u
|
|
}
|
|
|
|
private delegate PostSkipAction SkipBadTokens<TNode>(LanguageParser parser, ref SyntaxToken openToken, SeparatedSyntaxListBuilder<TNode> builder, SyntaxKind expectedKind, SyntaxKind closeTokenKind) where TNode : GreenNode;
|
|
|
|
private ref struct DisposableResetPoint(LanguageParser languageParser, bool resetOnDispose, ResetPoint resetPoint)
|
|
{
|
|
private readonly LanguageParser _languageParser = languageParser;
|
|
|
|
private readonly bool _resetOnDispose = resetOnDispose;
|
|
|
|
private ResetPoint _resetPoint = resetPoint;
|
|
|
|
public void Reset()
|
|
{
|
|
_languageParser.Reset(ref _resetPoint);
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
if (_resetOnDispose)
|
|
{
|
|
Reset();
|
|
}
|
|
_languageParser.Release(ref _resetPoint);
|
|
}
|
|
}
|
|
|
|
private new struct ResetPoint
|
|
{
|
|
internal SyntaxParser.ResetPoint BaseResetPoint;
|
|
|
|
internal readonly TerminatorState TerminatorState;
|
|
|
|
internal readonly bool IsInAsync;
|
|
|
|
internal readonly bool IsInQuery;
|
|
|
|
internal ResetPoint(SyntaxParser.ResetPoint resetPoint, TerminatorState terminatorState, bool isInAsync, bool isInQuery)
|
|
{
|
|
BaseResetPoint = resetPoint;
|
|
TerminatorState = terminatorState;
|
|
IsInAsync = isInAsync;
|
|
IsInQuery = isInQuery;
|
|
}
|
|
}
|
|
|
|
private readonly SyntaxListPool _pool = new SyntaxListPool();
|
|
|
|
private readonly SyntaxFactoryContext _syntaxFactoryContext;
|
|
|
|
private readonly ContextAwareSyntax _syntaxFactory;
|
|
|
|
private int _recursionDepth;
|
|
|
|
private TerminatorState _termState;
|
|
|
|
private const int LastTerminatorState = 268435456;
|
|
|
|
private bool IsCurrentTokenQueryContextualKeyword => IsTokenQueryContextualKeyword(base.CurrentToken);
|
|
|
|
[Obsolete("Use IsIncrementalAndFactoryContextMatches")]
|
|
private new bool IsIncremental
|
|
{
|
|
get
|
|
{
|
|
throw new Exception("Use IsIncrementalAndFactoryContextMatches");
|
|
}
|
|
}
|
|
|
|
private bool IsIncrementalAndFactoryContextMatches
|
|
{
|
|
get
|
|
{
|
|
if (!base.IsIncremental)
|
|
{
|
|
return false;
|
|
}
|
|
Microsoft.CodeAnalysis.CSharp.CSharpSyntaxNode currentNode = base.CurrentNode;
|
|
if (currentNode != null)
|
|
{
|
|
return MatchesFactoryContext(((SyntaxNode)currentNode).Green, _syntaxFactoryContext);
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
private bool IsInAsync
|
|
{
|
|
get
|
|
{
|
|
return _syntaxFactoryContext.IsInAsync;
|
|
}
|
|
set
|
|
{
|
|
_syntaxFactoryContext.IsInAsync = value;
|
|
}
|
|
}
|
|
|
|
private bool ForceConditionalAccessExpression
|
|
{
|
|
get
|
|
{
|
|
return _syntaxFactoryContext.ForceConditionalAccessExpression;
|
|
}
|
|
set
|
|
{
|
|
_syntaxFactoryContext.ForceConditionalAccessExpression = value;
|
|
}
|
|
}
|
|
|
|
private bool IsInQuery
|
|
{
|
|
get
|
|
{
|
|
return _syntaxFactoryContext.IsInQuery;
|
|
}
|
|
set
|
|
{
|
|
_syntaxFactoryContext.IsInQuery = value;
|
|
}
|
|
}
|
|
|
|
internal LanguageParser(Lexer lexer, Microsoft.CodeAnalysis.CSharp.CSharpSyntaxNode? oldTree, IEnumerable<TextChangeRange>? changes, LexerMode lexerMode = LexerMode.Syntax, CancellationToken cancellationToken = default(CancellationToken))
|
|
: base(lexer, lexerMode, oldTree, changes, allowModeReset: false, preLexIfNotIncremental: true, cancellationToken)
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000b: Expected O, but got Unknown
|
|
_syntaxFactoryContext = new SyntaxFactoryContext();
|
|
_syntaxFactory = new ContextAwareSyntax(_syntaxFactoryContext);
|
|
}
|
|
|
|
private static bool IsSomeWord(SyntaxKind kind)
|
|
{
|
|
if (kind != SyntaxKind.IdentifierToken)
|
|
{
|
|
return SyntaxFacts.IsKeywordKind(kind);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private bool IsTerminator()
|
|
{
|
|
if (base.CurrentToken.Kind == SyntaxKind.EndOfFileToken)
|
|
{
|
|
return true;
|
|
}
|
|
for (int num = 1; num <= 268435456; num <<= 1)
|
|
{
|
|
switch ((TerminatorState)((uint)_termState & (uint)num))
|
|
{
|
|
case TerminatorState.IsNamespaceMemberStartOrStop:
|
|
if (!IsNamespaceMemberStartOrStop())
|
|
{
|
|
continue;
|
|
}
|
|
break;
|
|
case TerminatorState.IsAttributeDeclarationTerminator:
|
|
if (!IsAttributeDeclarationTerminator())
|
|
{
|
|
continue;
|
|
}
|
|
break;
|
|
case TerminatorState.IsPossibleAggregateClauseStartOrStop:
|
|
if (!IsPossibleAggregateClauseStartOrStop())
|
|
{
|
|
continue;
|
|
}
|
|
break;
|
|
case TerminatorState.IsPossibleMemberStartOrStop:
|
|
if (!IsPossibleMemberStartOrStop())
|
|
{
|
|
continue;
|
|
}
|
|
break;
|
|
case TerminatorState.IsEndOfReturnType:
|
|
if (!IsEndOfReturnType())
|
|
{
|
|
continue;
|
|
}
|
|
break;
|
|
case TerminatorState.IsEndOfParameterList:
|
|
if (!IsEndOfParameterList())
|
|
{
|
|
continue;
|
|
}
|
|
break;
|
|
case TerminatorState.IsEndOfFieldDeclaration:
|
|
if (!IsEndOfFieldDeclaration())
|
|
{
|
|
continue;
|
|
}
|
|
break;
|
|
case TerminatorState.IsPossibleEndOfVariableDeclaration:
|
|
if (!IsPossibleEndOfVariableDeclaration())
|
|
{
|
|
continue;
|
|
}
|
|
break;
|
|
case TerminatorState.IsEndOfTypeArgumentList:
|
|
if (!IsEndOfTypeArgumentList())
|
|
{
|
|
continue;
|
|
}
|
|
break;
|
|
case TerminatorState.IsPossibleStatementStartOrStop:
|
|
if (!IsPossibleStatementStartOrStop())
|
|
{
|
|
continue;
|
|
}
|
|
break;
|
|
case TerminatorState.IsEndOfFixedStatement:
|
|
if (!IsEndOfFixedStatement())
|
|
{
|
|
continue;
|
|
}
|
|
break;
|
|
case TerminatorState.IsEndOfTryBlock:
|
|
if (!IsEndOfTryBlock())
|
|
{
|
|
continue;
|
|
}
|
|
break;
|
|
case TerminatorState.IsEndOfCatchClause:
|
|
if (!IsEndOfCatchClause())
|
|
{
|
|
continue;
|
|
}
|
|
break;
|
|
case TerminatorState.IsEndOfFilterClause:
|
|
if (!IsEndOfFilterClause())
|
|
{
|
|
continue;
|
|
}
|
|
break;
|
|
case TerminatorState.IsEndOfCatchBlock:
|
|
if (!IsEndOfCatchBlock())
|
|
{
|
|
continue;
|
|
}
|
|
break;
|
|
case TerminatorState.IsEndOfDoWhileExpression:
|
|
if (!IsEndOfDoWhileExpression())
|
|
{
|
|
continue;
|
|
}
|
|
break;
|
|
case TerminatorState.IsEndOfForStatementArgument:
|
|
if (!IsEndOfForStatementArgument())
|
|
{
|
|
continue;
|
|
}
|
|
break;
|
|
case TerminatorState.IsEndOfDeclarationClause:
|
|
if (!IsEndOfDeclarationClause())
|
|
{
|
|
continue;
|
|
}
|
|
break;
|
|
case TerminatorState.IsEndOfArgumentList:
|
|
if (!IsEndOfArgumentList())
|
|
{
|
|
continue;
|
|
}
|
|
break;
|
|
case TerminatorState.IsSwitchSectionStart:
|
|
if (!IsPossibleSwitchSection())
|
|
{
|
|
continue;
|
|
}
|
|
break;
|
|
case TerminatorState.IsEndOfTypeParameterList:
|
|
if (!IsEndOfTypeParameterList())
|
|
{
|
|
continue;
|
|
}
|
|
break;
|
|
case TerminatorState.IsEndOfMethodSignature:
|
|
if (!IsEndOfMethodSignature())
|
|
{
|
|
continue;
|
|
}
|
|
break;
|
|
case TerminatorState.IsEndOfNameInExplicitInterface:
|
|
if (!IsEndOfNameInExplicitInterface())
|
|
{
|
|
continue;
|
|
}
|
|
break;
|
|
case TerminatorState.IsEndOfFunctionPointerParameterList:
|
|
if (!IsEndOfFunctionPointerParameterList(errored: false))
|
|
{
|
|
continue;
|
|
}
|
|
break;
|
|
case TerminatorState.IsEndOfFunctionPointerParameterListErrored:
|
|
if (!IsEndOfFunctionPointerParameterList(errored: true))
|
|
{
|
|
continue;
|
|
}
|
|
break;
|
|
case TerminatorState.IsEndOfFunctionPointerCallingConvention:
|
|
if (!IsEndOfFunctionPointerCallingConvention())
|
|
{
|
|
continue;
|
|
}
|
|
break;
|
|
case TerminatorState.IsEndOfRecordOrClassOrStructOrInterfaceSignature:
|
|
if (!IsEndOfRecordOrClassOrStructOrInterfaceSignature())
|
|
{
|
|
continue;
|
|
}
|
|
break;
|
|
default:
|
|
continue;
|
|
}
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private static Microsoft.CodeAnalysis.CSharp.CSharpSyntaxNode? GetOldParent(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxNode node)
|
|
{
|
|
return node?.Parent;
|
|
}
|
|
|
|
internal CompilationUnitSyntax ParseCompilationUnit()
|
|
{
|
|
return ParseWithStackGuard((LanguageParser @this) => @this.ParseCompilationUnitCore(), (LanguageParser @this) => SyntaxFactory.CompilationUnit(default(SyntaxList<ExternAliasDirectiveSyntax>), default(SyntaxList<UsingDirectiveSyntax>), default(SyntaxList<AttributeListSyntax>), default(SyntaxList<MemberDeclarationSyntax>), SyntaxFactory.Token(SyntaxKind.EndOfFileToken)));
|
|
}
|
|
|
|
internal CompilationUnitSyntax ParseCompilationUnitCore()
|
|
{
|
|
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxToken openBraceOrSemicolon = null;
|
|
SyntaxListBuilder initialBadNodes = null;
|
|
NamespaceBodyBuilder body = new NamespaceBodyBuilder(_pool);
|
|
try
|
|
{
|
|
ParseNamespaceBody(ref openBraceOrSemicolon, ref body, ref initialBadNodes, SyntaxKind.CompilationUnit);
|
|
SyntaxToken endOfFileToken = EatToken(SyntaxKind.EndOfFileToken);
|
|
CompilationUnitSyntax compilationUnitSyntax = _syntaxFactory.CompilationUnit(SyntaxListBuilder<ExternAliasDirectiveSyntax>.op_Implicit(body.Externs), SyntaxListBuilder<UsingDirectiveSyntax>.op_Implicit(body.Usings), SyntaxListBuilder<AttributeListSyntax>.op_Implicit(body.Attributes), SyntaxListBuilder<MemberDeclarationSyntax>.op_Implicit(body.Members), endOfFileToken);
|
|
if (initialBadNodes != null)
|
|
{
|
|
compilationUnitSyntax = AddLeadingSkippedSyntax(compilationUnitSyntax, initialBadNodes.ToListNode());
|
|
_pool.Free(initialBadNodes);
|
|
}
|
|
return compilationUnitSyntax;
|
|
}
|
|
finally
|
|
{
|
|
body.Free(_pool);
|
|
}
|
|
}
|
|
|
|
internal TNode ParseWithStackGuard<TNode>(Func<LanguageParser, TNode> parseFunc, Func<LanguageParser, TNode> createEmptyNodeFunc) where TNode : CSharpSyntaxNode
|
|
{
|
|
try
|
|
{
|
|
return parseFunc(this);
|
|
}
|
|
catch (InsufficientExecutionStackException)
|
|
{
|
|
return CreateForGlobalFailure(lexer.TextWindow.Position, createEmptyNodeFunc(this));
|
|
}
|
|
}
|
|
|
|
private TNode CreateForGlobalFailure<TNode>(int position, TNode node) where TNode : CSharpSyntaxNode
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0007: Expected O, but got Unknown
|
|
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxListBuilder val = new SyntaxListBuilder(1);
|
|
val.Add((GreenNode)(object)SyntaxFactory.BadToken(null, ((object)lexer.TextWindow.Text).ToString(), null));
|
|
SkippedTokensTriviaSyntax skippedSyntax = _syntaxFactory.SkippedTokensTrivia(val.ToList<SyntaxToken>());
|
|
node = AddLeadingSkippedSyntax(node, (GreenNode)(object)skippedSyntax);
|
|
ForceEndOfFile();
|
|
return AddError(node, position, 0, ErrorCode.ERR_InsufficientStack);
|
|
}
|
|
|
|
private BaseNamespaceDeclarationSyntax ParseNamespaceDeclaration(SyntaxList<AttributeListSyntax> attributeLists, SyntaxListBuilder modifiers)
|
|
{
|
|
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
|
|
_recursionDepth++;
|
|
StackGuard.EnsureSufficientExecutionStack(_recursionDepth);
|
|
BaseNamespaceDeclarationSyntax result = ParseNamespaceDeclarationCore(attributeLists, modifiers);
|
|
_recursionDepth--;
|
|
return result;
|
|
}
|
|
|
|
private BaseNamespaceDeclarationSyntax ParseNamespaceDeclarationCore(SyntaxList<AttributeListSyntax> attributeLists, SyntaxListBuilder modifiers)
|
|
{
|
|
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxToken syntaxToken = EatToken(SyntaxKind.NamespaceKeyword);
|
|
if (base.IsScript)
|
|
{
|
|
syntaxToken = AddError(syntaxToken, ErrorCode.ERR_NamespaceNotAllowedInScript);
|
|
}
|
|
NameSyntax name = ParseQualifiedName();
|
|
SyntaxToken openBraceOrSemicolon = null;
|
|
SyntaxToken openBraceOrSemicolon2 = null;
|
|
if (base.CurrentToken.Kind == SyntaxKind.SemicolonToken)
|
|
{
|
|
openBraceOrSemicolon2 = EatToken(SyntaxKind.SemicolonToken);
|
|
}
|
|
else if (base.CurrentToken.Kind == SyntaxKind.OpenBraceToken || IsPossibleNamespaceMemberDeclaration())
|
|
{
|
|
openBraceOrSemicolon = EatToken(SyntaxKind.OpenBraceToken);
|
|
}
|
|
else
|
|
{
|
|
openBraceOrSemicolon = EatTokenWithPrejudice(SyntaxKind.OpenBraceToken);
|
|
openBraceOrSemicolon = ConvertToMissingWithTrailingTrivia(openBraceOrSemicolon, SyntaxKind.OpenBraceToken);
|
|
}
|
|
NamespaceBodyBuilder body = new NamespaceBodyBuilder(_pool);
|
|
try
|
|
{
|
|
if (openBraceOrSemicolon == null)
|
|
{
|
|
SyntaxListBuilder initialBadNodes = null;
|
|
ParseNamespaceBody(ref openBraceOrSemicolon2, ref body, ref initialBadNodes, SyntaxKind.FileScopedNamespaceDeclaration);
|
|
return _syntaxFactory.FileScopedNamespaceDeclaration(attributeLists, SyntaxList<SyntaxToken>.op_Implicit(modifiers.ToList()), syntaxToken, name, openBraceOrSemicolon2, SyntaxListBuilder<ExternAliasDirectiveSyntax>.op_Implicit(body.Externs), SyntaxListBuilder<UsingDirectiveSyntax>.op_Implicit(body.Usings), SyntaxListBuilder<MemberDeclarationSyntax>.op_Implicit(body.Members));
|
|
}
|
|
SyntaxListBuilder initialBadNodes2 = null;
|
|
ParseNamespaceBody(ref openBraceOrSemicolon, ref body, ref initialBadNodes2, SyntaxKind.NamespaceDeclaration);
|
|
return _syntaxFactory.NamespaceDeclaration(attributeLists, SyntaxList<SyntaxToken>.op_Implicit(modifiers.ToList()), syntaxToken, name, openBraceOrSemicolon, SyntaxListBuilder<ExternAliasDirectiveSyntax>.op_Implicit(body.Externs), SyntaxListBuilder<UsingDirectiveSyntax>.op_Implicit(body.Usings), SyntaxListBuilder<MemberDeclarationSyntax>.op_Implicit(body.Members), EatToken(SyntaxKind.CloseBraceToken), TryEatToken(SyntaxKind.SemicolonToken));
|
|
}
|
|
finally
|
|
{
|
|
body.Free(_pool);
|
|
}
|
|
}
|
|
|
|
private static bool IsPossibleStartOfTypeDeclaration(SyntaxKind kind)
|
|
{
|
|
if (!IsTypeModifierOrTypeKeyword(kind))
|
|
{
|
|
return kind == SyntaxKind.OpenBracketToken;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private static bool IsTypeModifierOrTypeKeyword(SyntaxKind kind)
|
|
{
|
|
switch (kind)
|
|
{
|
|
case SyntaxKind.PublicKeyword:
|
|
case SyntaxKind.PrivateKeyword:
|
|
case SyntaxKind.InternalKeyword:
|
|
case SyntaxKind.ProtectedKeyword:
|
|
case SyntaxKind.StaticKeyword:
|
|
case SyntaxKind.SealedKeyword:
|
|
case SyntaxKind.NewKeyword:
|
|
case SyntaxKind.AbstractKeyword:
|
|
case SyntaxKind.ClassKeyword:
|
|
case SyntaxKind.StructKeyword:
|
|
case SyntaxKind.InterfaceKeyword:
|
|
case SyntaxKind.EnumKeyword:
|
|
case SyntaxKind.DelegateKeyword:
|
|
case SyntaxKind.UnsafeKeyword:
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
|
|
private void AddSkippedNamespaceText(ref SyntaxToken? openBraceOrSemicolon, ref NamespaceBodyBuilder body, ref SyntaxListBuilder? initialBadNodes, CSharpSyntaxNode skippedSyntax)
|
|
{
|
|
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
|
|
if (body.Members.Count > 0)
|
|
{
|
|
AddTrailingSkippedSyntax<MemberDeclarationSyntax>(body.Members, (GreenNode)(object)skippedSyntax);
|
|
return;
|
|
}
|
|
if (body.Attributes.Count > 0)
|
|
{
|
|
AddTrailingSkippedSyntax<AttributeListSyntax>(body.Attributes, (GreenNode)(object)skippedSyntax);
|
|
return;
|
|
}
|
|
if (body.Usings.Count > 0)
|
|
{
|
|
AddTrailingSkippedSyntax<UsingDirectiveSyntax>(body.Usings, (GreenNode)(object)skippedSyntax);
|
|
return;
|
|
}
|
|
if (body.Externs.Count > 0)
|
|
{
|
|
AddTrailingSkippedSyntax<ExternAliasDirectiveSyntax>(body.Externs, (GreenNode)(object)skippedSyntax);
|
|
return;
|
|
}
|
|
if (openBraceOrSemicolon != null)
|
|
{
|
|
openBraceOrSemicolon = AddTrailingSkippedSyntax(openBraceOrSemicolon, (GreenNode)(object)skippedSyntax);
|
|
return;
|
|
}
|
|
if (initialBadNodes == null)
|
|
{
|
|
initialBadNodes = _pool.Allocate();
|
|
}
|
|
initialBadNodes.AddRange(SyntaxList<GreenNode>.op_Implicit((GreenNode)(object)skippedSyntax));
|
|
}
|
|
|
|
private void ParseNamespaceBody([NotNullIfNotNull("openBraceOrSemicolon")] ref SyntaxToken? openBraceOrSemicolon, ref NamespaceBodyBuilder body, ref SyntaxListBuilder? initialBadNodes, SyntaxKind parentKind)
|
|
{
|
|
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_037c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0359: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0333: Unknown result type (might be due to invalid IL or missing references)
|
|
bool flag = openBraceOrSemicolon == null;
|
|
TerminatorState termState = _termState;
|
|
_termState |= TerminatorState.IsNamespaceMemberStartOrStop;
|
|
NamespaceParts seen = NamespaceParts.None;
|
|
SyntaxListBuilder<MemberDeclarationSyntax> pendingIncompleteMembers = _pool.Allocate<MemberDeclarationSyntax>();
|
|
bool flag2 = true;
|
|
try
|
|
{
|
|
while (true)
|
|
{
|
|
switch (base.CurrentToken.Kind)
|
|
{
|
|
case SyntaxKind.NamespaceKeyword:
|
|
{
|
|
AddIncompleteMembers(ref pendingIncompleteMembers, ref body);
|
|
SyntaxListBuilder<AttributeListSyntax> val = _pool.Allocate<AttributeListSyntax>();
|
|
SyntaxListBuilder val2 = _pool.Allocate();
|
|
body.Members.Add(adjustStateAndReportStatementOutOfOrder(ref seen, ParseNamespaceDeclaration(SyntaxListBuilder<AttributeListSyntax>.op_Implicit(val), val2)));
|
|
_pool.Free(SyntaxListBuilder<AttributeListSyntax>.op_Implicit(val));
|
|
_pool.Free(val2);
|
|
flag2 = true;
|
|
continue;
|
|
}
|
|
case SyntaxKind.CloseBraceToken:
|
|
if (flag)
|
|
{
|
|
ReduceIncompleteMembers(ref pendingIncompleteMembers, ref openBraceOrSemicolon, ref body, ref initialBadNodes);
|
|
SyntaxToken node = EatToken();
|
|
node = AddError(node, base.IsScript ? ErrorCode.ERR_GlobalDefinitionOrStatementExpected : ErrorCode.ERR_EOFExpected);
|
|
AddSkippedNamespaceText(ref openBraceOrSemicolon, ref body, ref initialBadNodes, node);
|
|
flag2 = true;
|
|
continue;
|
|
}
|
|
return;
|
|
case SyntaxKind.EndOfFileToken:
|
|
return;
|
|
case SyntaxKind.ExternKeyword:
|
|
if (!flag || ScanExternAliasDirective())
|
|
{
|
|
ReduceIncompleteMembers(ref pendingIncompleteMembers, ref openBraceOrSemicolon, ref body, ref initialBadNodes);
|
|
ExternAliasDirectiveSyntax externAliasDirectiveSyntax = ParseExternAliasDirective();
|
|
if (seen > NamespaceParts.ExternAliases)
|
|
{
|
|
externAliasDirectiveSyntax = AddErrorToFirstToken(externAliasDirectiveSyntax, ErrorCode.ERR_ExternAfterElements);
|
|
AddSkippedNamespaceText(ref openBraceOrSemicolon, ref body, ref initialBadNodes, externAliasDirectiveSyntax);
|
|
}
|
|
else
|
|
{
|
|
body.Externs.Add(externAliasDirectiveSyntax);
|
|
seen = NamespaceParts.ExternAliases;
|
|
}
|
|
flag2 = true;
|
|
continue;
|
|
}
|
|
break;
|
|
case SyntaxKind.UsingKeyword:
|
|
if (!flag || (PeekToken(1).Kind != SyntaxKind.OpenParenToken && (base.IsScript || !IsPossibleTopLevelUsingLocalDeclarationStatement())))
|
|
{
|
|
parseUsingDirective(ref openBraceOrSemicolon, ref body, ref initialBadNodes, ref seen, ref pendingIncompleteMembers);
|
|
flag2 = true;
|
|
continue;
|
|
}
|
|
break;
|
|
case SyntaxKind.IdentifierToken:
|
|
if (base.CurrentToken.ContextualKind == SyntaxKind.GlobalKeyword && PeekToken(1).Kind == SyntaxKind.UsingKeyword)
|
|
{
|
|
parseUsingDirective(ref openBraceOrSemicolon, ref body, ref initialBadNodes, ref seen, ref pendingIncompleteMembers);
|
|
flag2 = true;
|
|
continue;
|
|
}
|
|
break;
|
|
case SyntaxKind.OpenBracketToken:
|
|
{
|
|
if (!IsPossibleGlobalAttributeDeclaration())
|
|
{
|
|
break;
|
|
}
|
|
AttributeListSyntax attributeListSyntax = TryParseAttributeDeclaration(parentKind == SyntaxKind.CompilationUnit);
|
|
if (attributeListSyntax != null)
|
|
{
|
|
ReduceIncompleteMembers(ref pendingIncompleteMembers, ref openBraceOrSemicolon, ref body, ref initialBadNodes);
|
|
if (!flag || seen > NamespaceParts.GlobalAttributes)
|
|
{
|
|
attributeListSyntax = AddError(attributeListSyntax, attributeListSyntax.Target.Identifier, ErrorCode.ERR_GlobalAttributesNotFirst);
|
|
AddSkippedNamespaceText(ref openBraceOrSemicolon, ref body, ref initialBadNodes, attributeListSyntax);
|
|
}
|
|
else
|
|
{
|
|
body.Attributes.Add(attributeListSyntax);
|
|
seen = NamespaceParts.GlobalAttributes;
|
|
}
|
|
flag2 = true;
|
|
continue;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
MemberDeclarationSyntax memberDeclarationSyntax = (flag ? ParseMemberDeclarationOrStatement(parentKind) : ParseMemberDeclaration(parentKind));
|
|
if (memberDeclarationSyntax == null)
|
|
{
|
|
ReduceIncompleteMembers(ref pendingIncompleteMembers, ref openBraceOrSemicolon, ref body, ref initialBadNodes);
|
|
SyntaxToken syntaxToken = EatToken();
|
|
if (flag2 && !((GreenNode)syntaxToken).ContainsDiagnostics)
|
|
{
|
|
syntaxToken = AddError(syntaxToken, base.IsScript ? ErrorCode.ERR_GlobalDefinitionOrStatementExpected : ErrorCode.ERR_EOFExpected);
|
|
flag2 = false;
|
|
}
|
|
AddSkippedNamespaceText(ref openBraceOrSemicolon, ref body, ref initialBadNodes, syntaxToken);
|
|
}
|
|
else if (memberDeclarationSyntax.Kind == SyntaxKind.IncompleteMember && seen < NamespaceParts.MembersAndStatements)
|
|
{
|
|
pendingIncompleteMembers.Add(memberDeclarationSyntax);
|
|
flag2 = true;
|
|
}
|
|
else
|
|
{
|
|
AddIncompleteMembers(ref pendingIncompleteMembers, ref body);
|
|
body.Members.Add(adjustStateAndReportStatementOutOfOrder(ref seen, memberDeclarationSyntax));
|
|
flag2 = true;
|
|
}
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
_termState = termState;
|
|
AddIncompleteMembers(ref pendingIncompleteMembers, ref body);
|
|
_pool.Free(SyntaxListBuilder<MemberDeclarationSyntax>.op_Implicit(pendingIncompleteMembers));
|
|
}
|
|
MemberDeclarationSyntax adjustStateAndReportStatementOutOfOrder(ref NamespaceParts reference, MemberDeclarationSyntax memberOrStatement)
|
|
{
|
|
switch (memberOrStatement.Kind)
|
|
{
|
|
case SyntaxKind.GlobalStatement:
|
|
if (reference < NamespaceParts.MembersAndStatements)
|
|
{
|
|
reference = NamespaceParts.MembersAndStatements;
|
|
}
|
|
else if (reference == NamespaceParts.TypesAndNamespaces)
|
|
{
|
|
reference = NamespaceParts.TopLevelStatementsAfterTypesAndNamespaces;
|
|
if (!base.IsScript)
|
|
{
|
|
memberOrStatement = AddError(memberOrStatement, ErrorCode.ERR_TopLevelStatementAfterNamespaceOrType);
|
|
}
|
|
}
|
|
break;
|
|
case SyntaxKind.NamespaceDeclaration:
|
|
case SyntaxKind.FileScopedNamespaceDeclaration:
|
|
case SyntaxKind.ClassDeclaration:
|
|
case SyntaxKind.StructDeclaration:
|
|
case SyntaxKind.InterfaceDeclaration:
|
|
case SyntaxKind.EnumDeclaration:
|
|
case SyntaxKind.DelegateDeclaration:
|
|
case SyntaxKind.RecordDeclaration:
|
|
case SyntaxKind.RecordStructDeclaration:
|
|
if (reference < NamespaceParts.TypesAndNamespaces)
|
|
{
|
|
reference = NamespaceParts.TypesAndNamespaces;
|
|
}
|
|
break;
|
|
default:
|
|
if (reference < NamespaceParts.MembersAndStatements)
|
|
{
|
|
reference = NamespaceParts.MembersAndStatements;
|
|
}
|
|
break;
|
|
}
|
|
return memberOrStatement;
|
|
}
|
|
void parseUsingDirective(ref SyntaxToken? openBrace, ref NamespaceBodyBuilder reference, ref SyntaxListBuilder? initialBadNodes2, ref NamespaceParts reference2, ref SyntaxListBuilder<MemberDeclarationSyntax> incompleteMembers)
|
|
{
|
|
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
|
|
ReduceIncompleteMembers(ref incompleteMembers, ref openBrace, ref reference, ref initialBadNodes2);
|
|
UsingDirectiveSyntax usingDirectiveSyntax = ParseUsingDirective();
|
|
if (reference2 > NamespaceParts.Usings)
|
|
{
|
|
usingDirectiveSyntax = AddError(usingDirectiveSyntax, ErrorCode.ERR_UsingAfterElements);
|
|
AddSkippedNamespaceText(ref openBrace, ref reference, ref initialBadNodes2, usingDirectiveSyntax);
|
|
}
|
|
else
|
|
{
|
|
reference.Usings.Add(usingDirectiveSyntax);
|
|
reference2 = NamespaceParts.Usings;
|
|
}
|
|
}
|
|
}
|
|
|
|
private static void AddIncompleteMembers(ref SyntaxListBuilder<MemberDeclarationSyntax> incompleteMembers, ref NamespaceBodyBuilder body)
|
|
{
|
|
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
|
|
if (incompleteMembers.Count > 0)
|
|
{
|
|
body.Members.AddRange(SyntaxListBuilder<MemberDeclarationSyntax>.op_Implicit(incompleteMembers));
|
|
incompleteMembers.Clear();
|
|
}
|
|
}
|
|
|
|
private void ReduceIncompleteMembers(ref SyntaxListBuilder<MemberDeclarationSyntax> incompleteMembers, ref SyntaxToken? openBraceOrSemicolon, ref NamespaceBodyBuilder body, ref SyntaxListBuilder? initialBadNodes)
|
|
{
|
|
for (int i = 0; i < incompleteMembers.Count; i++)
|
|
{
|
|
AddSkippedNamespaceText(ref openBraceOrSemicolon, ref body, ref initialBadNodes, incompleteMembers[i]);
|
|
}
|
|
incompleteMembers.Clear();
|
|
}
|
|
|
|
private bool IsPossibleNamespaceMemberDeclaration()
|
|
{
|
|
switch (base.CurrentToken.Kind)
|
|
{
|
|
case SyntaxKind.ExternKeyword:
|
|
case SyntaxKind.NamespaceKeyword:
|
|
case SyntaxKind.UsingKeyword:
|
|
return true;
|
|
case SyntaxKind.IdentifierToken:
|
|
return IsPartialInNamespaceMemberDeclaration();
|
|
default:
|
|
return IsPossibleStartOfTypeDeclaration(base.CurrentToken.Kind);
|
|
}
|
|
}
|
|
|
|
private bool IsPartialInNamespaceMemberDeclaration()
|
|
{
|
|
if (base.CurrentToken.ContextualKind == SyntaxKind.PartialKeyword)
|
|
{
|
|
if (IsPartialType())
|
|
{
|
|
return true;
|
|
}
|
|
if (PeekToken(1).Kind == SyntaxKind.NamespaceKeyword)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public bool IsEndOfNamespace()
|
|
{
|
|
return base.CurrentToken.Kind == SyntaxKind.CloseBraceToken;
|
|
}
|
|
|
|
public bool IsGobalAttributesTerminator()
|
|
{
|
|
if (!IsEndOfNamespace())
|
|
{
|
|
return IsPossibleNamespaceMemberDeclaration();
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private bool IsNamespaceMemberStartOrStop()
|
|
{
|
|
if (!IsEndOfNamespace())
|
|
{
|
|
return IsPossibleNamespaceMemberDeclaration();
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private bool ScanExternAliasDirective()
|
|
{
|
|
if (base.CurrentToken.Kind == SyntaxKind.ExternKeyword)
|
|
{
|
|
SyntaxToken syntaxToken = PeekToken(1);
|
|
if (syntaxToken != null && syntaxToken.Kind == SyntaxKind.IdentifierToken && syntaxToken.ContextualKind == SyntaxKind.AliasKeyword && PeekToken(2).Kind == SyntaxKind.IdentifierToken)
|
|
{
|
|
return PeekToken(3).Kind == SyntaxKind.SemicolonToken;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private ExternAliasDirectiveSyntax ParseExternAliasDirective()
|
|
{
|
|
if (IsIncrementalAndFactoryContextMatches && base.CurrentNodeKind == SyntaxKind.ExternAliasDirective)
|
|
{
|
|
return (ExternAliasDirectiveSyntax)(object)EatNode();
|
|
}
|
|
return _syntaxFactory.ExternAliasDirective(EatToken(SyntaxKind.ExternKeyword), EatContextualToken(SyntaxKind.AliasKeyword), ParseIdentifierToken(), EatToken(SyntaxKind.SemicolonToken));
|
|
}
|
|
|
|
private NameEqualsSyntax ParseNameEquals()
|
|
{
|
|
return _syntaxFactory.NameEquals(_syntaxFactory.IdentifierName(ParseIdentifierToken()), EatToken(SyntaxKind.EqualsToken));
|
|
}
|
|
|
|
private UsingDirectiveSyntax ParseUsingDirective()
|
|
{
|
|
if (IsIncrementalAndFactoryContextMatches && base.CurrentNodeKind == SyntaxKind.UsingDirective)
|
|
{
|
|
return (UsingDirectiveSyntax)(object)EatNode();
|
|
}
|
|
SyntaxToken globalKeyword = ((base.CurrentToken.ContextualKind == SyntaxKind.GlobalKeyword) ? SyntaxParser.ConvertToKeyword(EatToken()) : null);
|
|
SyntaxToken usingKeyword = EatToken(SyntaxKind.UsingKeyword);
|
|
SyntaxToken syntaxToken = TryEatToken(SyntaxKind.StaticKeyword);
|
|
SyntaxToken syntaxToken2 = TryEatToken(SyntaxKind.UnsafeKeyword);
|
|
if (syntaxToken == null && syntaxToken2 != null && base.CurrentToken.Kind == SyntaxKind.StaticKeyword)
|
|
{
|
|
syntaxToken = SyntaxFactory.MissingToken(SyntaxKind.StaticKeyword);
|
|
syntaxToken2 = AddTrailingSkippedSyntax(syntaxToken2, (GreenNode)(object)AddError(EatToken(), ErrorCode.ERR_BadStaticAfterUnsafe));
|
|
}
|
|
NameEqualsSyntax nameEqualsSyntax = (IsNamedAssignment() ? ParseNameEquals() : null);
|
|
TypeSyntax typeSyntax;
|
|
SyntaxToken semicolonToken;
|
|
if ((nameEqualsSyntax == null || base.CurrentToken.Kind != SyntaxKind.DelegateKeyword) && IsPossibleNamespaceMemberDeclaration())
|
|
{
|
|
typeSyntax = WithAdditionalDiagnostics(CreateMissingIdentifierName(), GetExpectedTokenError(SyntaxKind.IdentifierToken, base.CurrentToken.Kind));
|
|
semicolonToken = SyntaxFactory.MissingToken(SyntaxKind.SemicolonToken);
|
|
}
|
|
else
|
|
{
|
|
typeSyntax = ((nameEqualsSyntax == null) ? ParseQualifiedName() : ParseType());
|
|
if (((GreenNode)typeSyntax).IsMissing && PeekToken(1).Kind == SyntaxKind.SemicolonToken)
|
|
{
|
|
typeSyntax = AddTrailingSkippedSyntax(typeSyntax, (GreenNode)(object)EatToken());
|
|
}
|
|
semicolonToken = EatToken(SyntaxKind.SemicolonToken);
|
|
}
|
|
return _syntaxFactory.UsingDirective(globalKeyword, usingKeyword, syntaxToken, syntaxToken2, nameEqualsSyntax, typeSyntax, semicolonToken);
|
|
}
|
|
|
|
private bool IsPossibleGlobalAttributeDeclaration()
|
|
{
|
|
if (base.CurrentToken.Kind == SyntaxKind.OpenBracketToken && IsGlobalAttributeTarget(PeekToken(1)))
|
|
{
|
|
return PeekToken(2).Kind == SyntaxKind.ColonToken;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private static bool IsGlobalAttributeTarget(SyntaxToken token)
|
|
{
|
|
AttributeLocation attributeLocation = token.ToAttributeLocation();
|
|
if ((uint)(attributeLocation - 1) <= 1u)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private bool IsPossibleAttributeDeclaration()
|
|
{
|
|
return base.CurrentToken.Kind == SyntaxKind.OpenBracketToken;
|
|
}
|
|
|
|
private SyntaxList<AttributeListSyntax> ParseAttributeDeclarations(bool inExpressionContext)
|
|
{
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxListBuilder<AttributeListSyntax> val = _pool.Allocate<AttributeListSyntax>();
|
|
TerminatorState termState = _termState;
|
|
_termState |= TerminatorState.IsAttributeDeclarationTerminator;
|
|
while (IsPossibleAttributeDeclaration())
|
|
{
|
|
AttributeListSyntax attributeListSyntax = TryParseAttributeDeclaration(inExpressionContext);
|
|
if (attributeListSyntax == null)
|
|
{
|
|
break;
|
|
}
|
|
val.Add(attributeListSyntax);
|
|
}
|
|
_termState = termState;
|
|
return _pool.ToListAndFree<AttributeListSyntax>(val);
|
|
}
|
|
|
|
private bool IsAttributeDeclarationTerminator()
|
|
{
|
|
if (base.CurrentToken.Kind != SyntaxKind.CloseBracketToken)
|
|
{
|
|
return IsPossibleAttributeDeclaration();
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private AttributeListSyntax? TryParseAttributeDeclaration(bool inExpressionContext)
|
|
{
|
|
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
|
|
if (IsIncrementalAndFactoryContextMatches && base.CurrentNodeKind == SyntaxKind.AttributeList && !inExpressionContext)
|
|
{
|
|
return (AttributeListSyntax)(object)EatNode();
|
|
}
|
|
using (DisposableResetPoint disposableResetPoint = GetDisposableResetPoint(resetOnDispose: false))
|
|
{
|
|
SyntaxToken openToken = EatToken(SyntaxKind.OpenBracketToken);
|
|
AttributeTargetSpecifierSyntax target = ((IsSomeWord(base.CurrentToken.Kind) && PeekToken(1).Kind == SyntaxKind.ColonToken) ? _syntaxFactory.AttributeTargetSpecifier(SyntaxParser.ConvertToKeyword(EatToken()), EatToken(SyntaxKind.ColonToken)) : null);
|
|
SeparatedSyntaxList<AttributeSyntax> attributes = ParseCommaSeparatedSyntaxList(ref openToken, SyntaxKind.CloseBracketToken, (LanguageParser @this) => @this.IsPossibleAttribute(), (LanguageParser @this) => @this.ParseAttribute(), skipBadAttributeListTokens, allowTrailingSeparator: true, requireOneElement: true, allowSemicolonAsSeparator: false);
|
|
SyntaxToken closeBracketToken = EatToken(SyntaxKind.CloseBracketToken);
|
|
if (inExpressionContext && shouldParseAsCollectionExpression())
|
|
{
|
|
disposableResetPoint.Reset();
|
|
return null;
|
|
}
|
|
return _syntaxFactory.AttributeList(openToken, target, attributes, closeBracketToken);
|
|
}
|
|
bool shouldParseAsCollectionExpression()
|
|
{
|
|
if (base.CurrentToken.Kind == SyntaxKind.DotToken)
|
|
{
|
|
return true;
|
|
}
|
|
if (base.CurrentToken.Kind == SyntaxKind.MinusGreaterThanToken)
|
|
{
|
|
return true;
|
|
}
|
|
if (base.CurrentToken.Kind == SyntaxKind.QuestionToken && PeekToken(1).Kind == SyntaxKind.DotToken)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
static PostSkipAction skipBadAttributeListTokens(LanguageParser @this, ref SyntaxToken openBracket, SeparatedSyntaxListBuilder<AttributeSyntax> list, SyntaxKind expectedKind, SyntaxKind closeKind)
|
|
{
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
|
return @this.SkipBadSeparatedListTokensWithExpectedKind<SyntaxToken, AttributeSyntax>(ref openBracket, list, (LanguageParser p) => p.CurrentToken.Kind != SyntaxKind.CommaToken && !p.IsPossibleAttribute(), (LanguageParser p, SyntaxKind syntaxKind) => p.CurrentToken.Kind == syntaxKind, expectedKind, closeKind);
|
|
}
|
|
}
|
|
|
|
private bool IsPossibleAttribute()
|
|
{
|
|
return IsTrueIdentifier();
|
|
}
|
|
|
|
private AttributeSyntax ParseAttribute()
|
|
{
|
|
if (IsIncrementalAndFactoryContextMatches && base.CurrentNodeKind == SyntaxKind.Attribute)
|
|
{
|
|
return (AttributeSyntax)(object)EatNode();
|
|
}
|
|
return _syntaxFactory.Attribute(ParseQualifiedName(), ParseAttributeArgumentList());
|
|
}
|
|
|
|
internal AttributeArgumentListSyntax? ParseAttributeArgumentList()
|
|
{
|
|
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
|
|
if (IsIncrementalAndFactoryContextMatches && base.CurrentNodeKind == SyntaxKind.AttributeArgumentList)
|
|
{
|
|
return (AttributeArgumentListSyntax)(object)EatNode();
|
|
}
|
|
if (base.CurrentToken.Kind != SyntaxKind.OpenParenToken)
|
|
{
|
|
return null;
|
|
}
|
|
SyntaxToken openToken = EatToken(SyntaxKind.OpenParenToken);
|
|
SeparatedSyntaxList<AttributeArgumentSyntax> arguments = ParseCommaSeparatedSyntaxList(ref openToken, SyntaxKind.CloseParenToken, (LanguageParser @this) => @this.IsPossibleAttributeArgument(), (LanguageParser @this) => @this.ParseAttributeArgument(), skipBadAttributeArgumentTokens, allowTrailingSeparator: false, requireOneElement: false, allowSemicolonAsSeparator: false);
|
|
return _syntaxFactory.AttributeArgumentList(openToken, arguments, EatToken(SyntaxKind.CloseParenToken));
|
|
static PostSkipAction skipBadAttributeArgumentTokens(LanguageParser @this, ref SyntaxToken openParen, SeparatedSyntaxListBuilder<AttributeArgumentSyntax> list, SyntaxKind expectedKind, SyntaxKind closeKind)
|
|
{
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
|
return @this.SkipBadSeparatedListTokensWithExpectedKind<SyntaxToken, AttributeArgumentSyntax>(ref openParen, list, (LanguageParser p) => p.CurrentToken.Kind != SyntaxKind.CommaToken && !p.IsPossibleAttributeArgument(), (LanguageParser p, SyntaxKind syntaxKind) => p.CurrentToken.Kind == syntaxKind, expectedKind, closeKind);
|
|
}
|
|
}
|
|
|
|
private bool IsPossibleAttributeArgument()
|
|
{
|
|
return IsPossibleExpression();
|
|
}
|
|
|
|
private AttributeArgumentSyntax ParseAttributeArgument()
|
|
{
|
|
NameEqualsSyntax nameEquals = null;
|
|
NameColonSyntax nameColon = null;
|
|
if (base.CurrentToken.Kind == SyntaxKind.IdentifierToken)
|
|
{
|
|
switch (PeekToken(1).Kind)
|
|
{
|
|
case SyntaxKind.EqualsToken:
|
|
nameEquals = _syntaxFactory.NameEquals(_syntaxFactory.IdentifierName(ParseIdentifierToken()), EatToken(SyntaxKind.EqualsToken));
|
|
break;
|
|
case SyntaxKind.ColonToken:
|
|
nameColon = _syntaxFactory.NameColon(ParseIdentifierName(), EatToken(SyntaxKind.ColonToken));
|
|
break;
|
|
}
|
|
}
|
|
return _syntaxFactory.AttributeArgument(nameEquals, nameColon, ParseExpressionCore());
|
|
}
|
|
|
|
private static DeclarationModifiers GetModifierExcludingScoped(SyntaxToken token)
|
|
{
|
|
return GetModifierExcludingScoped(token.Kind, token.ContextualKind);
|
|
}
|
|
|
|
internal static DeclarationModifiers GetModifierExcludingScoped(SyntaxKind kind, SyntaxKind contextualKind)
|
|
{
|
|
switch (kind)
|
|
{
|
|
case SyntaxKind.PublicKeyword:
|
|
return DeclarationModifiers.Public;
|
|
case SyntaxKind.InternalKeyword:
|
|
return DeclarationModifiers.Internal;
|
|
case SyntaxKind.ProtectedKeyword:
|
|
return DeclarationModifiers.Protected;
|
|
case SyntaxKind.PrivateKeyword:
|
|
return DeclarationModifiers.Private;
|
|
case SyntaxKind.SealedKeyword:
|
|
return DeclarationModifiers.Sealed;
|
|
case SyntaxKind.AbstractKeyword:
|
|
return DeclarationModifiers.Abstract;
|
|
case SyntaxKind.StaticKeyword:
|
|
return DeclarationModifiers.Static;
|
|
case SyntaxKind.VirtualKeyword:
|
|
return DeclarationModifiers.Virtual;
|
|
case SyntaxKind.ExternKeyword:
|
|
return DeclarationModifiers.Extern;
|
|
case SyntaxKind.NewKeyword:
|
|
return DeclarationModifiers.New;
|
|
case SyntaxKind.OverrideKeyword:
|
|
return DeclarationModifiers.Override;
|
|
case SyntaxKind.ReadOnlyKeyword:
|
|
return DeclarationModifiers.ReadOnly;
|
|
case SyntaxKind.VolatileKeyword:
|
|
return DeclarationModifiers.Volatile;
|
|
case SyntaxKind.UnsafeKeyword:
|
|
return DeclarationModifiers.Unsafe;
|
|
case SyntaxKind.PartialKeyword:
|
|
return DeclarationModifiers.Partial;
|
|
case SyntaxKind.AsyncKeyword:
|
|
return DeclarationModifiers.Async;
|
|
case SyntaxKind.RefKeyword:
|
|
return DeclarationModifiers.Ref;
|
|
case SyntaxKind.IdentifierToken:
|
|
switch (contextualKind)
|
|
{
|
|
case SyntaxKind.PartialKeyword:
|
|
return DeclarationModifiers.Partial;
|
|
case SyntaxKind.AsyncKeyword:
|
|
return DeclarationModifiers.Async;
|
|
case SyntaxKind.RequiredKeyword:
|
|
return DeclarationModifiers.Required;
|
|
case SyntaxKind.FileKeyword:
|
|
return DeclarationModifiers.File;
|
|
}
|
|
break;
|
|
}
|
|
return DeclarationModifiers.None;
|
|
}
|
|
|
|
private void ParseModifiers(SyntaxListBuilder tokens, bool forAccessors, bool forTopLevelStatements, out bool isPossibleTypeDeclaration)
|
|
{
|
|
isPossibleTypeDeclaration = true;
|
|
while (true)
|
|
{
|
|
SyntaxToken syntaxToken;
|
|
switch (GetModifierExcludingScoped(base.CurrentToken))
|
|
{
|
|
case DeclarationModifiers.None:
|
|
if (!forAccessors)
|
|
{
|
|
SyntaxToken syntaxToken3 = ParsePossibleScopedKeyword(isFunctionPointerParameter: false);
|
|
if (syntaxToken3 != null)
|
|
{
|
|
isPossibleTypeDeclaration = false;
|
|
tokens.Add((GreenNode)(object)syntaxToken3);
|
|
}
|
|
}
|
|
return;
|
|
case DeclarationModifiers.Partial:
|
|
{
|
|
SyntaxToken syntaxToken2 = PeekToken(1);
|
|
if (IsPartialType() || IsPartialMember())
|
|
{
|
|
syntaxToken = SyntaxParser.ConvertToKeyword(EatToken());
|
|
break;
|
|
}
|
|
if (syntaxToken2.Kind == SyntaxKind.NamespaceKeyword)
|
|
{
|
|
syntaxToken = SyntaxParser.ConvertToKeyword(EatToken());
|
|
break;
|
|
}
|
|
SyntaxKind kind = syntaxToken2.Kind;
|
|
bool flag = kind - 8377 <= SyntaxKind.List;
|
|
if (flag || (IsPossibleStartOfTypeDeclaration(syntaxToken2.Kind) && GetModifierExcludingScoped(syntaxToken2) != DeclarationModifiers.None))
|
|
{
|
|
syntaxToken = SyntaxParser.ConvertToKeyword(EatToken());
|
|
break;
|
|
}
|
|
return;
|
|
}
|
|
case DeclarationModifiers.Ref:
|
|
{
|
|
SyntaxToken syntaxToken4 = PeekToken(1);
|
|
if (isStructOrRecordKeyword(syntaxToken4) || (syntaxToken4.ContextualKind == SyntaxKind.PartialKeyword && isStructOrRecordKeyword(PeekToken(2))))
|
|
{
|
|
syntaxToken = EatToken();
|
|
break;
|
|
}
|
|
if (forAccessors && IsPossibleAccessorModifier())
|
|
{
|
|
syntaxToken = EatToken();
|
|
break;
|
|
}
|
|
return;
|
|
}
|
|
case DeclarationModifiers.File:
|
|
if ((!IsFeatureEnabled(MessageID.IDS_FeatureFileTypes) || forTopLevelStatements) && !ShouldContextualKeywordBeTreatedAsModifier(parsingStatementNotDeclaration: false))
|
|
{
|
|
return;
|
|
}
|
|
syntaxToken = SyntaxParser.ConvertToKeyword(EatToken());
|
|
break;
|
|
case DeclarationModifiers.Async:
|
|
if (!ShouldContextualKeywordBeTreatedAsModifier(parsingStatementNotDeclaration: false))
|
|
{
|
|
return;
|
|
}
|
|
syntaxToken = SyntaxParser.ConvertToKeyword(EatToken());
|
|
break;
|
|
case DeclarationModifiers.Required:
|
|
if ((!IsFeatureEnabled(MessageID.IDS_FeatureRequiredMembers) || forTopLevelStatements) && !ShouldContextualKeywordBeTreatedAsModifier(parsingStatementNotDeclaration: false))
|
|
{
|
|
return;
|
|
}
|
|
syntaxToken = SyntaxParser.ConvertToKeyword(EatToken());
|
|
break;
|
|
default:
|
|
syntaxToken = EatToken();
|
|
break;
|
|
}
|
|
tokens.Add((GreenNode)(object)syntaxToken);
|
|
}
|
|
bool isStructOrRecordKeyword(SyntaxToken token)
|
|
{
|
|
if (token.Kind == SyntaxKind.StructKeyword)
|
|
{
|
|
return true;
|
|
}
|
|
if (token.ContextualKind == SyntaxKind.RecordKeyword)
|
|
{
|
|
return IsFeatureEnabled(MessageID.IDS_FeatureRecords);
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
private bool ShouldContextualKeywordBeTreatedAsModifier(bool parsingStatementNotDeclaration)
|
|
{
|
|
if (IsNonContextualModifier(PeekToken(1)))
|
|
{
|
|
return true;
|
|
}
|
|
bool flag;
|
|
using (GetDisposableResetPoint(resetOnDispose: true))
|
|
{
|
|
EatToken();
|
|
if (!parsingStatementNotDeclaration && base.CurrentToken.ContextualKind == SyntaxKind.PartialKeyword)
|
|
{
|
|
EatToken();
|
|
}
|
|
if (parsingStatementNotDeclaration)
|
|
{
|
|
goto IL_0095;
|
|
}
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
flag = IsTypeModifierOrTypeKeyword(kind) || kind == SyntaxKind.EventKeyword;
|
|
if (!flag)
|
|
{
|
|
bool flag2 = kind - 8383 <= SyntaxKind.List;
|
|
flag = flag2 && PeekToken(1).Kind == SyntaxKind.OperatorKeyword;
|
|
}
|
|
if (!flag)
|
|
{
|
|
goto IL_0095;
|
|
}
|
|
flag = true;
|
|
goto end_IL_0018;
|
|
IL_0127:
|
|
flag = false;
|
|
goto end_IL_0018;
|
|
IL_0095:
|
|
if (ScanType() == ScanTypeFlags.NotType)
|
|
{
|
|
goto IL_0127;
|
|
}
|
|
if (!IsPossibleMemberName())
|
|
{
|
|
SyntaxKind kind2 = base.CurrentToken.Kind;
|
|
switch (kind2)
|
|
{
|
|
case SyntaxKind.EndOfFileToken:
|
|
flag = true;
|
|
goto end_IL_0018;
|
|
case SyntaxKind.CloseBraceToken:
|
|
flag = true;
|
|
goto end_IL_0018;
|
|
default:
|
|
if (SyntaxFacts.IsPredefinedType(base.CurrentToken.Kind))
|
|
{
|
|
flag = true;
|
|
}
|
|
else if (IsNonContextualModifier(base.CurrentToken))
|
|
{
|
|
flag = true;
|
|
}
|
|
else if (IsTypeDeclarationStart())
|
|
{
|
|
flag = true;
|
|
}
|
|
else if (kind2 == SyntaxKind.NamespaceKeyword)
|
|
{
|
|
flag = true;
|
|
}
|
|
else
|
|
{
|
|
if (parsingStatementNotDeclaration || kind2 != SyntaxKind.OperatorKeyword)
|
|
{
|
|
break;
|
|
}
|
|
flag = true;
|
|
}
|
|
goto end_IL_0018;
|
|
}
|
|
goto IL_0127;
|
|
}
|
|
flag = true;
|
|
end_IL_0018:;
|
|
}
|
|
return flag;
|
|
}
|
|
|
|
private static bool IsNonContextualModifier(SyntaxToken nextToken)
|
|
{
|
|
if (!SyntaxFacts.IsContextualKeyword(nextToken.ContextualKind))
|
|
{
|
|
return GetModifierExcludingScoped(nextToken) != DeclarationModifiers.None;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private bool IsPartialType()
|
|
{
|
|
SyntaxToken syntaxToken = PeekToken(1);
|
|
SyntaxKind kind = syntaxToken.Kind;
|
|
if (kind - 8374 <= (SyntaxKind)2)
|
|
{
|
|
return true;
|
|
}
|
|
if (syntaxToken.ContextualKind == SyntaxKind.RecordKeyword)
|
|
{
|
|
return IsFeatureEnabled(MessageID.IDS_FeatureRecords);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private bool IsPartialMember()
|
|
{
|
|
using (GetDisposableResetPoint(resetOnDispose: true))
|
|
{
|
|
EatToken();
|
|
if (ScanType() == ScanTypeFlags.NotType)
|
|
{
|
|
return false;
|
|
}
|
|
return IsPossibleMemberName();
|
|
}
|
|
}
|
|
|
|
private bool IsPossibleMemberName()
|
|
{
|
|
switch (base.CurrentToken.Kind)
|
|
{
|
|
case SyntaxKind.IdentifierToken:
|
|
if (base.CurrentToken.ContextualKind == SyntaxKind.GlobalKeyword && PeekToken(1).Kind == SyntaxKind.UsingKeyword)
|
|
{
|
|
return false;
|
|
}
|
|
return true;
|
|
case SyntaxKind.ThisKeyword:
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
|
|
private MemberDeclarationSyntax ParseTypeDeclaration(SyntaxList<AttributeListSyntax> attributes, SyntaxListBuilder modifiers)
|
|
{
|
|
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
|
|
CancellationToken cancellationToken = base.cancellationToken;
|
|
cancellationToken.ThrowIfCancellationRequested();
|
|
return base.CurrentToken.Kind switch
|
|
{
|
|
SyntaxKind.ClassKeyword => ParseClassOrStructOrInterfaceDeclaration(attributes, modifiers),
|
|
SyntaxKind.StructKeyword => ParseClassOrStructOrInterfaceDeclaration(attributes, modifiers),
|
|
SyntaxKind.InterfaceKeyword => ParseClassOrStructOrInterfaceDeclaration(attributes, modifiers),
|
|
SyntaxKind.DelegateKeyword => ParseDelegateDeclaration(attributes, modifiers),
|
|
SyntaxKind.EnumKeyword => ParseEnumDeclaration(attributes, modifiers),
|
|
SyntaxKind.IdentifierToken => ParseClassOrStructOrInterfaceDeclaration(attributes, modifiers),
|
|
_ => throw ExceptionUtilities.UnexpectedValue((object)base.CurrentToken.Kind),
|
|
};
|
|
}
|
|
|
|
private TypeDeclarationSyntax ParseClassOrStructOrInterfaceDeclaration(SyntaxList<AttributeListSyntax> attributes, SyntaxListBuilder modifiers)
|
|
{
|
|
//IL_0258: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0273: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_022a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0236: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_023a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_017a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
|
|
if (!tryScanRecordStart(out var keyword, out var recordModifier))
|
|
{
|
|
keyword = SyntaxParser.ConvertToKeyword(EatToken());
|
|
}
|
|
TerminatorState termState = _termState;
|
|
_termState |= TerminatorState.IsEndOfRecordOrClassOrStructOrInterfaceSignature;
|
|
TerminatorState termState2 = _termState;
|
|
_termState |= TerminatorState.IsPossibleAggregateClauseStartOrStop;
|
|
SyntaxToken syntaxToken = ParseIdentifierToken();
|
|
TypeParameterListSyntax typeParameters = ParseTypeParameterList();
|
|
ParameterListSyntax paramList = ((base.CurrentToken.Kind == SyntaxKind.OpenParenToken) ? ParseParenthesizedParameterList() : null);
|
|
BaseListSyntax baseList = ParseBaseList();
|
|
_termState = termState2;
|
|
bool flag = true;
|
|
SyntaxListBuilder<MemberDeclarationSyntax> val = default(SyntaxListBuilder<MemberDeclarationSyntax>);
|
|
SyntaxListBuilder<TypeParameterConstraintClauseSyntax> val2 = default(SyntaxListBuilder<TypeParameterConstraintClauseSyntax>);
|
|
try
|
|
{
|
|
if (base.CurrentToken.ContextualKind == SyntaxKind.WhereKeyword)
|
|
{
|
|
val2 = _pool.Allocate<TypeParameterConstraintClauseSyntax>();
|
|
ParseTypeParameterConstraintClauses(SyntaxListBuilder<TypeParameterConstraintClauseSyntax>.op_Implicit(val2));
|
|
}
|
|
_termState = termState;
|
|
SyntaxToken semicolon;
|
|
SyntaxToken openBrace;
|
|
SyntaxToken closeBrace;
|
|
if (base.CurrentToken.Kind == SyntaxKind.SemicolonToken)
|
|
{
|
|
semicolon = EatToken(SyntaxKind.SemicolonToken);
|
|
openBrace = null;
|
|
closeBrace = null;
|
|
}
|
|
else
|
|
{
|
|
openBrace = EatToken(SyntaxKind.OpenBraceToken);
|
|
if (((GreenNode)syntaxToken).IsMissing || ((GreenNode)openBrace).IsMissing)
|
|
{
|
|
flag = false;
|
|
}
|
|
if (flag)
|
|
{
|
|
val = _pool.Allocate<MemberDeclarationSyntax>();
|
|
while (true)
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
if (CanStartMember(kind))
|
|
{
|
|
TerminatorState termState3 = _termState;
|
|
_termState |= TerminatorState.IsPossibleMemberStartOrStop;
|
|
MemberDeclarationSyntax memberDeclarationSyntax = ParseMemberDeclaration(keyword.Kind);
|
|
if (memberDeclarationSyntax != null)
|
|
{
|
|
val.Add(memberDeclarationSyntax);
|
|
}
|
|
else
|
|
{
|
|
SkipBadMemberListTokens(ref openBrace, SyntaxListBuilder<MemberDeclarationSyntax>.op_Implicit(val));
|
|
}
|
|
_termState = termState3;
|
|
}
|
|
else
|
|
{
|
|
bool flag2 = ((kind == SyntaxKind.CloseBraceToken || kind == SyntaxKind.EndOfFileToken) ? true : false);
|
|
if (flag2 || IsTerminator())
|
|
{
|
|
break;
|
|
}
|
|
SkipBadMemberListTokens(ref openBrace, SyntaxListBuilder<MemberDeclarationSyntax>.op_Implicit(val));
|
|
}
|
|
}
|
|
}
|
|
if (((GreenNode)openBrace).IsMissing)
|
|
{
|
|
closeBrace = SyntaxFactory.MissingToken(SyntaxKind.CloseBraceToken);
|
|
closeBrace = WithAdditionalDiagnostics(closeBrace, GetExpectedTokenError(SyntaxKind.CloseBraceToken, base.CurrentToken.Kind));
|
|
}
|
|
else
|
|
{
|
|
closeBrace = EatToken(SyntaxKind.CloseBraceToken);
|
|
}
|
|
semicolon = TryEatToken(SyntaxKind.SemicolonToken);
|
|
}
|
|
return constructTypeDeclaration(_syntaxFactory, attributes, modifiers, keyword, recordModifier, syntaxToken, typeParameters, paramList, baseList, val2, openBrace, val, closeBrace, semicolon);
|
|
}
|
|
finally
|
|
{
|
|
if (!val.IsNull)
|
|
{
|
|
_pool.Free(SyntaxListBuilder<MemberDeclarationSyntax>.op_Implicit(val));
|
|
}
|
|
if (!val2.IsNull)
|
|
{
|
|
_pool.Free(SyntaxListBuilder<TypeParameterConstraintClauseSyntax>.op_Implicit(val2));
|
|
}
|
|
}
|
|
static TypeDeclarationSyntax constructTypeDeclaration(ContextAwareSyntax syntaxFactory, SyntaxList<AttributeListSyntax> attributeLists, SyntaxListBuilder val3, SyntaxToken syntaxToken2, SyntaxToken? syntaxToken3, SyntaxToken name, TypeParameterListSyntax typeParameterList, ParameterListSyntax? parameterList, BaseListSyntax baseList2, SyntaxListBuilder<TypeParameterConstraintClauseSyntax> constraints, SyntaxToken? openBraceToken, SyntaxListBuilder<MemberDeclarationSyntax> members, SyntaxToken? closeBraceToken, SyntaxToken semicolonToken)
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxList<SyntaxToken> modifiers2 = SyntaxList<SyntaxToken>.op_Implicit(val3.ToList());
|
|
SyntaxList<MemberDeclarationSyntax> members2 = SyntaxListBuilder<MemberDeclarationSyntax>.op_Implicit(members);
|
|
SyntaxList<TypeParameterConstraintClauseSyntax> constraintClauses = SyntaxListBuilder<TypeParameterConstraintClauseSyntax>.op_Implicit(constraints);
|
|
switch (syntaxToken2.Kind)
|
|
{
|
|
case SyntaxKind.ClassKeyword:
|
|
return syntaxFactory.ClassDeclaration(attributeLists, modifiers2, syntaxToken2, name, typeParameterList, parameterList, baseList2, constraintClauses, openBraceToken, members2, closeBraceToken, semicolonToken);
|
|
case SyntaxKind.StructKeyword:
|
|
return syntaxFactory.StructDeclaration(attributeLists, modifiers2, syntaxToken2, name, typeParameterList, parameterList, baseList2, constraintClauses, openBraceToken, members2, closeBraceToken, semicolonToken);
|
|
case SyntaxKind.InterfaceKeyword:
|
|
return syntaxFactory.InterfaceDeclaration(attributeLists, modifiers2, syntaxToken2, name, typeParameterList, parameterList, baseList2, constraintClauses, openBraceToken, members2, closeBraceToken, semicolonToken);
|
|
case SyntaxKind.RecordKeyword:
|
|
{
|
|
SyntaxKind kind2 = ((syntaxToken3 != null && syntaxToken3.Kind == SyntaxKind.StructKeyword) ? SyntaxKind.RecordStructDeclaration : SyntaxKind.RecordDeclaration);
|
|
return syntaxFactory.RecordDeclaration(kind2, attributeLists, SyntaxList<SyntaxToken>.op_Implicit(val3.ToList()), syntaxToken2, syntaxToken3, name, typeParameterList, parameterList, baseList2, SyntaxListBuilder<TypeParameterConstraintClauseSyntax>.op_Implicit(constraints), openBraceToken, SyntaxListBuilder<MemberDeclarationSyntax>.op_Implicit(members), closeBraceToken, semicolonToken);
|
|
}
|
|
default:
|
|
throw ExceptionUtilities.UnexpectedValue((object)syntaxToken2.Kind);
|
|
}
|
|
}
|
|
bool tryScanRecordStart([NotNullWhen(true)] out SyntaxToken? reference, out SyntaxToken? reference2)
|
|
{
|
|
SyntaxKind kind2;
|
|
bool flag3;
|
|
if (base.CurrentToken.ContextualKind == SyntaxKind.RecordKeyword)
|
|
{
|
|
reference = SyntaxParser.ConvertToKeyword(EatToken());
|
|
kind2 = base.CurrentToken.Kind;
|
|
flag3 = kind2 - 8374 <= SyntaxKind.List;
|
|
reference2 = (flag3 ? EatToken() : null);
|
|
return true;
|
|
}
|
|
kind2 = base.CurrentToken.Kind;
|
|
flag3 = kind2 - 8374 <= SyntaxKind.List;
|
|
if (flag3 && PeekToken(1).ContextualKind == SyntaxKind.RecordKeyword && PeekToken(2).Kind == SyntaxKind.IdentifierToken)
|
|
{
|
|
SyntaxToken syntaxToken2 = EatToken();
|
|
reference = AddLeadingSkippedSyntax(AddError(SyntaxParser.ConvertToKeyword(EatToken()), ErrorCode.ERR_MisplacedRecord), (GreenNode)(object)syntaxToken2);
|
|
reference2 = SyntaxFactory.MissingToken(syntaxToken2.Kind);
|
|
return true;
|
|
}
|
|
reference = null;
|
|
reference2 = null;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
private void SkipBadMemberListTokens(ref SyntaxToken openBrace, SyntaxListBuilder members)
|
|
{
|
|
if (members.Count > 0)
|
|
{
|
|
GreenNode previousNode = members[members.Count - 1];
|
|
SkipBadMemberListTokens(ref previousNode);
|
|
members[members.Count - 1] = previousNode;
|
|
}
|
|
else
|
|
{
|
|
GreenNode previousNode2 = (GreenNode)(object)openBrace;
|
|
SkipBadMemberListTokens(ref previousNode2);
|
|
openBrace = (SyntaxToken)(object)previousNode2;
|
|
}
|
|
}
|
|
|
|
private void SkipBadMemberListTokens(ref GreenNode previousNode)
|
|
{
|
|
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
|
|
int num = 0;
|
|
SyntaxListBuilder val = _pool.Allocate();
|
|
bool flag = false;
|
|
SyntaxToken syntaxToken = EatToken();
|
|
syntaxToken = AddError(syntaxToken, ErrorCode.ERR_InvalidMemberDecl, syntaxToken.Text);
|
|
val.Add((GreenNode)(object)syntaxToken);
|
|
while (!flag)
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
bool flag2 = CanStartMember(kind);
|
|
if (flag2)
|
|
{
|
|
bool flag3 = kind == SyntaxKind.DelegateKeyword;
|
|
if (flag3)
|
|
{
|
|
SyntaxKind kind2 = PeekToken(1).Kind;
|
|
bool flag4 = ((kind2 == SyntaxKind.OpenParenToken || kind2 == SyntaxKind.OpenBraceToken) ? true : false);
|
|
flag3 = flag4;
|
|
}
|
|
flag2 = !flag3;
|
|
}
|
|
if (flag2)
|
|
{
|
|
flag = true;
|
|
continue;
|
|
}
|
|
switch (kind)
|
|
{
|
|
case SyntaxKind.OpenBraceToken:
|
|
num++;
|
|
break;
|
|
case SyntaxKind.CloseBraceToken:
|
|
if (num-- == 0)
|
|
{
|
|
flag = true;
|
|
continue;
|
|
}
|
|
break;
|
|
case SyntaxKind.EndOfFileToken:
|
|
flag = true;
|
|
continue;
|
|
}
|
|
val.Add((GreenNode)(object)EatToken());
|
|
}
|
|
previousNode = (GreenNode)(object)AddTrailingSkippedSyntax((CSharpSyntaxNode)(object)previousNode, _pool.ToTokenListAndFree(val).Node);
|
|
}
|
|
|
|
private bool IsPossibleMemberStartOrStop()
|
|
{
|
|
if (!IsPossibleMemberStart())
|
|
{
|
|
return base.CurrentToken.Kind == SyntaxKind.CloseBraceToken;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private bool IsPossibleAggregateClauseStartOrStop()
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
if ((kind != SyntaxKind.OpenBraceToken && kind != SyntaxKind.ColonToken) || 1 == 0)
|
|
{
|
|
return IsCurrentTokenWhereOfConstraintClause();
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private BaseListSyntax ParseBaseList()
|
|
{
|
|
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxToken colon = TryEatToken(SyntaxKind.ColonToken);
|
|
if (colon == null)
|
|
{
|
|
return null;
|
|
}
|
|
SeparatedSyntaxListBuilder<BaseTypeSyntax> list = _pool.AllocateSeparated<BaseTypeSyntax>();
|
|
TypeSyntax type = ParseType();
|
|
ArgumentListSyntax argumentListSyntax = ((base.CurrentToken.Kind == SyntaxKind.OpenParenToken) ? ParseParenthesizedArgumentList() : null);
|
|
list.Add((argumentListSyntax != null) ? ((BaseTypeSyntax)_syntaxFactory.PrimaryConstructorBaseType(type, argumentListSyntax)) : ((BaseTypeSyntax)_syntaxFactory.SimpleBaseType(type)));
|
|
while (base.CurrentToken.Kind != SyntaxKind.OpenBraceToken && ((_termState & TerminatorState.IsEndOfRecordOrClassOrStructOrInterfaceSignature) == 0 || base.CurrentToken.Kind != SyntaxKind.SemicolonToken) && !IsCurrentTokenWhereOfConstraintClause())
|
|
{
|
|
if (base.CurrentToken.Kind == SyntaxKind.CommaToken || IsPossibleType())
|
|
{
|
|
list.AddSeparator((GreenNode)(object)EatToken(SyntaxKind.CommaToken));
|
|
list.Add((BaseTypeSyntax)_syntaxFactory.SimpleBaseType(ParseType()));
|
|
}
|
|
else if (skipBadBaseListTokens(ref colon, list, SyntaxKind.CommaToken) == PostSkipAction.Abort)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
return _syntaxFactory.BaseList(colon, _pool.ToListAndFree<BaseTypeSyntax>(ref list));
|
|
PostSkipAction skipBadBaseListTokens(ref SyntaxToken startToken, SeparatedSyntaxListBuilder<BaseTypeSyntax> list2, SyntaxKind expected)
|
|
{
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
|
return SkipBadSeparatedListTokensWithExpectedKind<SyntaxToken, BaseTypeSyntax>(ref startToken, list2, (LanguageParser p) => p.CurrentToken.Kind != SyntaxKind.CommaToken && !p.IsPossibleAttribute(), (LanguageParser p, SyntaxKind _) => p.CurrentToken.Kind == SyntaxKind.OpenBraceToken || p.IsCurrentTokenWhereOfConstraintClause(), expected);
|
|
}
|
|
}
|
|
|
|
private bool IsCurrentTokenWhereOfConstraintClause()
|
|
{
|
|
if (base.CurrentToken.ContextualKind == SyntaxKind.WhereKeyword && PeekToken(1).Kind == SyntaxKind.IdentifierToken)
|
|
{
|
|
return PeekToken(2).Kind == SyntaxKind.ColonToken;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private void ParseTypeParameterConstraintClauses(SyntaxListBuilder list)
|
|
{
|
|
while (base.CurrentToken.ContextualKind == SyntaxKind.WhereKeyword)
|
|
{
|
|
list.Add((GreenNode)(object)ParseTypeParameterConstraintClause());
|
|
}
|
|
}
|
|
|
|
private TypeParameterConstraintClauseSyntax ParseTypeParameterConstraintClause()
|
|
{
|
|
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_016a: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxToken whereKeyword = EatContextualToken(SyntaxKind.WhereKeyword);
|
|
IdentifierNameSyntax name = ((!IsTrueIdentifier()) ? AddError(CreateMissingIdentifierName(), ErrorCode.ERR_IdentifierExpected) : ParseIdentifierName());
|
|
SyntaxToken colonToken = EatToken(SyntaxKind.ColonToken);
|
|
SeparatedSyntaxListBuilder<TypeParameterConstraintSyntax> list = _pool.AllocateSeparated<TypeParameterConstraintSyntax>();
|
|
if (base.CurrentToken.Kind == SyntaxKind.OpenBraceToken || IsCurrentTokenWhereOfConstraintClause())
|
|
{
|
|
list.Add((TypeParameterConstraintSyntax)_syntaxFactory.TypeConstraint(AddError(CreateMissingIdentifierName(), ErrorCode.ERR_TypeExpected)));
|
|
}
|
|
else
|
|
{
|
|
list.Add(ParseTypeParameterConstraint());
|
|
while (base.CurrentToken.Kind != SyntaxKind.OpenBraceToken && ((_termState & TerminatorState.IsEndOfRecordOrClassOrStructOrInterfaceSignature) == 0 || base.CurrentToken.Kind != SyntaxKind.SemicolonToken) && base.CurrentToken.Kind != SyntaxKind.EqualsGreaterThanToken && base.CurrentToken.ContextualKind != SyntaxKind.WhereKeyword)
|
|
{
|
|
if (base.CurrentToken.Kind == SyntaxKind.CommaToken || IsPossibleTypeParameterConstraint())
|
|
{
|
|
list.AddSeparator((GreenNode)(object)EatToken(SyntaxKind.CommaToken));
|
|
if (IsCurrentTokenWhereOfConstraintClause())
|
|
{
|
|
list.Add((TypeParameterConstraintSyntax)_syntaxFactory.TypeConstraint(AddError(CreateMissingIdentifierName(), ErrorCode.ERR_TypeExpected)));
|
|
break;
|
|
}
|
|
list.Add(ParseTypeParameterConstraint());
|
|
}
|
|
else if (skipBadTypeParameterConstraintTokens(list, SyntaxKind.CommaToken) == PostSkipAction.Abort)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return _syntaxFactory.TypeParameterConstraintClause(whereKeyword, name, colonToken, _pool.ToListAndFree<TypeParameterConstraintSyntax>(ref list));
|
|
PostSkipAction skipBadTypeParameterConstraintTokens(SeparatedSyntaxListBuilder<TypeParameterConstraintSyntax> list2, SyntaxKind expected)
|
|
{
|
|
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
|
|
CSharpSyntaxNode startToken = null;
|
|
return SkipBadSeparatedListTokensWithExpectedKind<CSharpSyntaxNode, TypeParameterConstraintSyntax>(ref startToken, list2, (LanguageParser p) => p.CurrentToken.Kind != SyntaxKind.CommaToken && !p.IsPossibleTypeParameterConstraint(), (LanguageParser p, SyntaxKind _) => p.CurrentToken.Kind == SyntaxKind.OpenBraceToken || p.IsCurrentTokenWhereOfConstraintClause(), expected);
|
|
}
|
|
}
|
|
|
|
private bool IsPossibleTypeParameterConstraint()
|
|
{
|
|
switch (base.CurrentToken.Kind)
|
|
{
|
|
case SyntaxKind.DefaultKeyword:
|
|
case SyntaxKind.NewKeyword:
|
|
case SyntaxKind.ClassKeyword:
|
|
case SyntaxKind.StructKeyword:
|
|
return true;
|
|
case SyntaxKind.IdentifierToken:
|
|
return IsTrueIdentifier();
|
|
default:
|
|
return IsPredefinedType(base.CurrentToken.Kind);
|
|
}
|
|
}
|
|
|
|
private TypeParameterConstraintSyntax ParseTypeParameterConstraint()
|
|
{
|
|
return base.CurrentToken.Kind switch
|
|
{
|
|
SyntaxKind.NewKeyword => _syntaxFactory.ConstructorConstraint(EatToken(), EatToken(SyntaxKind.OpenParenToken), EatToken(SyntaxKind.CloseParenToken)),
|
|
SyntaxKind.StructKeyword => _syntaxFactory.ClassOrStructConstraint(SyntaxKind.StructConstraint, EatToken(), (base.CurrentToken.Kind == SyntaxKind.QuestionToken) ? AddError(EatToken(), ErrorCode.ERR_UnexpectedToken, SyntaxFacts.GetText(SyntaxKind.QuestionToken)) : null),
|
|
SyntaxKind.ClassKeyword => _syntaxFactory.ClassOrStructConstraint(SyntaxKind.ClassConstraint, EatToken(), TryEatToken(SyntaxKind.QuestionToken)),
|
|
SyntaxKind.DefaultKeyword => _syntaxFactory.DefaultConstraint(EatToken()),
|
|
SyntaxKind.EnumKeyword => _syntaxFactory.TypeConstraint(AddTrailingSkippedSyntax(AddError(CreateMissingIdentifierName(), ErrorCode.ERR_NoEnumConstraint), (GreenNode)(object)EatToken())),
|
|
SyntaxKind.DelegateKeyword => (PeekToken(1).Kind == SyntaxKind.AsteriskToken) ? _syntaxFactory.TypeConstraint(ParseType()) : _syntaxFactory.TypeConstraint(AddTrailingSkippedSyntax(AddError(CreateMissingIdentifierName(), ErrorCode.ERR_NoDelegateConstraint), (GreenNode)(object)EatToken())),
|
|
_ => _syntaxFactory.TypeConstraint(ParseType()),
|
|
};
|
|
}
|
|
|
|
private bool IsPossibleMemberStart()
|
|
{
|
|
return CanStartMember(base.CurrentToken.Kind);
|
|
}
|
|
|
|
private static bool CanStartMember(SyntaxKind kind)
|
|
{
|
|
switch (kind)
|
|
{
|
|
case SyntaxKind.TildeToken:
|
|
case SyntaxKind.OpenParenToken:
|
|
case SyntaxKind.OpenBracketToken:
|
|
case SyntaxKind.BoolKeyword:
|
|
case SyntaxKind.ByteKeyword:
|
|
case SyntaxKind.SByteKeyword:
|
|
case SyntaxKind.ShortKeyword:
|
|
case SyntaxKind.UShortKeyword:
|
|
case SyntaxKind.IntKeyword:
|
|
case SyntaxKind.UIntKeyword:
|
|
case SyntaxKind.LongKeyword:
|
|
case SyntaxKind.ULongKeyword:
|
|
case SyntaxKind.DoubleKeyword:
|
|
case SyntaxKind.FloatKeyword:
|
|
case SyntaxKind.DecimalKeyword:
|
|
case SyntaxKind.StringKeyword:
|
|
case SyntaxKind.CharKeyword:
|
|
case SyntaxKind.VoidKeyword:
|
|
case SyntaxKind.ObjectKeyword:
|
|
case SyntaxKind.PublicKeyword:
|
|
case SyntaxKind.PrivateKeyword:
|
|
case SyntaxKind.InternalKeyword:
|
|
case SyntaxKind.ProtectedKeyword:
|
|
case SyntaxKind.StaticKeyword:
|
|
case SyntaxKind.ReadOnlyKeyword:
|
|
case SyntaxKind.SealedKeyword:
|
|
case SyntaxKind.ConstKeyword:
|
|
case SyntaxKind.FixedKeyword:
|
|
case SyntaxKind.VolatileKeyword:
|
|
case SyntaxKind.NewKeyword:
|
|
case SyntaxKind.OverrideKeyword:
|
|
case SyntaxKind.AbstractKeyword:
|
|
case SyntaxKind.VirtualKeyword:
|
|
case SyntaxKind.EventKeyword:
|
|
case SyntaxKind.ExternKeyword:
|
|
case SyntaxKind.RefKeyword:
|
|
case SyntaxKind.ClassKeyword:
|
|
case SyntaxKind.StructKeyword:
|
|
case SyntaxKind.InterfaceKeyword:
|
|
case SyntaxKind.EnumKeyword:
|
|
case SyntaxKind.DelegateKeyword:
|
|
case SyntaxKind.UnsafeKeyword:
|
|
case SyntaxKind.ExplicitKeyword:
|
|
case SyntaxKind.ImplicitKeyword:
|
|
case SyntaxKind.IdentifierToken:
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
|
|
private bool IsTypeDeclarationStart()
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
if (kind - 8374 > (SyntaxKind)3)
|
|
{
|
|
if (kind != SyntaxKind.DelegateKeyword)
|
|
{
|
|
if (kind == SyntaxKind.IdentifierToken)
|
|
{
|
|
if (base.CurrentToken.ContextualKind == SyntaxKind.RecordKeyword)
|
|
{
|
|
return IsFeatureEnabled(MessageID.IDS_FeatureRecords);
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
else if (!IsFunctionPointerStart())
|
|
{
|
|
goto IL_0030;
|
|
}
|
|
return false;
|
|
}
|
|
goto IL_0030;
|
|
IL_0030:
|
|
return true;
|
|
}
|
|
|
|
private bool CanReuseMemberDeclaration(SyntaxKind kind, bool isGlobal)
|
|
{
|
|
switch (kind)
|
|
{
|
|
case SyntaxKind.NamespaceDeclaration:
|
|
case SyntaxKind.FileScopedNamespaceDeclaration:
|
|
case SyntaxKind.ClassDeclaration:
|
|
case SyntaxKind.StructDeclaration:
|
|
case SyntaxKind.InterfaceDeclaration:
|
|
case SyntaxKind.EnumDeclaration:
|
|
case SyntaxKind.DelegateDeclaration:
|
|
case SyntaxKind.EventFieldDeclaration:
|
|
case SyntaxKind.OperatorDeclaration:
|
|
case SyntaxKind.ConversionOperatorDeclaration:
|
|
case SyntaxKind.ConstructorDeclaration:
|
|
case SyntaxKind.DestructorDeclaration:
|
|
case SyntaxKind.PropertyDeclaration:
|
|
case SyntaxKind.EventDeclaration:
|
|
case SyntaxKind.IndexerDeclaration:
|
|
case SyntaxKind.RecordDeclaration:
|
|
case SyntaxKind.RecordStructDeclaration:
|
|
return true;
|
|
case SyntaxKind.FieldDeclaration:
|
|
case SyntaxKind.MethodDeclaration:
|
|
if (!isGlobal || base.IsScript)
|
|
{
|
|
return true;
|
|
}
|
|
return base.CurrentNode.Parent is Microsoft.CodeAnalysis.CSharp.Syntax.CompilationUnitSyntax;
|
|
case SyntaxKind.GlobalStatement:
|
|
return isGlobal;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public MemberDeclarationSyntax ParseMemberDeclaration()
|
|
{
|
|
return ParseWithStackGuard((LanguageParser @this) => @this.ParseMemberDeclaration(SyntaxKind.StructDeclaration), createEmptyNodeFunc);
|
|
static MemberDeclarationSyntax createEmptyNodeFunc(LanguageParser @this)
|
|
{
|
|
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
|
|
return @this._syntaxFactory.IncompleteMember(default(SyntaxList<AttributeListSyntax>), default(SyntaxList<SyntaxToken>), @this.CreateMissingIdentifierName());
|
|
}
|
|
}
|
|
|
|
internal MemberDeclarationSyntax ParseMemberDeclarationOrStatement(SyntaxKind parentKind)
|
|
{
|
|
_recursionDepth++;
|
|
StackGuard.EnsureSufficientExecutionStack(_recursionDepth);
|
|
MemberDeclarationSyntax result = ParseMemberDeclarationOrStatementCore(parentKind);
|
|
_recursionDepth--;
|
|
return result;
|
|
}
|
|
|
|
private MemberDeclarationSyntax ParseMemberDeclarationOrStatementCore(SyntaxKind parentKind)
|
|
{
|
|
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0283: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0260: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_024a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_021a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0427: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0523: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0558: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_04aa: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_048a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_05a9: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_057f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0596: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_050c: Unknown result type (might be due to invalid IL or missing references)
|
|
CancellationToken cancellationToken = base.cancellationToken;
|
|
cancellationToken.ThrowIfCancellationRequested();
|
|
if (IsIncrementalAndFactoryContextMatches && CanReuseMemberDeclaration(base.CurrentNodeKind, isGlobal: true))
|
|
{
|
|
return (MemberDeclarationSyntax)(object)EatNode();
|
|
}
|
|
TerminatorState termState = _termState;
|
|
SyntaxList<AttributeListSyntax> val = ParseStatementAttributeDeclarations();
|
|
bool flag = val.Count > 0;
|
|
ResetPoint startPoint = GetResetPoint();
|
|
SyntaxListBuilder modifiers = _pool.Allocate();
|
|
try
|
|
{
|
|
if (!flag || !base.IsScript)
|
|
{
|
|
bool isInAsync = IsInAsync;
|
|
if (!base.IsScript)
|
|
{
|
|
IsInAsync = true;
|
|
}
|
|
try
|
|
{
|
|
switch (base.CurrentToken.Kind)
|
|
{
|
|
case SyntaxKind.UnsafeKeyword:
|
|
if (PeekToken(1).Kind == SyntaxKind.OpenBraceToken)
|
|
{
|
|
return _syntaxFactory.GlobalStatement(ParseUnsafeStatement(val));
|
|
}
|
|
break;
|
|
case SyntaxKind.FixedKeyword:
|
|
if (PeekToken(1).Kind == SyntaxKind.OpenParenToken)
|
|
{
|
|
return _syntaxFactory.GlobalStatement(ParseFixedStatement(val));
|
|
}
|
|
break;
|
|
case SyntaxKind.DelegateKeyword:
|
|
{
|
|
SyntaxKind kind = PeekToken(1).Kind;
|
|
if (kind != SyntaxKind.OpenParenToken && kind != SyntaxKind.OpenBraceToken)
|
|
{
|
|
break;
|
|
}
|
|
return _syntaxFactory.GlobalStatement(ParseExpressionStatement(val));
|
|
}
|
|
case SyntaxKind.NewKeyword:
|
|
if (IsPossibleNewExpression())
|
|
{
|
|
return _syntaxFactory.GlobalStatement(ParseExpressionStatement(val));
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
IsInAsync = isInAsync;
|
|
}
|
|
}
|
|
ParseModifiers(modifiers, forAccessors: false, forTopLevelStatements: true, out var isPossibleTypeDeclaration);
|
|
bool flag2 = modifiers.Count > 0;
|
|
MemberDeclarationSyntax result;
|
|
if (base.CurrentToken.Kind == SyntaxKind.IdentifierToken && PeekToken(1).Kind == SyntaxKind.OpenParenToken && (flag || flag2))
|
|
{
|
|
PredefinedTypeSyntax type = _syntaxFactory.PredefinedType(AddError(SyntaxFactory.MissingToken(SyntaxKind.VoidKeyword), ErrorCode.ERR_MemberNeedsType));
|
|
if (base.IsScript)
|
|
{
|
|
SyntaxToken identifier = EatToken();
|
|
return ParseMethodDeclaration(val, modifiers, type, null, identifier, null);
|
|
}
|
|
if (tryParseLocalDeclarationStatementFromStartPoint<LocalFunctionStatementSyntax>(val, ref startPoint, out result))
|
|
{
|
|
return result;
|
|
}
|
|
}
|
|
if (base.CurrentToken.Kind == SyntaxKind.ConstKeyword)
|
|
{
|
|
if (!base.IsScript && tryParseLocalDeclarationStatementFromStartPoint<LocalDeclarationStatementSyntax>(val, ref startPoint, out result))
|
|
{
|
|
return result;
|
|
}
|
|
return ParseConstantFieldDeclaration(val, modifiers, parentKind);
|
|
}
|
|
if (base.CurrentToken.Kind == SyntaxKind.EventKeyword)
|
|
{
|
|
return ParseEventDeclaration(val, modifiers, parentKind);
|
|
}
|
|
if (base.CurrentToken.Kind == SyntaxKind.FixedKeyword)
|
|
{
|
|
return ParseFixedSizeBufferDeclaration(val, modifiers, parentKind);
|
|
}
|
|
result = TryParseConversionOperatorDeclaration(val, modifiers);
|
|
if (result != null)
|
|
{
|
|
return result;
|
|
}
|
|
if (base.CurrentToken.Kind == SyntaxKind.NamespaceKeyword)
|
|
{
|
|
return ParseNamespaceDeclaration(val, modifiers);
|
|
}
|
|
if (isPossibleTypeDeclaration && IsTypeDeclarationStart())
|
|
{
|
|
return ParseTypeDeclaration(val, modifiers);
|
|
}
|
|
TypeSyntax type2 = ParseReturnType();
|
|
ResetPoint state = GetResetPoint();
|
|
try
|
|
{
|
|
if ((!flag || !base.IsScript) && !flag2 && (type2.Kind == SyntaxKind.RefType || !IsOperatorStart(out var _, advanceParser: false)))
|
|
{
|
|
Reset(ref startPoint);
|
|
SyntaxKind kind2 = base.CurrentToken.Kind;
|
|
if (kind2 != SyntaxKind.CloseBraceToken && kind2 != SyntaxKind.EndOfFileToken && IsPossibleStatement(acceptAccessibilityMods: true))
|
|
{
|
|
TerminatorState termState2 = _termState;
|
|
_termState |= TerminatorState.IsPossibleStatementStartOrStop;
|
|
bool isInAsync2 = IsInAsync;
|
|
if (!base.IsScript)
|
|
{
|
|
IsInAsync = true;
|
|
}
|
|
StatementSyntax statement = ParseStatementCore(val, isGlobal: true);
|
|
IsInAsync = isInAsync2;
|
|
_termState = termState2;
|
|
if (isAcceptableNonDeclarationStatement(statement, base.IsScript))
|
|
{
|
|
return _syntaxFactory.GlobalStatement(statement);
|
|
}
|
|
}
|
|
Reset(ref state);
|
|
}
|
|
if (IsMisplacedModifier(modifiers, val, type2, out result))
|
|
{
|
|
return result;
|
|
}
|
|
ExplicitInterfaceSpecifierSyntax explicitInterfaceOpt2;
|
|
SyntaxToken identifierOrThisOpt;
|
|
TypeParameterListSyntax typeParameterListOpt;
|
|
do
|
|
{
|
|
bool isRef = type2.IsRef;
|
|
if (!isRef && IsOperatorStart(out explicitInterfaceOpt2))
|
|
{
|
|
return ParseOperatorDeclaration(val, modifiers, type2, explicitInterfaceOpt2);
|
|
}
|
|
if ((!isRef || !base.IsScript) && IsFieldDeclaration(isEvent: false, isGlobalScriptLevel: true))
|
|
{
|
|
TerminatorState termState3 = _termState;
|
|
if ((!flag && !flag2) || !base.IsScript)
|
|
{
|
|
_termState |= TerminatorState.IsPossibleStatementStartOrStop;
|
|
if (!base.IsScript)
|
|
{
|
|
Reset(ref startPoint);
|
|
if (tryParseLocalDeclarationStatement<LocalDeclarationStatementSyntax>(val, out result))
|
|
{
|
|
return result;
|
|
}
|
|
Reset(ref state);
|
|
}
|
|
}
|
|
if (!isRef)
|
|
{
|
|
return ParseNormalFieldDeclaration(val, modifiers, type2, parentKind);
|
|
}
|
|
_termState = termState3;
|
|
}
|
|
ParseMemberName(out explicitInterfaceOpt2, out identifierOrThisOpt, out typeParameterListOpt, isEvent: false);
|
|
if (!flag2 && !flag && !base.IsScript && explicitInterfaceOpt2 == null && identifierOrThisOpt == null && typeParameterListOpt == null && !((GreenNode)type2).IsMissing && type2.Kind != SyntaxKind.RefType && !isFollowedByPossibleUsingDirective() && tryParseLocalDeclarationStatementFromStartPoint<LocalDeclarationStatementSyntax>(val, ref startPoint, out result))
|
|
{
|
|
return result;
|
|
}
|
|
if (IsNoneOrIncompleteMember(parentKind, val, modifiers, type2, explicitInterfaceOpt2, identifierOrThisOpt, typeParameterListOpt, out result))
|
|
{
|
|
return result;
|
|
}
|
|
}
|
|
while (ReconsideredTypeAsAsyncModifier(ref modifiers, ref type2, ref state, ref explicitInterfaceOpt2, ref identifierOrThisOpt, ref typeParameterListOpt));
|
|
if (TryParseIndexerOrPropertyDeclaration(val, modifiers, type2, explicitInterfaceOpt2, identifierOrThisOpt, typeParameterListOpt, out result))
|
|
{
|
|
return result;
|
|
}
|
|
if (!base.IsScript)
|
|
{
|
|
if (explicitInterfaceOpt2 == null && tryParseLocalDeclarationStatementFromStartPoint<LocalFunctionStatementSyntax>(val, ref startPoint, out result))
|
|
{
|
|
return result;
|
|
}
|
|
if (!flag2 && tryParseStatement(val, ref startPoint, out result))
|
|
{
|
|
return result;
|
|
}
|
|
}
|
|
return ParseMethodDeclaration(val, modifiers, type2, explicitInterfaceOpt2, identifierOrThisOpt, typeParameterListOpt);
|
|
}
|
|
finally
|
|
{
|
|
Release(ref state);
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
_pool.Free(modifiers);
|
|
_termState = termState;
|
|
Release(ref startPoint);
|
|
}
|
|
static bool isAcceptableNonDeclarationStatement(StatementSyntax statementSyntax, bool isScript)
|
|
{
|
|
SyntaxKind? syntaxKind = statementSyntax?.Kind;
|
|
if (syntaxKind.HasValue)
|
|
{
|
|
SyntaxKind valueOrDefault = syntaxKind.GetValueOrDefault();
|
|
if (valueOrDefault == SyntaxKind.LocalDeclarationStatement)
|
|
{
|
|
if (!isScript)
|
|
{
|
|
if (statementSyntax is LocalDeclarationStatementSyntax localDeclarationStatementSyntax)
|
|
{
|
|
return localDeclarationStatementSyntax.UsingKeyword != null;
|
|
}
|
|
return false;
|
|
}
|
|
return false;
|
|
}
|
|
if (valueOrDefault != SyntaxKind.ExpressionStatement)
|
|
{
|
|
if (valueOrDefault == SyntaxKind.LocalFunctionStatement)
|
|
{
|
|
goto IL_0081;
|
|
}
|
|
}
|
|
else if (!isScript && statementSyntax is ExpressionStatementSyntax expressionStatementSyntax)
|
|
{
|
|
ExpressionSyntax expression = expressionStatementSyntax.Expression;
|
|
if (expression != null && expression.Kind == SyntaxKind.IdentifierName)
|
|
{
|
|
SyntaxToken semicolonToken = expressionStatementSyntax.SemicolonToken;
|
|
if (semicolonToken != null && ((GreenNode)semicolonToken).IsMissing)
|
|
{
|
|
goto IL_0081;
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
goto IL_0081;
|
|
IL_0081:
|
|
return false;
|
|
}
|
|
bool isFollowedByPossibleUsingDirective()
|
|
{
|
|
if (base.CurrentToken.Kind == SyntaxKind.UsingKeyword)
|
|
{
|
|
return !IsPossibleTopLevelUsingLocalDeclarationStatement();
|
|
}
|
|
if (base.CurrentToken.ContextualKind == SyntaxKind.GlobalKeyword && PeekToken(1).Kind == SyntaxKind.UsingKeyword)
|
|
{
|
|
using (GetDisposableResetPoint(resetOnDispose: true))
|
|
{
|
|
EatToken();
|
|
return !IsPossibleTopLevelUsingLocalDeclarationStatement();
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
bool tryParseLocalDeclarationStatement<DeclarationSyntax>(SyntaxList<AttributeListSyntax> attributes, out MemberDeclarationSyntax reference) where DeclarationSyntax : StatementSyntax
|
|
{
|
|
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
|
|
bool isInAsync3 = IsInAsync;
|
|
IsInAsync = true;
|
|
int lastTokenPosition = -1;
|
|
IsMakingProgress(ref lastTokenPosition);
|
|
StatementSyntax statementSyntax = ParseLocalDeclarationStatement(attributes);
|
|
IsInAsync = isInAsync3;
|
|
if (statementSyntax is DeclarationSyntax statement2 && IsMakingProgress(ref lastTokenPosition, assertIfFalse: false))
|
|
{
|
|
reference = _syntaxFactory.GlobalStatement(statement2);
|
|
return true;
|
|
}
|
|
reference = null;
|
|
return false;
|
|
}
|
|
bool tryParseLocalDeclarationStatementFromStartPoint<DeclarationSyntax>(SyntaxList<AttributeListSyntax> attributes, ref ResetPoint state2, out MemberDeclarationSyntax result2) where DeclarationSyntax : StatementSyntax
|
|
{
|
|
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
|
|
using DisposableResetPoint disposableResetPoint = GetDisposableResetPoint(resetOnDispose: false);
|
|
Reset(ref state2);
|
|
if (tryParseLocalDeclarationStatement<DeclarationSyntax>(attributes, out result2))
|
|
{
|
|
return true;
|
|
}
|
|
disposableResetPoint.Reset();
|
|
return false;
|
|
}
|
|
bool tryParseStatement(SyntaxList<AttributeListSyntax> attributes, ref ResetPoint afterAttributesPoint, out MemberDeclarationSyntax reference)
|
|
{
|
|
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
|
|
using DisposableResetPoint disposableResetPoint = GetDisposableResetPoint(resetOnDispose: false);
|
|
Reset(ref afterAttributesPoint);
|
|
if (IsPossibleStatement(acceptAccessibilityMods: false))
|
|
{
|
|
TerminatorState termState4 = _termState;
|
|
_termState |= TerminatorState.IsPossibleStatementStartOrStop;
|
|
bool isInAsync3 = IsInAsync;
|
|
IsInAsync = true;
|
|
StatementSyntax statementSyntax = ParseStatementCore(attributes, isGlobal: true);
|
|
IsInAsync = isInAsync3;
|
|
_termState = termState4;
|
|
if (statementSyntax != null)
|
|
{
|
|
reference = _syntaxFactory.GlobalStatement(statementSyntax);
|
|
return true;
|
|
}
|
|
}
|
|
disposableResetPoint.Reset();
|
|
reference = null;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
private bool IsMisplacedModifier(SyntaxListBuilder modifiers, SyntaxList<AttributeListSyntax> attributes, TypeSyntax type, out MemberDeclarationSyntax result)
|
|
{
|
|
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
|
|
bool flag = GetModifierExcludingScoped(base.CurrentToken) != DeclarationModifiers.None;
|
|
if (flag)
|
|
{
|
|
bool flag2;
|
|
switch (base.CurrentToken.ContextualKind)
|
|
{
|
|
case SyntaxKind.PartialKeyword:
|
|
case SyntaxKind.AsyncKeyword:
|
|
case SyntaxKind.RequiredKeyword:
|
|
case SyntaxKind.FileKeyword:
|
|
flag2 = true;
|
|
break;
|
|
default:
|
|
flag2 = false;
|
|
break;
|
|
}
|
|
flag = !flag2;
|
|
}
|
|
if (flag && IsComplete(type))
|
|
{
|
|
SyntaxToken currentToken = base.CurrentToken;
|
|
type = AddError(type, ((GreenNode)type).FullWidth + ((GreenNode)currentToken).GetLeadingTriviaWidth(), ((GreenNode)currentToken).Width, ErrorCode.ERR_BadModifierLocation, currentToken.Text);
|
|
result = _syntaxFactory.IncompleteMember(attributes, SyntaxList<SyntaxToken>.op_Implicit(modifiers.ToList()), type);
|
|
return true;
|
|
}
|
|
result = null;
|
|
return false;
|
|
}
|
|
|
|
private bool IsNoneOrIncompleteMember(SyntaxKind parentKind, SyntaxList<AttributeListSyntax> attributes, SyntaxListBuilder modifiers, TypeSyntax type, ExplicitInterfaceSpecifierSyntax explicitInterfaceOpt, SyntaxToken identifierOrThisOpt, TypeParameterListSyntax typeParameterListOpt, out MemberDeclarationSyntax result)
|
|
{
|
|
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
|
|
if (explicitInterfaceOpt == null && identifierOrThisOpt == null && typeParameterListOpt == null)
|
|
{
|
|
if (attributes.Count == 0 && modifiers.Count == 0 && ((GreenNode)type).IsMissing && type.Kind != SyntaxKind.RefType)
|
|
{
|
|
result = null;
|
|
return true;
|
|
}
|
|
IncompleteMemberSyntax incompleteMemberSyntax = _syntaxFactory.IncompleteMember(attributes, SyntaxList<SyntaxToken>.op_Implicit(modifiers.ToList()), ((GreenNode)type).IsMissing ? null : type);
|
|
if (ContainsErrorDiagnostic((GreenNode)(object)incompleteMemberSyntax))
|
|
{
|
|
result = incompleteMemberSyntax;
|
|
}
|
|
else
|
|
{
|
|
bool flag = ((parentKind == SyntaxKind.NamespaceDeclaration || parentKind == SyntaxKind.FileScopedNamespaceDeclaration) ? true : false);
|
|
if (flag || (parentKind == SyntaxKind.CompilationUnit && !base.IsScript))
|
|
{
|
|
result = AddErrorToLastToken(incompleteMemberSyntax, ErrorCode.ERR_NamespaceUnexpected);
|
|
}
|
|
else
|
|
{
|
|
result = AddError(incompleteMemberSyntax, ((GreenNode)incompleteMemberSyntax).FullWidth + ((GreenNode)base.CurrentToken).GetLeadingTriviaWidth(), ((GreenNode)base.CurrentToken).Width, ErrorCode.ERR_InvalidMemberDecl, base.CurrentToken.Text);
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
result = null;
|
|
return false;
|
|
}
|
|
|
|
private bool ReconsideredTypeAsAsyncModifier(ref SyntaxListBuilder modifiers, ref TypeSyntax type, ref ResetPoint afterTypeResetPoint, ref ExplicitInterfaceSpecifierSyntax explicitInterfaceOpt, ref SyntaxToken identifierOrThisOpt, ref TypeParameterListSyntax typeParameterListOpt)
|
|
{
|
|
if (type.Kind != SyntaxKind.RefType && identifierOrThisOpt != null)
|
|
{
|
|
if (typeParameterListOpt == null || !((GreenNode)typeParameterListOpt).ContainsDiagnostics)
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
if (kind == SyntaxKind.OpenParenToken || kind == SyntaxKind.OpenBraceToken || kind == SyntaxKind.EqualsGreaterThanToken)
|
|
{
|
|
goto IL_0083;
|
|
}
|
|
}
|
|
if (ReconsiderTypeAsAsyncModifier(ref modifiers, type, identifierOrThisOpt))
|
|
{
|
|
Reset(ref afterTypeResetPoint);
|
|
explicitInterfaceOpt = null;
|
|
identifierOrThisOpt = null;
|
|
typeParameterListOpt = null;
|
|
Release(ref afterTypeResetPoint);
|
|
type = ParseReturnType();
|
|
afterTypeResetPoint = GetResetPoint();
|
|
return true;
|
|
}
|
|
}
|
|
goto IL_0083;
|
|
IL_0083:
|
|
return false;
|
|
}
|
|
|
|
private bool TryParseIndexerOrPropertyDeclaration(SyntaxList<AttributeListSyntax> attributes, SyntaxListBuilder modifiers, TypeSyntax type, ExplicitInterfaceSpecifierSyntax explicitInterfaceOpt, SyntaxToken identifierOrThisOpt, TypeParameterListSyntax typeParameterListOpt, out MemberDeclarationSyntax result)
|
|
{
|
|
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
|
|
if (identifierOrThisOpt.Kind == SyntaxKind.ThisKeyword)
|
|
{
|
|
result = ParseIndexerDeclaration(attributes, modifiers, type, explicitInterfaceOpt, identifierOrThisOpt, typeParameterListOpt);
|
|
return true;
|
|
}
|
|
if (IsStartOfPropertyBody(base.CurrentToken.Kind) || (base.CurrentToken.Kind == SyntaxKind.SemicolonToken && IsStartOfPropertyBody(PeekToken(1).Kind)))
|
|
{
|
|
result = ParsePropertyDeclaration(attributes, modifiers, type, explicitInterfaceOpt, identifierOrThisOpt, typeParameterListOpt);
|
|
return true;
|
|
}
|
|
result = null;
|
|
return false;
|
|
}
|
|
|
|
private static bool IsStartOfPropertyBody(SyntaxKind kind)
|
|
{
|
|
if (kind == SyntaxKind.OpenBraceToken || kind == SyntaxKind.EqualsGreaterThanToken)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
internal MemberDeclarationSyntax ParseMemberDeclaration(SyntaxKind parentKind)
|
|
{
|
|
_recursionDepth++;
|
|
StackGuard.EnsureSufficientExecutionStack(_recursionDepth);
|
|
MemberDeclarationSyntax result = ParseMemberDeclarationCore(parentKind);
|
|
_recursionDepth--;
|
|
return result;
|
|
}
|
|
|
|
private MemberDeclarationSyntax ParseMemberDeclarationCore(SyntaxKind parentKind)
|
|
{
|
|
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0185: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_020d: Unknown result type (might be due to invalid IL or missing references)
|
|
CancellationToken cancellationToken = base.cancellationToken;
|
|
cancellationToken.ThrowIfCancellationRequested();
|
|
if (IsIncrementalAndFactoryContextMatches && CanReuseMemberDeclaration(base.CurrentNodeKind, isGlobal: false))
|
|
{
|
|
return (MemberDeclarationSyntax)(object)EatNode();
|
|
}
|
|
SyntaxListBuilder modifiers = _pool.Allocate();
|
|
TerminatorState termState = _termState;
|
|
try
|
|
{
|
|
SyntaxList<AttributeListSyntax> attributes = ParseAttributeDeclarations(inExpressionContext: false);
|
|
ParseModifiers(modifiers, forAccessors: false, forTopLevelStatements: false, out var isPossibleTypeDeclaration);
|
|
if (base.CurrentToken.Kind == SyntaxKind.IdentifierToken && PeekToken(1).Kind == SyntaxKind.OpenParenToken)
|
|
{
|
|
return ParseConstructorDeclaration(attributes, modifiers);
|
|
}
|
|
if (base.CurrentToken.Kind == SyntaxKind.TildeToken)
|
|
{
|
|
return ParseDestructorDeclaration(attributes, modifiers);
|
|
}
|
|
if (base.CurrentToken.Kind == SyntaxKind.ConstKeyword)
|
|
{
|
|
return ParseConstantFieldDeclaration(attributes, modifiers, parentKind);
|
|
}
|
|
if (base.CurrentToken.Kind == SyntaxKind.EventKeyword)
|
|
{
|
|
return ParseEventDeclaration(attributes, modifiers, parentKind);
|
|
}
|
|
if (base.CurrentToken.Kind == SyntaxKind.FixedKeyword)
|
|
{
|
|
return ParseFixedSizeBufferDeclaration(attributes, modifiers, parentKind);
|
|
}
|
|
MemberDeclarationSyntax result = TryParseConversionOperatorDeclaration(attributes, modifiers);
|
|
if (result != null)
|
|
{
|
|
return result;
|
|
}
|
|
if (isPossibleTypeDeclaration && IsTypeDeclarationStart())
|
|
{
|
|
return ParseTypeDeclaration(attributes, modifiers);
|
|
}
|
|
TypeSyntax type = ParseReturnType();
|
|
ResetPoint state = GetResetPoint();
|
|
try
|
|
{
|
|
if (IsMisplacedModifier(modifiers, attributes, type, out result))
|
|
{
|
|
return result;
|
|
}
|
|
ExplicitInterfaceSpecifierSyntax explicitInterfaceOpt;
|
|
SyntaxToken identifierOrThisOpt;
|
|
TypeParameterListSyntax typeParameterListOpt;
|
|
do
|
|
{
|
|
if (type.Kind != SyntaxKind.RefType && IsOperatorStart(out explicitInterfaceOpt))
|
|
{
|
|
return ParseOperatorDeclaration(attributes, modifiers, type, explicitInterfaceOpt);
|
|
}
|
|
if (IsFieldDeclaration(isEvent: false, isGlobalScriptLevel: false))
|
|
{
|
|
return ParseNormalFieldDeclaration(attributes, modifiers, type, parentKind);
|
|
}
|
|
ParseMemberName(out explicitInterfaceOpt, out identifierOrThisOpt, out typeParameterListOpt, isEvent: false);
|
|
if (IsNoneOrIncompleteMember(parentKind, attributes, modifiers, type, explicitInterfaceOpt, identifierOrThisOpt, typeParameterListOpt, out result))
|
|
{
|
|
return result;
|
|
}
|
|
}
|
|
while (ReconsideredTypeAsAsyncModifier(ref modifiers, ref type, ref state, ref explicitInterfaceOpt, ref identifierOrThisOpt, ref typeParameterListOpt));
|
|
if (TryParseIndexerOrPropertyDeclaration(attributes, modifiers, type, explicitInterfaceOpt, identifierOrThisOpt, typeParameterListOpt, out result))
|
|
{
|
|
return result;
|
|
}
|
|
return ParseMethodDeclaration(attributes, modifiers, type, explicitInterfaceOpt, identifierOrThisOpt, typeParameterListOpt);
|
|
}
|
|
finally
|
|
{
|
|
Release(ref state);
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
_pool.Free(modifiers);
|
|
_termState = termState;
|
|
}
|
|
}
|
|
|
|
private static bool ReconsiderTypeAsAsyncModifier(ref SyntaxListBuilder modifiers, TypeSyntax type, SyntaxToken identifierOrThisOpt)
|
|
{
|
|
if (type.Kind != SyntaxKind.IdentifierName)
|
|
{
|
|
return false;
|
|
}
|
|
if (identifierOrThisOpt.Kind != SyntaxKind.IdentifierToken)
|
|
{
|
|
return false;
|
|
}
|
|
SyntaxToken identifier = ((IdentifierNameSyntax)type).Identifier;
|
|
SyntaxKind contextualKind = identifier.ContextualKind;
|
|
if (contextualKind != SyntaxKind.AsyncKeyword || modifiers.Any((int)contextualKind))
|
|
{
|
|
return false;
|
|
}
|
|
modifiers.Add((GreenNode)(object)SyntaxParser.ConvertToKeyword(identifier));
|
|
return true;
|
|
}
|
|
|
|
private bool IsFieldDeclaration(bool isEvent, bool isGlobalScriptLevel)
|
|
{
|
|
if (base.CurrentToken.Kind != SyntaxKind.IdentifierToken)
|
|
{
|
|
return false;
|
|
}
|
|
if (base.CurrentToken.ContextualKind == SyntaxKind.GlobalKeyword && PeekToken(1).Kind == SyntaxKind.UsingKeyword)
|
|
{
|
|
return false;
|
|
}
|
|
SyntaxKind kind = PeekToken(1).Kind;
|
|
if (!isGlobalScriptLevel && kind == SyntaxKind.SemicolonToken && IsStartOfPropertyBody(PeekToken(2).Kind))
|
|
{
|
|
return false;
|
|
}
|
|
switch (kind)
|
|
{
|
|
case SyntaxKind.OpenBraceToken:
|
|
case SyntaxKind.LessThanToken:
|
|
case SyntaxKind.DotToken:
|
|
case SyntaxKind.DotDotToken:
|
|
case SyntaxKind.ColonColonToken:
|
|
case SyntaxKind.EqualsGreaterThanToken:
|
|
return false;
|
|
case SyntaxKind.OpenParenToken:
|
|
return isEvent;
|
|
default:
|
|
return true;
|
|
}
|
|
}
|
|
|
|
private bool IsOperatorKeyword()
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
if (kind - 8382 <= (SyntaxKind)2)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public static bool IsComplete(CSharpSyntaxNode node)
|
|
{
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
|
|
if (node == null)
|
|
{
|
|
return false;
|
|
}
|
|
ChildSyntaxList val = ((GreenNode)node).ChildNodesAndTokens();
|
|
Reversed val2 = ((ChildSyntaxList)(ref val)).Reverse();
|
|
Enumerator enumerator = ((Reversed)(ref val2)).GetEnumerator();
|
|
while (((Enumerator)(ref enumerator)).MoveNext())
|
|
{
|
|
GreenNode current = ((Enumerator)(ref enumerator)).Current;
|
|
if (!(current is SyntaxToken syntaxToken))
|
|
{
|
|
return IsComplete((CSharpSyntaxNode)(object)current);
|
|
}
|
|
if (((GreenNode)syntaxToken).IsMissing)
|
|
{
|
|
return false;
|
|
}
|
|
if (syntaxToken.Kind != SyntaxKind.None)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private ConstructorDeclarationSyntax ParseConstructorDeclaration(SyntaxList<AttributeListSyntax> attributes, SyntaxListBuilder modifiers)
|
|
{
|
|
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxToken identifier = ParseIdentifierToken();
|
|
TerminatorState termState = _termState;
|
|
_termState |= TerminatorState.IsEndOfMethodSignature;
|
|
try
|
|
{
|
|
ParameterListSyntax parameterList = ParseParenthesizedParameterList();
|
|
ConstructorInitializerSyntax initializer = ((base.CurrentToken.Kind == SyntaxKind.ColonToken) ? ParseConstructorInitializer() : null);
|
|
ParseBlockAndExpressionBodiesWithSemicolon(out var blockBody, out var expressionBody, out var semicolon);
|
|
return _syntaxFactory.ConstructorDeclaration(attributes, SyntaxList<SyntaxToken>.op_Implicit(modifiers.ToList()), identifier, parameterList, initializer, blockBody, expressionBody, semicolon);
|
|
}
|
|
finally
|
|
{
|
|
_termState = termState;
|
|
}
|
|
}
|
|
|
|
private ConstructorInitializerSyntax ParseConstructorInitializer()
|
|
{
|
|
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxToken colonToken = EatToken(SyntaxKind.ColonToken);
|
|
bool reportError = true;
|
|
SyntaxKind kind = ((base.CurrentToken.Kind == SyntaxKind.BaseKeyword) ? SyntaxKind.BaseConstructorInitializer : SyntaxKind.ThisConstructorInitializer);
|
|
SyntaxKind kind2 = base.CurrentToken.Kind;
|
|
SyntaxToken thisOrBaseKeyword;
|
|
if (kind2 - 8370 <= SyntaxKind.List)
|
|
{
|
|
thisOrBaseKeyword = EatToken();
|
|
}
|
|
else
|
|
{
|
|
thisOrBaseKeyword = EatToken(SyntaxKind.ThisKeyword, ErrorCode.ERR_ThisOrBaseExpected);
|
|
reportError = false;
|
|
}
|
|
ArgumentListSyntax argumentList = ((base.CurrentToken.Kind == SyntaxKind.OpenParenToken) ? ParseParenthesizedArgumentList() : _syntaxFactory.ArgumentList(EatToken(SyntaxKind.OpenParenToken, reportError), default(SeparatedSyntaxList<ArgumentSyntax>), EatToken(SyntaxKind.CloseParenToken, reportError)));
|
|
return _syntaxFactory.ConstructorInitializer(kind, colonToken, thisOrBaseKeyword, argumentList);
|
|
}
|
|
|
|
private DestructorDeclarationSyntax ParseDestructorDeclaration(SyntaxList<AttributeListSyntax> attributes, SyntaxListBuilder modifiers)
|
|
{
|
|
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxToken tildeToken = EatToken(SyntaxKind.TildeToken);
|
|
SyntaxToken identifier = ParseIdentifierToken();
|
|
ParameterListSyntax parameterList = _syntaxFactory.ParameterList(EatToken(SyntaxKind.OpenParenToken), default(SeparatedSyntaxList<ParameterSyntax>), EatToken(SyntaxKind.CloseParenToken));
|
|
ParseBlockAndExpressionBodiesWithSemicolon(out var blockBody, out var expressionBody, out var semicolon);
|
|
return _syntaxFactory.DestructorDeclaration(attributes, SyntaxList<SyntaxToken>.op_Implicit(modifiers.ToList()), tildeToken, identifier, parameterList, blockBody, expressionBody, semicolon);
|
|
}
|
|
|
|
private void ParseBlockAndExpressionBodiesWithSemicolon(out BlockSyntax blockBody, out ArrowExpressionClauseSyntax expressionBody, out SyntaxToken semicolon, bool parseSemicolonAfterBlock = true)
|
|
{
|
|
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
|
|
if (base.CurrentToken.Kind == SyntaxKind.SemicolonToken)
|
|
{
|
|
blockBody = null;
|
|
expressionBody = null;
|
|
semicolon = EatToken(SyntaxKind.SemicolonToken);
|
|
return;
|
|
}
|
|
blockBody = ((base.CurrentToken.Kind == SyntaxKind.OpenBraceToken) ? ParseMethodOrAccessorBodyBlock(default(SyntaxList<AttributeListSyntax>), isAccessorBody: false) : null);
|
|
expressionBody = ((base.CurrentToken.Kind == SyntaxKind.EqualsGreaterThanToken) ? ParseArrowExpressionClause() : null);
|
|
if (expressionBody != null || blockBody == null)
|
|
{
|
|
semicolon = EatToken(SyntaxKind.SemicolonToken);
|
|
}
|
|
else if (parseSemicolonAfterBlock && base.CurrentToken.Kind == SyntaxKind.SemicolonToken)
|
|
{
|
|
semicolon = EatTokenWithPrejudice(ErrorCode.ERR_UnexpectedSemicolon);
|
|
}
|
|
else
|
|
{
|
|
semicolon = null;
|
|
}
|
|
}
|
|
|
|
private bool IsEndOfTypeParameterList()
|
|
{
|
|
if (base.CurrentToken.Kind == SyntaxKind.OpenParenToken)
|
|
{
|
|
return true;
|
|
}
|
|
if (base.CurrentToken.Kind == SyntaxKind.ColonToken)
|
|
{
|
|
return true;
|
|
}
|
|
if (base.CurrentToken.Kind == SyntaxKind.OpenBraceToken)
|
|
{
|
|
return true;
|
|
}
|
|
if (IsCurrentTokenWhereOfConstraintClause())
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private bool IsEndOfMethodSignature()
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
if (kind == SyntaxKind.OpenBraceToken || kind == SyntaxKind.SemicolonToken)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private bool IsEndOfRecordOrClassOrStructOrInterfaceSignature()
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
if (kind == SyntaxKind.OpenBraceToken || kind == SyntaxKind.SemicolonToken)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private bool IsEndOfNameInExplicitInterface()
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
if (kind == SyntaxKind.DotToken || kind == SyntaxKind.ColonColonToken)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private bool IsEndOfFunctionPointerParameterList(bool errored)
|
|
{
|
|
return (int)base.CurrentToken.Kind == (errored ? 8201 : 8217);
|
|
}
|
|
|
|
private bool IsEndOfFunctionPointerCallingConvention()
|
|
{
|
|
return base.CurrentToken.Kind == SyntaxKind.CloseBracketToken;
|
|
}
|
|
|
|
private MethodDeclarationSyntax ParseMethodDeclaration(SyntaxList<AttributeListSyntax> attributes, SyntaxListBuilder modifiers, TypeSyntax type, ExplicitInterfaceSpecifierSyntax explicitInterfaceOpt, SyntaxToken identifier, TypeParameterListSyntax typeParameterList)
|
|
{
|
|
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
|
|
TerminatorState termState = _termState;
|
|
_termState |= TerminatorState.IsEndOfMethodSignature;
|
|
ParameterListSyntax parameterListSyntax = ParseParenthesizedParameterList();
|
|
SyntaxListBuilder<TypeParameterConstraintClauseSyntax> val = default(SyntaxListBuilder<TypeParameterConstraintClauseSyntax>);
|
|
if (base.CurrentToken.ContextualKind == SyntaxKind.WhereKeyword)
|
|
{
|
|
val = _pool.Allocate<TypeParameterConstraintClauseSyntax>();
|
|
ParseTypeParameterConstraintClauses(SyntaxListBuilder<TypeParameterConstraintClauseSyntax>.op_Implicit(val));
|
|
}
|
|
else if (base.CurrentToken.Kind == SyntaxKind.ColonToken)
|
|
{
|
|
SyntaxToken currentToken = base.CurrentToken;
|
|
ConstructorInitializerSyntax node = ParseConstructorInitializer();
|
|
node = AddErrorToFirstToken(node, ErrorCode.ERR_UnexpectedToken, currentToken.Text);
|
|
parameterListSyntax = AddTrailingSkippedSyntax(parameterListSyntax, (GreenNode)(object)node);
|
|
}
|
|
_termState = termState;
|
|
IsInAsync = modifiers.Any(8435);
|
|
ParseBlockAndExpressionBodiesWithSemicolon(out var blockBody, out var expressionBody, out var semicolon);
|
|
IsInAsync = false;
|
|
return _syntaxFactory.MethodDeclaration(attributes, SyntaxList<SyntaxToken>.op_Implicit(modifiers.ToList()), type, explicitInterfaceOpt, identifier, typeParameterList, parameterListSyntax, _pool.ToListAndFree<TypeParameterConstraintClauseSyntax>(val), blockBody, expressionBody, semicolon);
|
|
}
|
|
|
|
private TypeSyntax ParseReturnType()
|
|
{
|
|
TerminatorState termState = _termState;
|
|
_termState |= TerminatorState.IsEndOfReturnType;
|
|
TypeSyntax result = ParseTypeOrVoid();
|
|
_termState = termState;
|
|
return result;
|
|
}
|
|
|
|
private bool IsEndOfReturnType()
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
if (kind == SyntaxKind.OpenParenToken || kind == SyntaxKind.OpenBraceToken || kind == SyntaxKind.SemicolonToken)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private ConversionOperatorDeclarationSyntax TryParseConversionOperatorDeclaration(SyntaxList<AttributeListSyntax> attributes, SyntaxListBuilder modifiers)
|
|
{
|
|
//IL_0373: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0375: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_037a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_023d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_023f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0244: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0262: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0268: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0303: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0308: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_031b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0320: Unknown result type (might be due to invalid IL or missing references)
|
|
ResetPoint state = GetResetPoint();
|
|
try
|
|
{
|
|
bool flag = false;
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
bool flag2;
|
|
if (kind - 8383 > SyntaxKind.List)
|
|
{
|
|
SyntaxKind syntaxKind = SyntaxKind.None;
|
|
if (base.CurrentToken.Kind == SyntaxKind.IdentifierToken)
|
|
{
|
|
while (base.CurrentToken.Kind != SyntaxKind.OperatorKeyword)
|
|
{
|
|
using (DisposableResetPoint disposableResetPoint = GetDisposableResetPoint(resetOnDispose: false))
|
|
{
|
|
int lastTokenPosition = -1;
|
|
IsMakingProgress(ref lastTokenPosition);
|
|
ScanNamedTypePart();
|
|
if (IsDotOrColonColonOrDotDot() || (IsMakingProgress(ref lastTokenPosition, assertIfFalse: false) && base.CurrentToken.Kind != SyntaxKind.OpenParenToken))
|
|
{
|
|
flag = true;
|
|
if (IsDotOrColonColonOrDotDot())
|
|
{
|
|
syntaxKind = base.CurrentToken.Kind;
|
|
EatToken();
|
|
}
|
|
else
|
|
{
|
|
syntaxKind = SyntaxKind.None;
|
|
}
|
|
continue;
|
|
}
|
|
disposableResetPoint.Reset();
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
flag2 = base.CurrentToken.Kind != SyntaxKind.OperatorKeyword;
|
|
if (!flag2)
|
|
{
|
|
bool flag3 = flag;
|
|
if (flag3)
|
|
{
|
|
bool flag4 = ((syntaxKind == SyntaxKind.DotToken || syntaxKind == SyntaxKind.DotDotToken) ? true : false);
|
|
flag3 = !flag4;
|
|
}
|
|
flag2 = flag3;
|
|
}
|
|
bool flag5;
|
|
if (flag2)
|
|
{
|
|
flag5 = false;
|
|
}
|
|
else
|
|
{
|
|
kind = PeekToken(1).Kind;
|
|
flag2 = kind - 8379 <= SyntaxKind.List;
|
|
flag5 = ((!flag2) ? (!SyntaxFacts.IsAnyOverloadableOperator(PeekToken(1).Kind)) : (!SyntaxFacts.IsAnyOverloadableOperator(PeekToken(2).Kind)));
|
|
}
|
|
Reset(ref state);
|
|
if (!flag5)
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
kind = base.CurrentToken.Kind;
|
|
flag2 = kind - 8383 <= SyntaxKind.List;
|
|
SyntaxToken syntaxToken = (flag2 ? EatToken() : EatToken(SyntaxKind.ExplicitKeyword));
|
|
ExplicitInterfaceSpecifierSyntax explicitInterfaceSpecifierSyntax = tryParseExplicitInterfaceSpecifier();
|
|
SyntaxToken operatorKeyword;
|
|
TypeSyntax type;
|
|
if (!((GreenNode)syntaxToken).IsMissing && explicitInterfaceSpecifierSyntax != null && base.CurrentToken.Kind != SyntaxKind.OperatorKeyword && syntaxToken.TrailingTrivia.Any(8539))
|
|
{
|
|
Reset(ref state);
|
|
syntaxToken = EatToken();
|
|
explicitInterfaceSpecifierSyntax = null;
|
|
operatorKeyword = EatToken(SyntaxKind.OperatorKeyword);
|
|
type = AddError(CreateMissingIdentifierName(), ErrorCode.ERR_IdentifierExpected);
|
|
return _syntaxFactory.ConversionOperatorDeclaration(attributes, SyntaxList<SyntaxToken>.op_Implicit(modifiers.ToList()), syntaxToken, explicitInterfaceSpecifierSyntax, operatorKeyword, null, type, _syntaxFactory.ParameterList(SyntaxFactory.MissingToken(SyntaxKind.OpenParenToken), default(SeparatedSyntaxList<ParameterSyntax>), SyntaxFactory.MissingToken(SyntaxKind.CloseParenToken)), null, null, SyntaxFactory.MissingToken(SyntaxKind.SemicolonToken));
|
|
}
|
|
operatorKeyword = EatToken(SyntaxKind.OperatorKeyword);
|
|
SyntaxToken checkedKeyword = TryEatCheckedOrHandleUnchecked(ref operatorKeyword);
|
|
Release(ref state);
|
|
state = GetResetPoint();
|
|
bool num = base.CurrentToken.Kind == SyntaxKind.OpenParenToken;
|
|
type = ParseType();
|
|
if (num && type is TupleTypeSyntax tupleTypeSyntax)
|
|
{
|
|
SeparatedSyntaxList<TupleElementSyntax> elements = tupleTypeSyntax.Elements;
|
|
if (elements.Count == 2 && elements.SeparatorCount == 1 && tupleTypeSyntax.Elements.GetSeparator(0).IsMissing && ((GreenNode)tupleTypeSyntax.Elements[1]).IsMissing && base.CurrentToken.Kind != SyntaxKind.OpenParenToken)
|
|
{
|
|
Reset(ref state);
|
|
type = ParseIdentifierName();
|
|
}
|
|
}
|
|
ParameterListSyntax parameterList = ParseParenthesizedParameterList();
|
|
ParseBlockAndExpressionBodiesWithSemicolon(out var blockBody, out var expressionBody, out var semicolon);
|
|
return _syntaxFactory.ConversionOperatorDeclaration(attributes, SyntaxList<SyntaxToken>.op_Implicit(modifiers.ToList()), syntaxToken, explicitInterfaceSpecifierSyntax, operatorKeyword, checkedKeyword, type, parameterList, blockBody, expressionBody, semicolon);
|
|
}
|
|
finally
|
|
{
|
|
Release(ref state);
|
|
}
|
|
ExplicitInterfaceSpecifierSyntax tryParseExplicitInterfaceSpecifier()
|
|
{
|
|
if (base.CurrentToken.Kind != SyntaxKind.IdentifierToken)
|
|
{
|
|
return null;
|
|
}
|
|
NameSyntax explicitInterfaceName = null;
|
|
SyntaxToken separator = null;
|
|
while (true)
|
|
{
|
|
bool flag6;
|
|
using (GetDisposableResetPoint(resetOnDispose: true))
|
|
{
|
|
if (base.CurrentToken.Kind == SyntaxKind.OperatorKeyword)
|
|
{
|
|
flag6 = false;
|
|
}
|
|
else
|
|
{
|
|
int lastTokenPosition2 = -1;
|
|
IsMakingProgress(ref lastTokenPosition2);
|
|
ScanNamedTypePart();
|
|
flag6 = IsDotOrColonColonOrDotDot() || (IsMakingProgress(ref lastTokenPosition2, assertIfFalse: false) && base.CurrentToken.Kind != SyntaxKind.OpenParenToken);
|
|
}
|
|
}
|
|
if (!flag6)
|
|
{
|
|
break;
|
|
}
|
|
AccumulateExplicitInterfaceName(ref explicitInterfaceName, ref separator);
|
|
}
|
|
if (separator != null && separator.Kind == SyntaxKind.ColonColonToken)
|
|
{
|
|
separator = AddError(separator, ErrorCode.ERR_AliasQualAsExpression);
|
|
separator = ConvertToMissingWithTrailingTrivia(separator, SyntaxKind.DotToken);
|
|
}
|
|
if (explicitInterfaceName == null)
|
|
{
|
|
return null;
|
|
}
|
|
if (separator.Kind != SyntaxKind.DotToken)
|
|
{
|
|
separator = WithAdditionalDiagnostics(separator, GetExpectedTokenError(SyntaxKind.DotToken, separator.Kind, ((GreenNode)separator).GetLeadingTriviaWidth(), ((GreenNode)separator).Width));
|
|
separator = ConvertToMissingWithTrailingTrivia(separator, SyntaxKind.DotToken);
|
|
}
|
|
return _syntaxFactory.ExplicitInterfaceSpecifier(explicitInterfaceName, separator);
|
|
}
|
|
}
|
|
|
|
private SyntaxToken TryEatCheckedOrHandleUnchecked(ref SyntaxToken operatorKeyword)
|
|
{
|
|
if (base.CurrentToken.Kind == SyntaxKind.UncheckedKeyword)
|
|
{
|
|
SyntaxToken skippedSyntax = AddError(EatToken(), ErrorCode.ERR_MisplacedUnchecked);
|
|
operatorKeyword = AddTrailingSkippedSyntax(operatorKeyword, (GreenNode)(object)skippedSyntax);
|
|
return null;
|
|
}
|
|
return TryEatToken(SyntaxKind.CheckedKeyword);
|
|
}
|
|
|
|
private OperatorDeclarationSyntax ParseOperatorDeclaration(SyntaxList<AttributeListSyntax> attributes, SyntaxListBuilder modifiers, TypeSyntax type, ExplicitInterfaceSpecifierSyntax explicitInterfaceOpt)
|
|
{
|
|
//IL_019c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxToken operatorKeyword = EatToken(SyntaxKind.OperatorKeyword);
|
|
SyntaxToken checkedKeyword = TryEatCheckedOrHandleUnchecked(ref operatorKeyword);
|
|
SyntaxToken syntaxToken;
|
|
int offset;
|
|
int width;
|
|
if (SyntaxFacts.IsAnyOverloadableOperator(base.CurrentToken.Kind))
|
|
{
|
|
syntaxToken = EatToken();
|
|
offset = ((GreenNode)syntaxToken).GetLeadingTriviaWidth();
|
|
width = ((GreenNode)syntaxToken).Width;
|
|
}
|
|
else
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
if (kind - 8383 <= SyntaxKind.List)
|
|
{
|
|
GetDiagnosticSpanForMissingToken(out offset, out width);
|
|
syntaxToken = ConvertToMissingWithTrailingTrivia(EatToken(), SyntaxKind.PlusToken);
|
|
if (((GreenNode)type).IsMissing)
|
|
{
|
|
SyntaxDiagnosticInfo syntaxDiagnosticInfo = SyntaxParser.MakeError(offset, width, ErrorCode.ERR_BadOperatorSyntax, SyntaxFacts.GetText(SyntaxKind.PlusToken));
|
|
syntaxToken = WithAdditionalDiagnostics(syntaxToken, syntaxDiagnosticInfo);
|
|
}
|
|
else
|
|
{
|
|
type = AddError(type, ErrorCode.ERR_BadOperatorSyntax, SyntaxFacts.GetText(SyntaxKind.PlusToken));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
syntaxToken = EatToken();
|
|
offset = ((GreenNode)syntaxToken).GetLeadingTriviaWidth();
|
|
width = ((GreenNode)syntaxToken).Width;
|
|
}
|
|
}
|
|
SyntaxKind kind2 = syntaxToken.Kind;
|
|
SyntaxToken currentToken = base.CurrentToken;
|
|
if (syntaxToken.Kind == SyntaxKind.GreaterThanToken && currentToken.Kind == SyntaxKind.GreaterThanToken && NoTriviaBetween(syntaxToken, currentToken))
|
|
{
|
|
SyntaxToken syntaxToken2 = EatToken();
|
|
currentToken = base.CurrentToken;
|
|
if (currentToken.Kind == SyntaxKind.GreaterThanToken && NoTriviaBetween(syntaxToken2, currentToken))
|
|
{
|
|
syntaxToken2 = EatToken();
|
|
syntaxToken = SyntaxFactory.Token(syntaxToken.GetLeadingTrivia(), SyntaxKind.GreaterThanGreaterThanGreaterThanToken, syntaxToken2.GetTrailingTrivia());
|
|
}
|
|
else
|
|
{
|
|
syntaxToken = SyntaxFactory.Token(syntaxToken.GetLeadingTrivia(), SyntaxKind.GreaterThanGreaterThanToken, syntaxToken2.GetTrailingTrivia());
|
|
}
|
|
}
|
|
ParameterListSyntax parameterListSyntax = ParseParenthesizedParameterList();
|
|
switch (parameterListSyntax.Parameters.Count)
|
|
{
|
|
case 1:
|
|
if (((GreenNode)syntaxToken).IsMissing || !SyntaxFacts.IsOverloadableUnaryOperator(kind2))
|
|
{
|
|
SyntaxDiagnosticInfo syntaxDiagnosticInfo4 = SyntaxParser.MakeError(offset, width, ErrorCode.ERR_OvlUnaryOperatorExpected);
|
|
syntaxToken = WithAdditionalDiagnostics(syntaxToken, syntaxDiagnosticInfo4);
|
|
}
|
|
break;
|
|
case 2:
|
|
if (((GreenNode)syntaxToken).IsMissing || !SyntaxFacts.IsOverloadableBinaryOperator(kind2))
|
|
{
|
|
SyntaxDiagnosticInfo syntaxDiagnosticInfo3 = SyntaxParser.MakeError(offset, width, ErrorCode.ERR_OvlBinaryOperatorExpected);
|
|
syntaxToken = WithAdditionalDiagnostics(syntaxToken, syntaxDiagnosticInfo3);
|
|
}
|
|
break;
|
|
default:
|
|
if (((GreenNode)syntaxToken).IsMissing)
|
|
{
|
|
SyntaxDiagnosticInfo syntaxDiagnosticInfo2 = SyntaxParser.MakeError(offset, width, ErrorCode.ERR_OvlOperatorExpected);
|
|
syntaxToken = WithAdditionalDiagnostics(syntaxToken, syntaxDiagnosticInfo2);
|
|
}
|
|
else
|
|
{
|
|
syntaxToken = ((!SyntaxFacts.IsOverloadableBinaryOperator(kind2)) ? ((!SyntaxFacts.IsOverloadableUnaryOperator(kind2)) ? AddError(syntaxToken, ErrorCode.ERR_OvlOperatorExpected) : AddError(syntaxToken, ErrorCode.ERR_BadUnOpArgs, SyntaxFacts.GetText(kind2))) : AddError(syntaxToken, ErrorCode.ERR_BadBinOpArgs, SyntaxFacts.GetText(kind2)));
|
|
}
|
|
break;
|
|
}
|
|
ParseBlockAndExpressionBodiesWithSemicolon(out var blockBody, out var expressionBody, out var semicolon);
|
|
if (kind2 != SyntaxKind.IsKeyword && !SyntaxFacts.IsOverloadableUnaryOperator(kind2) && !SyntaxFacts.IsOverloadableBinaryOperator(kind2))
|
|
{
|
|
syntaxToken = ConvertToMissingWithTrailingTrivia(syntaxToken, SyntaxKind.PlusToken);
|
|
}
|
|
return _syntaxFactory.OperatorDeclaration(attributes, SyntaxList<SyntaxToken>.op_Implicit(modifiers.ToList()), type, explicitInterfaceOpt, operatorKeyword, checkedKeyword, syntaxToken, parameterListSyntax, blockBody, expressionBody, semicolon);
|
|
}
|
|
|
|
private IndexerDeclarationSyntax ParseIndexerDeclaration(SyntaxList<AttributeListSyntax> attributes, SyntaxListBuilder modifiers, TypeSyntax type, ExplicitInterfaceSpecifierSyntax explicitInterfaceOpt, SyntaxToken thisKeyword, TypeParameterListSyntax typeParameterList)
|
|
{
|
|
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
|
|
if (typeParameterList != null)
|
|
{
|
|
thisKeyword = AddTrailingSkippedSyntax(thisKeyword, (GreenNode)(object)typeParameterList);
|
|
thisKeyword = AddError(thisKeyword, ErrorCode.ERR_UnexpectedGenericName);
|
|
}
|
|
BracketedParameterListSyntax parameterList = ParseBracketedParameterList();
|
|
AccessorListSyntax accessorList = null;
|
|
ArrowExpressionClauseSyntax expressionBody = null;
|
|
SyntaxToken syntaxToken = null;
|
|
if (base.CurrentToken.Kind == SyntaxKind.EqualsGreaterThanToken)
|
|
{
|
|
expressionBody = ParseArrowExpressionClause();
|
|
syntaxToken = EatToken(SyntaxKind.SemicolonToken);
|
|
}
|
|
else
|
|
{
|
|
accessorList = ParseAccessorList(isEvent: false);
|
|
if (base.CurrentToken.Kind == SyntaxKind.SemicolonToken)
|
|
{
|
|
syntaxToken = EatTokenWithPrejudice(ErrorCode.ERR_UnexpectedSemicolon);
|
|
}
|
|
}
|
|
if (base.CurrentToken.Kind == SyntaxKind.EqualsGreaterThanToken && syntaxToken == null)
|
|
{
|
|
expressionBody = ParseArrowExpressionClause();
|
|
syntaxToken = EatToken(SyntaxKind.SemicolonToken);
|
|
}
|
|
return _syntaxFactory.IndexerDeclaration(attributes, SyntaxList<SyntaxToken>.op_Implicit(modifiers.ToList()), type, explicitInterfaceOpt, thisKeyword, parameterList, accessorList, expressionBody, syntaxToken);
|
|
}
|
|
|
|
private PropertyDeclarationSyntax ParsePropertyDeclaration(SyntaxList<AttributeListSyntax> attributes, SyntaxListBuilder modifiers, TypeSyntax type, ExplicitInterfaceSpecifierSyntax explicitInterfaceOpt, SyntaxToken identifier, TypeParameterListSyntax typeParameterList)
|
|
{
|
|
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
|
|
if (typeParameterList != null)
|
|
{
|
|
identifier = AddTrailingSkippedSyntax(identifier, (GreenNode)(object)typeParameterList);
|
|
identifier = AddError(identifier, ErrorCode.ERR_UnexpectedGenericName);
|
|
}
|
|
if (base.CurrentToken.Kind == SyntaxKind.SemicolonToken)
|
|
{
|
|
identifier = AddTrailingSkippedSyntax(identifier, (GreenNode)(object)EatTokenWithPrejudice(SyntaxKind.OpenBraceToken));
|
|
}
|
|
AccessorListSyntax accessorList = ((base.CurrentToken.Kind == SyntaxKind.OpenBraceToken) ? ParseAccessorList(isEvent: false) : null);
|
|
ArrowExpressionClauseSyntax arrowExpressionClauseSyntax = null;
|
|
EqualsValueClauseSyntax equalsValueClauseSyntax = null;
|
|
if (base.CurrentToken.Kind == SyntaxKind.EqualsGreaterThanToken)
|
|
{
|
|
arrowExpressionClauseSyntax = ParseArrowExpressionClause();
|
|
}
|
|
else if (base.CurrentToken.Kind == SyntaxKind.EqualsToken)
|
|
{
|
|
SyntaxToken equalsToken = EatToken(SyntaxKind.EqualsToken);
|
|
ExpressionSyntax value = ParseVariableInitializer();
|
|
equalsValueClauseSyntax = _syntaxFactory.EqualsValueClause(equalsToken, value);
|
|
}
|
|
SyntaxToken semicolonToken = null;
|
|
if (arrowExpressionClauseSyntax != null || equalsValueClauseSyntax != null)
|
|
{
|
|
semicolonToken = EatToken(SyntaxKind.SemicolonToken);
|
|
}
|
|
else if (base.CurrentToken.Kind == SyntaxKind.SemicolonToken)
|
|
{
|
|
semicolonToken = EatTokenWithPrejudice(ErrorCode.ERR_UnexpectedSemicolon);
|
|
}
|
|
return _syntaxFactory.PropertyDeclaration(attributes, SyntaxList<SyntaxToken>.op_Implicit(modifiers.ToList()), type, explicitInterfaceOpt, identifier, accessorList, arrowExpressionClauseSyntax, equalsValueClauseSyntax, semicolonToken);
|
|
}
|
|
|
|
private AccessorListSyntax ParseAccessorList(bool isEvent)
|
|
{
|
|
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxToken openBrace = EatToken(SyntaxKind.OpenBraceToken);
|
|
SyntaxList<AccessorDeclarationSyntax> accessors = default(SyntaxList<AccessorDeclarationSyntax>);
|
|
if (!((GreenNode)openBrace).IsMissing || !IsTerminator())
|
|
{
|
|
SyntaxListBuilder<AccessorDeclarationSyntax> val = _pool.Allocate<AccessorDeclarationSyntax>();
|
|
while (base.CurrentToken.Kind != SyntaxKind.CloseBraceToken)
|
|
{
|
|
if (IsPossibleAccessor())
|
|
{
|
|
AccessorDeclarationSyntax accessorDeclarationSyntax = ParseAccessorDeclaration(isEvent);
|
|
val.Add(accessorDeclarationSyntax);
|
|
}
|
|
else if (SkipBadAccessorListTokens(ref openBrace, val, isEvent ? ErrorCode.ERR_AddOrRemoveExpected : ErrorCode.ERR_GetOrSetExpected) == PostSkipAction.Abort)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
accessors = _pool.ToListAndFree<AccessorDeclarationSyntax>(val);
|
|
}
|
|
return _syntaxFactory.AccessorList(openBrace, accessors, EatToken(SyntaxKind.CloseBraceToken));
|
|
}
|
|
|
|
private ArrowExpressionClauseSyntax ParseArrowExpressionClause()
|
|
{
|
|
return _syntaxFactory.ArrowExpressionClause(EatToken(SyntaxKind.EqualsGreaterThanToken), ParsePossibleRefExpression());
|
|
}
|
|
|
|
private ExpressionSyntax ParsePossibleRefExpression()
|
|
{
|
|
SyntaxToken syntaxToken = ((base.CurrentToken.Kind == SyntaxKind.RefKeyword && !IsPossibleLambdaExpression(Precedence.Expression)) ? EatToken() : null);
|
|
ExpressionSyntax expressionSyntax = ParseExpressionCore();
|
|
if (syntaxToken != null)
|
|
{
|
|
return _syntaxFactory.RefExpression(syntaxToken, expressionSyntax);
|
|
}
|
|
return expressionSyntax;
|
|
}
|
|
|
|
private PostSkipAction SkipBadAccessorListTokens(ref SyntaxToken openBrace, SyntaxListBuilder<AccessorDeclarationSyntax> list, ErrorCode error)
|
|
{
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
|
return SkipBadListTokensWithErrorCode<SyntaxToken, AccessorDeclarationSyntax>(ref openBrace, list, (LanguageParser p) => p.CurrentToken.Kind != SyntaxKind.CloseBraceToken && !p.IsPossibleAccessor(), (LanguageParser p) => p.IsTerminator(), error);
|
|
}
|
|
|
|
private bool IsPossibleAccessor()
|
|
{
|
|
if (base.CurrentToken.Kind != SyntaxKind.IdentifierToken && !IsPossibleAttributeDeclaration() && SyntaxFacts.GetAccessorDeclarationKind(base.CurrentToken.ContextualKind) == SyntaxKind.None && base.CurrentToken.Kind != SyntaxKind.OpenBraceToken && base.CurrentToken.Kind != SyntaxKind.SemicolonToken)
|
|
{
|
|
return IsPossibleAccessorModifier();
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private bool IsPossibleAccessorModifier()
|
|
{
|
|
if (GetModifierExcludingScoped(base.CurrentToken) == DeclarationModifiers.None)
|
|
{
|
|
return false;
|
|
}
|
|
int i;
|
|
for (i = 1; GetModifierExcludingScoped(PeekToken(i)) != DeclarationModifiers.None; i++)
|
|
{
|
|
}
|
|
SyntaxToken syntaxToken = PeekToken(i);
|
|
SyntaxKind kind = syntaxToken.Kind;
|
|
if ((kind == SyntaxKind.CloseBraceToken || kind == SyntaxKind.EndOfFileToken) ? true : false)
|
|
{
|
|
return true;
|
|
}
|
|
kind = syntaxToken.ContextualKind;
|
|
if (kind - 8417 <= (SyntaxKind)3 || kind == SyntaxKind.InitKeyword)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private PostSkipAction SkipBadSeparatedListTokensWithExpectedKind<T, TNode>(ref T startToken, SeparatedSyntaxListBuilder<TNode> list, Func<LanguageParser, bool> isNotExpectedFunction, Func<LanguageParser, SyntaxKind, bool> abortFunction, SyntaxKind expected, SyntaxKind closeKind = SyntaxKind.None) where T : CSharpSyntaxNode where TNode : CSharpSyntaxNode
|
|
{
|
|
GreenNode trailingTrivia;
|
|
PostSkipAction result = SkipBadListTokensWithExpectedKindHelper(list.UnderlyingBuilder, isNotExpectedFunction, abortFunction, expected, closeKind, out trailingTrivia);
|
|
if (trailingTrivia != null)
|
|
{
|
|
startToken = AddTrailingSkippedSyntax(startToken, trailingTrivia);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
private PostSkipAction SkipBadListTokensWithErrorCode<T, TNode>(ref T startToken, SyntaxListBuilder<TNode> list, Func<LanguageParser, bool> isNotExpectedFunction, Func<LanguageParser, bool> abortFunction, ErrorCode error) where T : CSharpSyntaxNode where TNode : CSharpSyntaxNode
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
GreenNode trailingTrivia;
|
|
PostSkipAction result = SkipBadListTokensWithErrorCodeHelper<TNode>(list, isNotExpectedFunction, abortFunction, error, out trailingTrivia);
|
|
if (trailingTrivia != null)
|
|
{
|
|
startToken = AddTrailingSkippedSyntax(startToken, trailingTrivia);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
private PostSkipAction SkipBadListTokensWithExpectedKindHelper(SyntaxListBuilder list, Func<LanguageParser, bool> isNotExpectedFunction, Func<LanguageParser, SyntaxKind, bool> abortFunction, SyntaxKind expected, SyntaxKind closeKind, out GreenNode trailingTrivia)
|
|
{
|
|
if (list.Count == 0)
|
|
{
|
|
return SkipBadTokensWithExpectedKind(isNotExpectedFunction, abortFunction, expected, closeKind, out trailingTrivia);
|
|
}
|
|
GreenNode trailingTrivia2;
|
|
PostSkipAction result = SkipBadTokensWithExpectedKind(isNotExpectedFunction, abortFunction, expected, closeKind, out trailingTrivia2);
|
|
if (trailingTrivia2 != null)
|
|
{
|
|
AddTrailingSkippedSyntax(list, trailingTrivia2);
|
|
}
|
|
trailingTrivia = null;
|
|
return result;
|
|
}
|
|
|
|
private PostSkipAction SkipBadListTokensWithErrorCodeHelper<TNode>(SyntaxListBuilder<TNode> list, Func<LanguageParser, bool> isNotExpectedFunction, Func<LanguageParser, bool> abortFunction, ErrorCode error, out GreenNode trailingTrivia) where TNode : CSharpSyntaxNode
|
|
{
|
|
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
|
|
if (list.Count == 0)
|
|
{
|
|
return SkipBadTokensWithErrorCode(isNotExpectedFunction, abortFunction, error, out trailingTrivia);
|
|
}
|
|
GreenNode trailingTrivia2;
|
|
PostSkipAction result = SkipBadTokensWithErrorCode(isNotExpectedFunction, abortFunction, error, out trailingTrivia2);
|
|
if (trailingTrivia2 != null)
|
|
{
|
|
AddTrailingSkippedSyntax<TNode>(list, trailingTrivia2);
|
|
}
|
|
trailingTrivia = null;
|
|
return result;
|
|
}
|
|
|
|
private PostSkipAction SkipBadTokensWithExpectedKind(Func<LanguageParser, bool> isNotExpectedFunction, Func<LanguageParser, SyntaxKind, bool> abortFunction, SyntaxKind expected, SyntaxKind closeKind, out GreenNode trailingTrivia)
|
|
{
|
|
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxListBuilder val = _pool.Allocate();
|
|
bool flag = true;
|
|
PostSkipAction result = PostSkipAction.Continue;
|
|
while (isNotExpectedFunction(this))
|
|
{
|
|
if (abortFunction(this, closeKind) || IsTerminator())
|
|
{
|
|
result = PostSkipAction.Abort;
|
|
break;
|
|
}
|
|
SyntaxToken syntaxToken = ((flag && !((GreenNode)base.CurrentToken).ContainsDiagnostics) ? EatTokenWithPrejudice(expected) : EatToken());
|
|
flag = false;
|
|
val.Add((GreenNode)(object)syntaxToken);
|
|
}
|
|
trailingTrivia = _pool.ToTokenListAndFree(val).Node;
|
|
return result;
|
|
}
|
|
|
|
private PostSkipAction SkipBadTokensWithErrorCode(Func<LanguageParser, bool> isNotExpectedFunction, Func<LanguageParser, bool> abortFunction, ErrorCode errorCode, out GreenNode trailingTrivia)
|
|
{
|
|
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxListBuilder val = _pool.Allocate();
|
|
bool flag = true;
|
|
PostSkipAction result = PostSkipAction.Continue;
|
|
while (isNotExpectedFunction(this))
|
|
{
|
|
if (abortFunction(this))
|
|
{
|
|
result = PostSkipAction.Abort;
|
|
break;
|
|
}
|
|
SyntaxToken syntaxToken = ((flag && !((GreenNode)base.CurrentToken).ContainsDiagnostics) ? EatTokenWithPrejudice(errorCode) : EatToken());
|
|
flag = false;
|
|
val.Add((GreenNode)(object)syntaxToken);
|
|
}
|
|
trailingTrivia = _pool.ToTokenListAndFree(val).Node;
|
|
return result;
|
|
}
|
|
|
|
private AccessorDeclarationSyntax ParseAccessorDeclaration(bool isEvent)
|
|
{
|
|
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
|
|
if (IsIncrementalAndFactoryContextMatches && SyntaxFacts.IsAccessorDeclaration(base.CurrentNodeKind))
|
|
{
|
|
return (AccessorDeclarationSyntax)(object)EatNode();
|
|
}
|
|
SyntaxListBuilder val = _pool.Allocate();
|
|
SyntaxList<AttributeListSyntax> attributeLists = ParseAttributeDeclarations(inExpressionContext: false);
|
|
ParseModifiers(val, forAccessors: true, forTopLevelStatements: false, out var _);
|
|
SyntaxToken syntaxToken = EatToken(SyntaxKind.IdentifierToken, isEvent ? ErrorCode.ERR_AddOrRemoveExpected : ErrorCode.ERR_GetOrSetExpected);
|
|
SyntaxKind accessorKind = GetAccessorKind(syntaxToken);
|
|
if (accessorKind == SyntaxKind.UnknownAccessorDeclaration)
|
|
{
|
|
if (!((GreenNode)syntaxToken).IsMissing)
|
|
{
|
|
syntaxToken = AddError(syntaxToken, isEvent ? ErrorCode.ERR_AddOrRemoveExpected : ErrorCode.ERR_GetOrSetExpected);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
syntaxToken = SyntaxParser.ConvertToKeyword(syntaxToken);
|
|
}
|
|
BlockSyntax blockBody = null;
|
|
ArrowExpressionClauseSyntax expressionBody = null;
|
|
SyntaxToken semicolon = null;
|
|
bool flag = base.CurrentToken.Kind == SyntaxKind.SemicolonToken;
|
|
bool flag2 = base.CurrentToken.Kind == SyntaxKind.EqualsGreaterThanToken;
|
|
if (base.CurrentToken.Kind == SyntaxKind.OpenBraceToken || flag2)
|
|
{
|
|
ParseBlockAndExpressionBodiesWithSemicolon(out blockBody, out expressionBody, out semicolon);
|
|
}
|
|
else if (flag)
|
|
{
|
|
semicolon = EatAccessorSemicolon();
|
|
}
|
|
else if (accessorKind != SyntaxKind.UnknownAccessorDeclaration)
|
|
{
|
|
if (!IsTerminator())
|
|
{
|
|
blockBody = ParseMethodOrAccessorBodyBlock(default(SyntaxList<AttributeListSyntax>), isAccessorBody: true);
|
|
}
|
|
else
|
|
{
|
|
semicolon = EatAccessorSemicolon();
|
|
}
|
|
}
|
|
return _syntaxFactory.AccessorDeclaration(accessorKind, attributeLists, _pool.ToTokenListAndFree(val), syntaxToken, blockBody, expressionBody, semicolon);
|
|
}
|
|
|
|
private SyntaxToken EatAccessorSemicolon()
|
|
{
|
|
return EatToken(SyntaxKind.SemicolonToken, IsFeatureEnabled(MessageID.IDS_FeatureExpressionBodiedAccessor) ? ErrorCode.ERR_SemiOrLBraceOrArrowExpected : ErrorCode.ERR_SemiOrLBraceExpected);
|
|
}
|
|
|
|
private static SyntaxKind GetAccessorKind(SyntaxToken accessorName)
|
|
{
|
|
return accessorName.ContextualKind switch
|
|
{
|
|
SyntaxKind.GetKeyword => SyntaxKind.GetAccessorDeclaration,
|
|
SyntaxKind.SetKeyword => SyntaxKind.SetAccessorDeclaration,
|
|
SyntaxKind.InitKeyword => SyntaxKind.InitAccessorDeclaration,
|
|
SyntaxKind.AddKeyword => SyntaxKind.AddAccessorDeclaration,
|
|
SyntaxKind.RemoveKeyword => SyntaxKind.RemoveAccessorDeclaration,
|
|
_ => SyntaxKind.UnknownAccessorDeclaration,
|
|
};
|
|
}
|
|
|
|
internal ParameterListSyntax ParseParenthesizedParameterList()
|
|
{
|
|
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
|
|
if (IsIncrementalAndFactoryContextMatches && CanReuseParameterList(base.CurrentNode as Microsoft.CodeAnalysis.CSharp.Syntax.ParameterListSyntax))
|
|
{
|
|
return (ParameterListSyntax)(object)EatNode();
|
|
}
|
|
SyntaxToken open;
|
|
SyntaxToken close;
|
|
SeparatedSyntaxList<ParameterSyntax> parameters = ParseParameterList(out open, out close, SyntaxKind.OpenParenToken, SyntaxKind.CloseParenToken);
|
|
return _syntaxFactory.ParameterList(open, parameters, close);
|
|
}
|
|
|
|
internal BracketedParameterListSyntax ParseBracketedParameterList()
|
|
{
|
|
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
|
|
if (IsIncrementalAndFactoryContextMatches && CanReuseBracketedParameterList(base.CurrentNode as Microsoft.CodeAnalysis.CSharp.Syntax.BracketedParameterListSyntax))
|
|
{
|
|
return (BracketedParameterListSyntax)(object)EatNode();
|
|
}
|
|
SyntaxToken open;
|
|
SyntaxToken close;
|
|
SeparatedSyntaxList<ParameterSyntax> parameters = ParseParameterList(out open, out close, SyntaxKind.OpenBracketToken, SyntaxKind.CloseBracketToken);
|
|
return _syntaxFactory.BracketedParameterList(open, parameters, close);
|
|
}
|
|
|
|
private static bool CanReuseParameterList(Microsoft.CodeAnalysis.CSharp.Syntax.ParameterListSyntax list)
|
|
{
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
|
|
if (list == null)
|
|
{
|
|
return false;
|
|
}
|
|
SyntaxToken val = list.OpenParenToken;
|
|
if (((SyntaxToken)(ref val)).IsMissing)
|
|
{
|
|
return false;
|
|
}
|
|
val = list.CloseParenToken;
|
|
if (((SyntaxToken)(ref val)).IsMissing)
|
|
{
|
|
return false;
|
|
}
|
|
Enumerator<Microsoft.CodeAnalysis.CSharp.Syntax.ParameterSyntax> enumerator = list.Parameters.GetEnumerator();
|
|
while (enumerator.MoveNext())
|
|
{
|
|
if (!CanReuseParameter(enumerator.Current))
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private static bool CanReuseBracketedParameterList(Microsoft.CodeAnalysis.CSharp.Syntax.BracketedParameterListSyntax list)
|
|
{
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
|
|
if (list == null)
|
|
{
|
|
return false;
|
|
}
|
|
SyntaxToken val = list.OpenBracketToken;
|
|
if (((SyntaxToken)(ref val)).IsMissing)
|
|
{
|
|
return false;
|
|
}
|
|
val = list.CloseBracketToken;
|
|
if (((SyntaxToken)(ref val)).IsMissing)
|
|
{
|
|
return false;
|
|
}
|
|
Enumerator<Microsoft.CodeAnalysis.CSharp.Syntax.ParameterSyntax> enumerator = list.Parameters.GetEnumerator();
|
|
while (enumerator.MoveNext())
|
|
{
|
|
if (!CanReuseParameter(enumerator.Current))
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private SeparatedSyntaxList<ParameterSyntax> ParseParameterList(out SyntaxToken open, out SyntaxToken close, SyntaxKind openKind, SyntaxKind closeKind)
|
|
{
|
|
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
|
|
open = EatToken(openKind);
|
|
TerminatorState termState = _termState;
|
|
_termState |= TerminatorState.IsEndOfParameterList;
|
|
SeparatedSyntaxList<ParameterSyntax> result = ParseCommaSeparatedSyntaxList(ref open, closeKind, (LanguageParser @this) => @this.IsPossibleParameter(), (LanguageParser @this) => @this.ParseParameter(), skipBadParameterListTokens, allowTrailingSeparator: false, requireOneElement: false, allowSemicolonAsSeparator: false);
|
|
_termState = termState;
|
|
close = EatToken(closeKind);
|
|
return result;
|
|
static PostSkipAction skipBadParameterListTokens(LanguageParser @this, ref SyntaxToken startToken, SeparatedSyntaxListBuilder<ParameterSyntax> list, SyntaxKind expectedKind, SyntaxKind closeKind2)
|
|
{
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
|
return @this.SkipBadSeparatedListTokensWithExpectedKind<SyntaxToken, ParameterSyntax>(ref startToken, list, (LanguageParser p) => p.CurrentToken.Kind != SyntaxKind.CommaToken && !p.IsPossibleParameter(), (LanguageParser p, SyntaxKind syntaxKind) => p.CurrentToken.Kind == syntaxKind, expectedKind, closeKind2);
|
|
}
|
|
}
|
|
|
|
private bool IsEndOfParameterList()
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
if (kind == SyntaxKind.CloseParenToken || kind == SyntaxKind.CloseBracketToken || kind == SyntaxKind.SemicolonToken)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private bool IsPossibleParameter()
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
if (kind <= SyntaxKind.OpenBracketToken)
|
|
{
|
|
if (kind == SyntaxKind.OpenParenToken || kind == SyntaxKind.OpenBracketToken)
|
|
{
|
|
goto IL_0048;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (kind == SyntaxKind.ArgListKeyword)
|
|
{
|
|
goto IL_0048;
|
|
}
|
|
if (kind != SyntaxKind.DelegateKeyword)
|
|
{
|
|
if (kind == SyntaxKind.IdentifierToken)
|
|
{
|
|
return IsTrueIdentifier();
|
|
}
|
|
}
|
|
else if (IsFunctionPointerStart())
|
|
{
|
|
goto IL_0048;
|
|
}
|
|
}
|
|
if (!IsParameterModifierExcludingScoped(base.CurrentToken) && !IsPossibleScopedKeyword(isFunctionPointerParameter: false))
|
|
{
|
|
return IsPredefinedType(base.CurrentToken.Kind);
|
|
}
|
|
return true;
|
|
IL_0048:
|
|
return true;
|
|
}
|
|
|
|
private static bool CanReuseParameter(Microsoft.CodeAnalysis.CSharp.Syntax.ParameterSyntax parameter)
|
|
{
|
|
if (parameter == null)
|
|
{
|
|
return false;
|
|
}
|
|
if (parameter.Default != null)
|
|
{
|
|
return false;
|
|
}
|
|
Microsoft.CodeAnalysis.CSharp.CSharpSyntaxNode parent = parameter.Parent;
|
|
if (parent != null)
|
|
{
|
|
if (parent.Kind() == SyntaxKind.SimpleLambdaExpression)
|
|
{
|
|
return false;
|
|
}
|
|
Microsoft.CodeAnalysis.CSharp.CSharpSyntaxNode parent2 = parent.Parent;
|
|
if (parent2 != null && parent2.Kind() == SyntaxKind.ParenthesizedLambdaExpression)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private ParameterSyntax ParseParameter()
|
|
{
|
|
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
|
|
if (IsIncrementalAndFactoryContextMatches && CanReuseParameter(base.CurrentNode as Microsoft.CodeAnalysis.CSharp.Syntax.ParameterSyntax))
|
|
{
|
|
return (ParameterSyntax)(object)EatNode();
|
|
}
|
|
SyntaxList<AttributeListSyntax> attributeLists = ParseAttributeDeclarations(inExpressionContext: false);
|
|
SyntaxListBuilder val = _pool.Allocate();
|
|
ParseParameterModifiers(val, isFunctionPointerParameter: false);
|
|
if (base.CurrentToken.Kind == SyntaxKind.ArgListKeyword)
|
|
{
|
|
return _syntaxFactory.Parameter(attributeLists, SyntaxList<SyntaxToken>.op_Implicit(val.ToList()), null, EatToken(SyntaxKind.ArgListKeyword), null);
|
|
}
|
|
TypeSyntax type = ParseType(ParseTypeMode.Parameter);
|
|
SyntaxToken identifier = ((base.CurrentToken.Kind != SyntaxKind.IdentifierToken || !IsCurrentTokenWhereOfConstraintClause()) ? ParseIdentifierToken() : AddError(CreateMissingIdentifierToken(), ErrorCode.ERR_IdentifierExpected));
|
|
if (base.CurrentToken.Kind == SyntaxKind.OpenBracketToken && PeekToken(1).Kind == SyntaxKind.CloseBracketToken)
|
|
{
|
|
identifier = AddTrailingSkippedSyntax(identifier, (GreenNode)(object)SyntaxList.List((GreenNode)(object)AddError(EatToken(), ErrorCode.ERR_BadArraySyntax), (GreenNode)(object)EatToken()));
|
|
}
|
|
ParseParameterNullCheck(ref identifier, out SyntaxToken equalsToken);
|
|
if (equalsToken == null)
|
|
{
|
|
equalsToken = TryEatToken(SyntaxKind.EqualsToken);
|
|
}
|
|
return _syntaxFactory.Parameter(attributeLists, _pool.ToTokenListAndFree(val), type, identifier, (equalsToken == null) ? null : _syntaxFactory.EqualsValueClause(equalsToken, ParseExpressionCore()));
|
|
}
|
|
|
|
private void ParseParameterNullCheck(ref SyntaxToken identifier, out SyntaxToken? equalsToken)
|
|
{
|
|
equalsToken = null;
|
|
if (base.CurrentToken.Kind == SyntaxKind.ExclamationEqualsToken)
|
|
{
|
|
SyntaxToken syntaxToken = EatToken();
|
|
identifier = AddTrailingSkippedSyntax(identifier, (GreenNode)(object)AddError(SyntaxFactory.Token(syntaxToken.GetLeadingTrivia(), SyntaxKind.ExclamationToken, "!", "!", null), ErrorCode.ERR_ParameterNullCheckingNotSupported));
|
|
equalsToken = SyntaxFactory.Token(null, SyntaxKind.EqualsToken, syntaxToken.GetTrailingTrivia());
|
|
}
|
|
else if (base.CurrentToken.Kind == SyntaxKind.ExclamationToken)
|
|
{
|
|
identifier = AddTrailingSkippedSyntax(identifier, (GreenNode)(object)AddError(EatToken(), ErrorCode.ERR_ParameterNullCheckingNotSupported));
|
|
if (base.CurrentToken.Kind == SyntaxKind.ExclamationToken)
|
|
{
|
|
identifier = AddTrailingSkippedSyntax(identifier, (GreenNode)(object)EatToken());
|
|
}
|
|
else if (base.CurrentToken.Kind == SyntaxKind.ExclamationEqualsToken)
|
|
{
|
|
SyntaxToken syntaxToken2 = EatToken();
|
|
identifier = AddTrailingSkippedSyntax(identifier, (GreenNode)(object)SyntaxFactory.Token(syntaxToken2.GetLeadingTrivia(), SyntaxKind.ExclamationToken, null));
|
|
equalsToken = SyntaxFactory.Token(null, SyntaxKind.EqualsToken, syntaxToken2.GetTrailingTrivia());
|
|
}
|
|
}
|
|
}
|
|
|
|
private SyntaxToken? MergeAdjacent(SyntaxToken t1, SyntaxToken t2, SyntaxKind kind)
|
|
{
|
|
if (NoTriviaBetween(t1, t2))
|
|
{
|
|
return SyntaxFactory.Token(t1.GetLeadingTrivia(), kind, t2.GetTrailingTrivia());
|
|
}
|
|
PooledStringBuilder instance = PooledStringBuilder.GetInstance();
|
|
StringWriter stringWriter = new StringWriter(instance.Builder, CultureInfo.InvariantCulture);
|
|
((GreenNode)t1).WriteTo((TextWriter)stringWriter, false, true);
|
|
((GreenNode)t2).WriteTo((TextWriter)stringWriter, true, false);
|
|
string text = instance.ToStringAndFree();
|
|
return WithAdditionalDiagnostics(SyntaxFactory.Token(t1.GetLeadingTrivia(), kind, text, text, t2.GetTrailingTrivia()), GetExpectedTokenError(kind, t1.Kind));
|
|
}
|
|
|
|
internal static bool NoTriviaBetween(SyntaxToken token1, SyntaxToken token2)
|
|
{
|
|
if (((GreenNode)token1).GetTrailingTriviaWidth() == 0)
|
|
{
|
|
return ((GreenNode)token2).GetLeadingTriviaWidth() == 0;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private static bool IsParameterModifierExcludingScoped(SyntaxToken token)
|
|
{
|
|
switch (token.Kind)
|
|
{
|
|
case SyntaxKind.ReadOnlyKeyword:
|
|
case SyntaxKind.RefKeyword:
|
|
case SyntaxKind.OutKeyword:
|
|
case SyntaxKind.InKeyword:
|
|
case SyntaxKind.ParamsKeyword:
|
|
case SyntaxKind.ThisKeyword:
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
|
|
private void ParseParameterModifiers(SyntaxListBuilder modifiers, bool isFunctionPointerParameter)
|
|
{
|
|
bool flag = true;
|
|
while (IsParameterModifierExcludingScoped(base.CurrentToken))
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
if ((kind == SyntaxKind.ReadOnlyKeyword || kind - 8360 <= (SyntaxKind)2) ? true : false)
|
|
{
|
|
flag = false;
|
|
}
|
|
modifiers.Add((GreenNode)(object)EatToken());
|
|
}
|
|
if (!flag)
|
|
{
|
|
return;
|
|
}
|
|
SyntaxToken syntaxToken = ParsePossibleScopedKeyword(isFunctionPointerParameter);
|
|
if (syntaxToken == null)
|
|
{
|
|
return;
|
|
}
|
|
modifiers.Add((GreenNode)(object)syntaxToken);
|
|
while (true)
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
if ((kind == SyntaxKind.ReadOnlyKeyword || kind - 8360 <= (SyntaxKind)2) ? true : false)
|
|
{
|
|
modifiers.Add((GreenNode)(object)EatToken());
|
|
continue;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
private FieldDeclarationSyntax ParseFixedSizeBufferDeclaration(SyntaxList<AttributeListSyntax> attributes, SyntaxListBuilder modifiers, SyntaxKind parentKind)
|
|
{
|
|
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
|
|
modifiers.Add((GreenNode)(object)EatToken());
|
|
TypeSyntax type = ParseType();
|
|
return _syntaxFactory.FieldDeclaration(attributes, SyntaxList<SyntaxToken>.op_Implicit(modifiers.ToList()), _syntaxFactory.VariableDeclaration(type, ParseFieldDeclarationVariableDeclarators(type, VariableFlags.Fixed, parentKind)), EatToken(SyntaxKind.SemicolonToken));
|
|
}
|
|
|
|
private MemberDeclarationSyntax ParseEventDeclaration(SyntaxList<AttributeListSyntax> attributes, SyntaxListBuilder modifiers, SyntaxKind parentKind)
|
|
{
|
|
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxToken eventToken = EatToken();
|
|
TypeSyntax type = ParseType();
|
|
if (!IsFieldDeclaration(isEvent: true, parentKind == SyntaxKind.CompilationUnit))
|
|
{
|
|
return ParseEventDeclarationWithAccessors(attributes, modifiers, eventToken, type);
|
|
}
|
|
return ParseEventFieldDeclaration(attributes, modifiers, eventToken, type, parentKind);
|
|
}
|
|
|
|
private EventDeclarationSyntax ParseEventDeclarationWithAccessors(SyntaxList<AttributeListSyntax> attributes, SyntaxListBuilder modifiers, SyntaxToken eventToken, TypeSyntax type)
|
|
{
|
|
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
|
|
ParseMemberName(out var explicitInterfaceOpt, out var identifierOrThisOpt, out var typeParameterListOpt, isEvent: true);
|
|
if (explicitInterfaceOpt != null)
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
if (kind != SyntaxKind.OpenBraceToken && kind != SyntaxKind.SemicolonToken)
|
|
{
|
|
return _syntaxFactory.EventDeclaration(attributes, SyntaxList<SyntaxToken>.op_Implicit(modifiers.ToList()), eventToken, type, explicitInterfaceOpt, (identifierOrThisOpt == null) ? CreateMissingIdentifierToken() : identifierOrThisOpt, _syntaxFactory.AccessorList(SyntaxFactory.MissingToken(SyntaxKind.OpenBraceToken), default(SyntaxList<AccessorDeclarationSyntax>), SyntaxFactory.MissingToken(SyntaxKind.CloseBraceToken)), null);
|
|
}
|
|
}
|
|
SyntaxToken syntaxToken = ((identifierOrThisOpt == null) ? CreateMissingIdentifierToken() : ((identifierOrThisOpt.Kind == SyntaxKind.IdentifierToken) ? identifierOrThisOpt : ConvertToMissingWithTrailingTrivia(identifierOrThisOpt, SyntaxKind.IdentifierToken)));
|
|
if (((GreenNode)syntaxToken).IsMissing && !((GreenNode)type).IsMissing)
|
|
{
|
|
syntaxToken = AddError(syntaxToken, ErrorCode.ERR_IdentifierExpected);
|
|
}
|
|
if (typeParameterListOpt != null)
|
|
{
|
|
syntaxToken = AddTrailingSkippedSyntax(syntaxToken, (GreenNode)(object)typeParameterListOpt);
|
|
syntaxToken = AddError(syntaxToken, ErrorCode.ERR_UnexpectedGenericName);
|
|
}
|
|
AccessorListSyntax accessorList = null;
|
|
SyntaxToken semicolonToken = null;
|
|
if (explicitInterfaceOpt != null && base.CurrentToken.Kind == SyntaxKind.SemicolonToken)
|
|
{
|
|
semicolonToken = EatToken(SyntaxKind.SemicolonToken);
|
|
}
|
|
else
|
|
{
|
|
accessorList = ParseAccessorList(isEvent: true);
|
|
}
|
|
EventDeclarationSyntax decl = _syntaxFactory.EventDeclaration(attributes, SyntaxList<SyntaxToken>.op_Implicit(modifiers.ToList()), eventToken, type, explicitInterfaceOpt, syntaxToken, accessorList, semicolonToken);
|
|
return EatUnexpectedTrailingSemicolon(decl);
|
|
}
|
|
|
|
private TNode EatUnexpectedTrailingSemicolon<TNode>(TNode decl) where TNode : CSharpSyntaxNode
|
|
{
|
|
if (base.CurrentToken.Kind == SyntaxKind.SemicolonToken)
|
|
{
|
|
SyntaxToken node = EatToken();
|
|
node = AddError(node, ErrorCode.ERR_UnexpectedSemicolon);
|
|
decl = AddTrailingSkippedSyntax(decl, (GreenNode)(object)node);
|
|
}
|
|
return decl;
|
|
}
|
|
|
|
private FieldDeclarationSyntax ParseNormalFieldDeclaration(SyntaxList<AttributeListSyntax> attributes, SyntaxListBuilder modifiers, TypeSyntax type, SyntaxKind parentKind)
|
|
{
|
|
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
|
|
SeparatedSyntaxList<VariableDeclaratorSyntax> variables = ParseFieldDeclarationVariableDeclarators(type, VariableFlags.LocalOrField, parentKind);
|
|
if (modifiers != null)
|
|
{
|
|
int count = modifiers.Count;
|
|
if (count >= 1 && modifiers[count - 1] is SyntaxToken { Kind: SyntaxKind.ScopedKeyword } syntaxToken)
|
|
{
|
|
type = _syntaxFactory.ScopedType(syntaxToken, type);
|
|
modifiers.RemoveLast();
|
|
}
|
|
}
|
|
return _syntaxFactory.FieldDeclaration(attributes, SyntaxList<SyntaxToken>.op_Implicit(modifiers.ToList()), _syntaxFactory.VariableDeclaration(type, variables), EatToken(SyntaxKind.SemicolonToken));
|
|
}
|
|
|
|
private EventFieldDeclarationSyntax ParseEventFieldDeclaration(SyntaxList<AttributeListSyntax> attributes, SyntaxListBuilder modifiers, SyntaxToken eventToken, TypeSyntax type, SyntaxKind parentKind)
|
|
{
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
|
|
SeparatedSyntaxList<VariableDeclaratorSyntax> variables = ParseFieldDeclarationVariableDeclarators(type, (VariableFlags)0, parentKind);
|
|
if (base.CurrentToken.Kind == SyntaxKind.DotToken)
|
|
{
|
|
eventToken = AddError(eventToken, ErrorCode.ERR_ExplicitEventFieldImpl);
|
|
}
|
|
return _syntaxFactory.EventFieldDeclaration(attributes, SyntaxList<SyntaxToken>.op_Implicit(modifiers.ToList()), eventToken, _syntaxFactory.VariableDeclaration(type, variables), EatToken(SyntaxKind.SemicolonToken));
|
|
}
|
|
|
|
private bool IsEndOfFieldDeclaration()
|
|
{
|
|
return base.CurrentToken.Kind == SyntaxKind.SemicolonToken;
|
|
}
|
|
|
|
private SeparatedSyntaxList<VariableDeclaratorSyntax> ParseFieldDeclarationVariableDeclarators(TypeSyntax type, VariableFlags flags, SyntaxKind parentKind)
|
|
{
|
|
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
|
|
int num;
|
|
switch (parentKind)
|
|
{
|
|
case SyntaxKind.CompilationUnit:
|
|
num = (base.IsScript ? 1 : 0);
|
|
break;
|
|
default:
|
|
num = 1;
|
|
break;
|
|
case SyntaxKind.NamespaceDeclaration:
|
|
case SyntaxKind.FileScopedNamespaceDeclaration:
|
|
num = 0;
|
|
break;
|
|
}
|
|
bool variableDeclarationsExpected = (byte)num != 0;
|
|
SeparatedSyntaxListBuilder<VariableDeclaratorSyntax> variables = _pool.AllocateSeparated<VariableDeclaratorSyntax>();
|
|
TerminatorState termState = _termState;
|
|
_termState |= TerminatorState.IsEndOfFieldDeclaration;
|
|
ParseVariableDeclarators(type, flags, variables, variableDeclarationsExpected, allowLocalFunctions: false, stopOnCloseParen: false, default(SyntaxList<AttributeListSyntax>), default(SyntaxList<SyntaxToken>), out var _);
|
|
_termState = termState;
|
|
return _pool.ToListAndFree<VariableDeclaratorSyntax>(ref variables);
|
|
}
|
|
|
|
private void ParseVariableDeclarators(TypeSyntax type, VariableFlags flags, SeparatedSyntaxListBuilder<VariableDeclaratorSyntax> variables, bool variableDeclarationsExpected, bool allowLocalFunctions, bool stopOnCloseParen, SyntaxList<AttributeListSyntax> attributes, SyntaxList<SyntaxToken> mods, out LocalFunctionStatementSyntax localFunction)
|
|
{
|
|
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
|
|
variables.Add(ParseVariableDeclarator(type, flags, isFirst: true, allowLocalFunctions, attributes, mods, out localFunction));
|
|
if (localFunction != null)
|
|
{
|
|
return;
|
|
}
|
|
while (base.CurrentToken.Kind != SyntaxKind.SemicolonToken && (!stopOnCloseParen || base.CurrentToken.Kind != SyntaxKind.CloseParenToken))
|
|
{
|
|
if (base.CurrentToken.Kind == SyntaxKind.CommaToken)
|
|
{
|
|
variables.AddSeparator((GreenNode)(object)EatToken(SyntaxKind.CommaToken));
|
|
variables.Add(ParseVariableDeclarator(type, flags, isFirst: false, allowLocalFunctions: false, attributes, mods, out localFunction));
|
|
}
|
|
else if (!variableDeclarationsExpected || SkipBadVariableListTokens(variables, SyntaxKind.CommaToken) == PostSkipAction.Abort)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
private PostSkipAction SkipBadVariableListTokens(SeparatedSyntaxListBuilder<VariableDeclaratorSyntax> list, SyntaxKind expected)
|
|
{
|
|
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
|
|
CSharpSyntaxNode startToken = null;
|
|
return SkipBadSeparatedListTokensWithExpectedKind<CSharpSyntaxNode, VariableDeclaratorSyntax>(ref startToken, list, (LanguageParser p) => p.CurrentToken.Kind != SyntaxKind.CommaToken, (LanguageParser p, SyntaxKind _) => p.CurrentToken.Kind == SyntaxKind.SemicolonToken, expected);
|
|
}
|
|
|
|
private static SyntaxTokenList GetOriginalModifiers(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxNode decl)
|
|
{
|
|
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
|
|
if (decl != null)
|
|
{
|
|
switch (decl.Kind())
|
|
{
|
|
case SyntaxKind.FieldDeclaration:
|
|
return ((Microsoft.CodeAnalysis.CSharp.Syntax.FieldDeclarationSyntax)decl).Modifiers;
|
|
case SyntaxKind.MethodDeclaration:
|
|
return ((Microsoft.CodeAnalysis.CSharp.Syntax.MethodDeclarationSyntax)decl).Modifiers;
|
|
case SyntaxKind.ConstructorDeclaration:
|
|
return ((Microsoft.CodeAnalysis.CSharp.Syntax.ConstructorDeclarationSyntax)decl).Modifiers;
|
|
case SyntaxKind.DestructorDeclaration:
|
|
return ((Microsoft.CodeAnalysis.CSharp.Syntax.DestructorDeclarationSyntax)decl).Modifiers;
|
|
case SyntaxKind.PropertyDeclaration:
|
|
return ((Microsoft.CodeAnalysis.CSharp.Syntax.PropertyDeclarationSyntax)decl).Modifiers;
|
|
case SyntaxKind.EventFieldDeclaration:
|
|
return ((Microsoft.CodeAnalysis.CSharp.Syntax.EventFieldDeclarationSyntax)decl).Modifiers;
|
|
case SyntaxKind.GetAccessorDeclaration:
|
|
case SyntaxKind.SetAccessorDeclaration:
|
|
case SyntaxKind.AddAccessorDeclaration:
|
|
case SyntaxKind.RemoveAccessorDeclaration:
|
|
case SyntaxKind.InitAccessorDeclaration:
|
|
return ((Microsoft.CodeAnalysis.CSharp.Syntax.AccessorDeclarationSyntax)decl).Modifiers;
|
|
case SyntaxKind.ClassDeclaration:
|
|
case SyntaxKind.StructDeclaration:
|
|
case SyntaxKind.InterfaceDeclaration:
|
|
case SyntaxKind.RecordDeclaration:
|
|
case SyntaxKind.RecordStructDeclaration:
|
|
return ((Microsoft.CodeAnalysis.CSharp.Syntax.TypeDeclarationSyntax)decl).Modifiers;
|
|
case SyntaxKind.DelegateDeclaration:
|
|
return ((Microsoft.CodeAnalysis.CSharp.Syntax.DelegateDeclarationSyntax)decl).Modifiers;
|
|
}
|
|
}
|
|
return default(SyntaxTokenList);
|
|
}
|
|
|
|
private static bool WasFirstVariable(Microsoft.CodeAnalysis.CSharp.Syntax.VariableDeclaratorSyntax variable)
|
|
{
|
|
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
|
|
if (GetOldParent(variable) is Microsoft.CodeAnalysis.CSharp.Syntax.VariableDeclarationSyntax variableDeclarationSyntax)
|
|
{
|
|
return variableDeclarationSyntax.Variables[0] == variable;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private static VariableFlags GetOriginalVariableFlags(Microsoft.CodeAnalysis.CSharp.Syntax.VariableDeclaratorSyntax old)
|
|
{
|
|
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
|
|
Microsoft.CodeAnalysis.CSharp.CSharpSyntaxNode oldParent = GetOldParent(old);
|
|
SyntaxTokenList originalModifiers = GetOriginalModifiers(oldParent);
|
|
VariableFlags variableFlags = (VariableFlags)0;
|
|
if (originalModifiers.Any(SyntaxKind.FixedKeyword))
|
|
{
|
|
variableFlags |= VariableFlags.Fixed;
|
|
}
|
|
if (originalModifiers.Any(SyntaxKind.ConstKeyword))
|
|
{
|
|
variableFlags |= VariableFlags.Const;
|
|
}
|
|
if (oldParent != null && (oldParent.Kind() == SyntaxKind.VariableDeclaration || oldParent.Kind() == SyntaxKind.LocalDeclarationStatement))
|
|
{
|
|
variableFlags |= VariableFlags.LocalOrField;
|
|
}
|
|
return variableFlags;
|
|
}
|
|
|
|
private static bool CanReuseVariableDeclarator(Microsoft.CodeAnalysis.CSharp.Syntax.VariableDeclaratorSyntax old, VariableFlags flags, bool isFirst)
|
|
{
|
|
if (old == null)
|
|
{
|
|
return false;
|
|
}
|
|
SyntaxKind syntaxKind;
|
|
if (flags == GetOriginalVariableFlags(old) && isFirst == WasFirstVariable(old) && old.Initializer == null && (syntaxKind = GetOldParent(old).Kind()) != SyntaxKind.VariableDeclaration)
|
|
{
|
|
return syntaxKind != SyntaxKind.LocalDeclarationStatement;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private VariableDeclaratorSyntax ParseVariableDeclarator(TypeSyntax parentType, VariableFlags flags, bool isFirst, bool allowLocalFunctions, SyntaxList<AttributeListSyntax> attributes, SyntaxList<SyntaxToken> mods, out LocalFunctionStatementSyntax localFunction, bool isExpressionContext = false)
|
|
{
|
|
//IL_02de: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0309: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_030e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0312: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0317: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_031b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0320: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_026f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0271: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0250: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0252: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0372: Unknown result type (might be due to invalid IL or missing references)
|
|
if (IsIncrementalAndFactoryContextMatches && CanReuseVariableDeclarator(base.CurrentNode as Microsoft.CodeAnalysis.CSharp.Syntax.VariableDeclaratorSyntax, flags, isFirst))
|
|
{
|
|
localFunction = null;
|
|
return (VariableDeclaratorSyntax)(object)EatNode();
|
|
}
|
|
if (!isExpressionContext)
|
|
{
|
|
using (GetDisposableResetPoint(resetOnDispose: true))
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
if (kind == SyntaxKind.IdentifierToken && !((GreenNode)parentType).IsMissing && parentType.GetLastToken().TrailingTrivia.Any(8539))
|
|
{
|
|
GetDiagnosticSpanForMissingToken(out var offset, out var width);
|
|
EatToken();
|
|
kind = base.CurrentToken.Kind;
|
|
bool flag = kind != SyntaxKind.EqualsToken && SyntaxFacts.IsBinaryExpressionOperatorToken(kind);
|
|
bool flag2 = ((kind == SyntaxKind.OpenParenToken || kind == SyntaxKind.DotToken || kind == SyntaxKind.MinusGreaterThanToken) ? true : false);
|
|
if (flag2 || flag)
|
|
{
|
|
flag2 = ((kind == SyntaxKind.OpenParenToken || kind == SyntaxKind.LessThanToken) ? true : false);
|
|
if (!flag2 || !IsLocalFunctionAfterIdentifier())
|
|
{
|
|
SyntaxToken node = CreateMissingIdentifierToken();
|
|
node = AddError(node, offset, width, ErrorCode.ERR_IdentifierExpected);
|
|
localFunction = null;
|
|
return _syntaxFactory.VariableDeclarator(node, null, null);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
SyntaxToken syntaxToken = ParseIdentifierToken();
|
|
BracketedArgumentListSyntax bracketedArgumentListSyntax = null;
|
|
EqualsValueClauseSyntax initializer = null;
|
|
TerminatorState termState = _termState;
|
|
bool flag3 = (flags & VariableFlags.Fixed) != 0;
|
|
bool flag4 = (flags & VariableFlags.Const) != 0;
|
|
bool flag5 = (flags & VariableFlags.LocalOrField) != 0;
|
|
if (!isFirst && IsTrueIdentifier())
|
|
{
|
|
syntaxToken = AddError(syntaxToken, ErrorCode.ERR_MultiTypeInDeclaration);
|
|
}
|
|
SyntaxKind kind2 = base.CurrentToken.Kind;
|
|
if (kind2 <= SyntaxKind.EqualsToken)
|
|
{
|
|
if (kind2 == SyntaxKind.OpenParenToken)
|
|
{
|
|
if (allowLocalFunctions && isFirst)
|
|
{
|
|
localFunction = TryParseLocalFunctionStatementBody(attributes, mods, parentType, syntaxToken);
|
|
if (localFunction != null)
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
_termState |= TerminatorState.IsPossibleEndOfVariableDeclaration;
|
|
bracketedArgumentListSyntax = ParseBracketedArgumentList();
|
|
_termState = termState;
|
|
bracketedArgumentListSyntax = AddError(bracketedArgumentListSyntax, ErrorCode.ERR_BadVarDecl);
|
|
goto IL_040a;
|
|
}
|
|
if (kind2 == SyntaxKind.EqualsToken)
|
|
{
|
|
goto IL_01d5;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (kind2 == SyntaxKind.OpenBracketToken)
|
|
{
|
|
goto IL_02b4;
|
|
}
|
|
if (kind2 == SyntaxKind.LessThanToken && allowLocalFunctions && isFirst)
|
|
{
|
|
localFunction = TryParseLocalFunctionStatementBody(attributes, mods, parentType, syntaxToken);
|
|
if (localFunction != null)
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
goto IL_03d6;
|
|
IL_01d5:
|
|
if (flag3)
|
|
{
|
|
goto IL_03d6;
|
|
}
|
|
SyntaxToken equalsToken = EatToken();
|
|
SyntaxToken syntaxToken2 = ((flag5 && !flag4 && base.CurrentToken.Kind == SyntaxKind.RefKeyword && !IsPossibleLambdaExpression(Precedence.Expression)) ? EatToken() : null);
|
|
ExpressionSyntax expressionSyntax = ParseVariableInitializer();
|
|
initializer = _syntaxFactory.EqualsValueClause(equalsToken, (syntaxToken2 == null) ? expressionSyntax : _syntaxFactory.RefExpression(syntaxToken2, expressionSyntax));
|
|
goto IL_040a;
|
|
IL_02b4:
|
|
_termState |= TerminatorState.IsPossibleEndOfVariableDeclaration;
|
|
bool sawNonOmittedSize;
|
|
ArrayRankSpecifierSyntax arrayRankSpecifierSyntax = ParseArrayRankSpecifier(out sawNonOmittedSize);
|
|
_termState = termState;
|
|
SyntaxToken openBracketToken = arrayRankSpecifierSyntax.OpenBracketToken;
|
|
SeparatedSyntaxList<ExpressionSyntax> sizes = arrayRankSpecifierSyntax.Sizes;
|
|
SyntaxToken syntaxToken3 = arrayRankSpecifierSyntax.CloseBracketToken;
|
|
if (flag3 && !sawNonOmittedSize)
|
|
{
|
|
syntaxToken3 = AddError(syntaxToken3, ErrorCode.ERR_ValueExpected);
|
|
}
|
|
SeparatedSyntaxListBuilder<ArgumentSyntax> val = _pool.AllocateSeparated<ArgumentSyntax>();
|
|
Enumerator<GreenNode> enumerator = sizes.GetWithSeparators().GetEnumerator();
|
|
while (enumerator.MoveNext())
|
|
{
|
|
GreenNode current = enumerator.Current;
|
|
ExpressionSyntax expressionSyntax2 = current as ExpressionSyntax;
|
|
if (expressionSyntax2 != null)
|
|
{
|
|
bool flag6 = expressionSyntax2.Kind == SyntaxKind.OmittedArraySizeExpression;
|
|
if (!flag3 && !flag6)
|
|
{
|
|
expressionSyntax2 = AddError(expressionSyntax2, ErrorCode.ERR_ArraySizeInDeclaration);
|
|
}
|
|
val.Add(_syntaxFactory.Argument(null, null, expressionSyntax2));
|
|
}
|
|
else
|
|
{
|
|
val.AddSeparator((GreenNode)(object)(SyntaxToken)(object)current);
|
|
}
|
|
}
|
|
bracketedArgumentListSyntax = _syntaxFactory.BracketedArgumentList(openBracketToken, _pool.ToListAndFree<ArgumentSyntax>(ref val), syntaxToken3);
|
|
if (!flag3)
|
|
{
|
|
bracketedArgumentListSyntax = AddError(bracketedArgumentListSyntax, ErrorCode.ERR_CStyleArray);
|
|
if (base.CurrentToken.Kind == SyntaxKind.EqualsToken)
|
|
{
|
|
goto IL_01d5;
|
|
}
|
|
}
|
|
goto IL_040a;
|
|
IL_040a:
|
|
localFunction = null;
|
|
return _syntaxFactory.VariableDeclarator(syntaxToken, bracketedArgumentListSyntax, initializer);
|
|
IL_03d6:
|
|
if (flag4)
|
|
{
|
|
syntaxToken = AddError(syntaxToken, ErrorCode.ERR_ConstValueRequired);
|
|
}
|
|
else if (flag3)
|
|
{
|
|
if (parentType.Kind != SyntaxKind.ArrayType)
|
|
{
|
|
goto IL_02b4;
|
|
}
|
|
syntaxToken = AddError(syntaxToken, ErrorCode.ERR_FixedDimsRequired);
|
|
}
|
|
goto IL_040a;
|
|
}
|
|
|
|
private bool IsLocalFunctionAfterIdentifier()
|
|
{
|
|
bool flag;
|
|
using (GetDisposableResetPoint(resetOnDispose: true))
|
|
{
|
|
ParseTypeParameterList();
|
|
flag = !((GreenNode)ParseParenthesizedParameterList()).IsMissing;
|
|
if (flag)
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
bool flag2 = ((kind == SyntaxKind.OpenBraceToken || kind == SyntaxKind.EqualsGreaterThanToken) ? true : false);
|
|
flag = flag2 || base.CurrentToken.ContextualKind == SyntaxKind.WhereKeyword;
|
|
}
|
|
flag = (flag ? true : false);
|
|
}
|
|
return flag;
|
|
}
|
|
|
|
private bool IsPossibleEndOfVariableDeclaration()
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
if (kind == SyntaxKind.SemicolonToken || kind == SyntaxKind.CommaToken)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private ExpressionSyntax ParseVariableInitializer()
|
|
{
|
|
if (base.CurrentToken.Kind != SyntaxKind.OpenBraceToken)
|
|
{
|
|
return ParseExpressionCore();
|
|
}
|
|
return ParseArrayInitializer();
|
|
}
|
|
|
|
private bool IsPossibleVariableInitializer()
|
|
{
|
|
if (base.CurrentToken.Kind != SyntaxKind.OpenBraceToken)
|
|
{
|
|
return IsPossibleExpression();
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private FieldDeclarationSyntax ParseConstantFieldDeclaration(SyntaxList<AttributeListSyntax> attributes, SyntaxListBuilder modifiers, SyntaxKind parentKind)
|
|
{
|
|
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
|
|
modifiers.Add((GreenNode)(object)EatToken(SyntaxKind.ConstKeyword));
|
|
TypeSyntax type = ParseType();
|
|
return _syntaxFactory.FieldDeclaration(attributes, SyntaxList<SyntaxToken>.op_Implicit(modifiers.ToList()), _syntaxFactory.VariableDeclaration(type, ParseFieldDeclarationVariableDeclarators(type, VariableFlags.Const, parentKind)), EatToken(SyntaxKind.SemicolonToken));
|
|
}
|
|
|
|
private DelegateDeclarationSyntax ParseDelegateDeclaration(SyntaxList<AttributeListSyntax> attributes, SyntaxListBuilder modifiers)
|
|
{
|
|
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxToken delegateKeyword = EatToken(SyntaxKind.DelegateKeyword);
|
|
TypeSyntax returnType = ParseReturnType();
|
|
TerminatorState termState = _termState;
|
|
_termState |= TerminatorState.IsEndOfMethodSignature;
|
|
SyntaxToken identifier = ParseIdentifierToken();
|
|
TypeParameterListSyntax typeParameterList = ParseTypeParameterList();
|
|
ParameterListSyntax parameterList = ParseParenthesizedParameterList();
|
|
SyntaxListBuilder<TypeParameterConstraintClauseSyntax> val = default(SyntaxListBuilder<TypeParameterConstraintClauseSyntax>);
|
|
if (base.CurrentToken.ContextualKind == SyntaxKind.WhereKeyword)
|
|
{
|
|
val = _pool.Allocate<TypeParameterConstraintClauseSyntax>();
|
|
ParseTypeParameterConstraintClauses(SyntaxListBuilder<TypeParameterConstraintClauseSyntax>.op_Implicit(val));
|
|
}
|
|
_termState = termState;
|
|
return _syntaxFactory.DelegateDeclaration(attributes, SyntaxList<SyntaxToken>.op_Implicit(modifiers.ToList()), delegateKeyword, returnType, identifier, typeParameterList, parameterList, _pool.ToListAndFree<TypeParameterConstraintClauseSyntax>(val), EatToken(SyntaxKind.SemicolonToken));
|
|
}
|
|
|
|
private EnumDeclarationSyntax ParseEnumDeclaration(SyntaxList<AttributeListSyntax> attributes, SyntaxListBuilder modifiers)
|
|
{
|
|
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0179: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxToken enumKeyword = EatToken(SyntaxKind.EnumKeyword);
|
|
SyntaxToken syntaxToken = ParseIdentifierToken();
|
|
TypeParameterListSyntax typeParameterListSyntax = ParseTypeParameterList();
|
|
if (typeParameterListSyntax != null)
|
|
{
|
|
syntaxToken = AddTrailingSkippedSyntax(syntaxToken, (GreenNode)(object)typeParameterListSyntax);
|
|
syntaxToken = AddError(syntaxToken, ErrorCode.ERR_UnexpectedGenericName);
|
|
}
|
|
BaseListSyntax baseList = null;
|
|
if (base.CurrentToken.Kind == SyntaxKind.ColonToken)
|
|
{
|
|
SyntaxToken colonToken = EatToken(SyntaxKind.ColonToken);
|
|
TypeSyntax type = ParseType();
|
|
SeparatedSyntaxListBuilder<BaseTypeSyntax> val = _pool.AllocateSeparated<BaseTypeSyntax>();
|
|
val.Add((BaseTypeSyntax)_syntaxFactory.SimpleBaseType(type));
|
|
baseList = _syntaxFactory.BaseList(colonToken, _pool.ToListAndFree<BaseTypeSyntax>(ref val));
|
|
}
|
|
SeparatedSyntaxList<EnumMemberDeclarationSyntax> members = default(SeparatedSyntaxList<EnumMemberDeclarationSyntax>);
|
|
SyntaxToken semicolonToken;
|
|
SyntaxToken openToken;
|
|
SyntaxToken closeBraceToken;
|
|
if (base.CurrentToken.Kind == SyntaxKind.SemicolonToken)
|
|
{
|
|
semicolonToken = EatToken(SyntaxKind.SemicolonToken);
|
|
openToken = null;
|
|
closeBraceToken = null;
|
|
}
|
|
else
|
|
{
|
|
openToken = EatToken(SyntaxKind.OpenBraceToken);
|
|
if (!((GreenNode)openToken).IsMissing)
|
|
{
|
|
members = ParseCommaSeparatedSyntaxList(ref openToken, SyntaxKind.CloseBraceToken, (LanguageParser @this) => @this.IsPossibleEnumMemberDeclaration(), (LanguageParser @this) => @this.ParseEnumMemberDeclaration(), skipBadEnumMemberListTokens, allowTrailingSeparator: true, requireOneElement: false, allowSemicolonAsSeparator: true);
|
|
}
|
|
closeBraceToken = EatToken(SyntaxKind.CloseBraceToken);
|
|
semicolonToken = TryEatToken(SyntaxKind.SemicolonToken);
|
|
}
|
|
return _syntaxFactory.EnumDeclaration(attributes, SyntaxList<SyntaxToken>.op_Implicit(modifiers.ToList()), enumKeyword, syntaxToken, baseList, openToken, members, closeBraceToken, semicolonToken);
|
|
static PostSkipAction skipBadEnumMemberListTokens(LanguageParser @this, ref SyntaxToken openBrace, SeparatedSyntaxListBuilder<EnumMemberDeclarationSyntax> list, SyntaxKind expectedKind, SyntaxKind closeKind)
|
|
{
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
|
return @this.SkipBadSeparatedListTokensWithExpectedKind<SyntaxToken, EnumMemberDeclarationSyntax>(ref openBrace, list, delegate(LanguageParser p)
|
|
{
|
|
SyntaxKind kind = p.CurrentToken.Kind;
|
|
return kind != SyntaxKind.CommaToken && kind != SyntaxKind.SemicolonToken && !p.IsPossibleEnumMemberDeclaration();
|
|
}, (LanguageParser p, SyntaxKind syntaxKind) => p.CurrentToken.Kind == syntaxKind, expectedKind, closeKind);
|
|
}
|
|
}
|
|
|
|
private EnumMemberDeclarationSyntax ParseEnumMemberDeclaration()
|
|
{
|
|
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
|
|
if (IsIncrementalAndFactoryContextMatches && base.CurrentNodeKind == SyntaxKind.EnumMemberDeclaration)
|
|
{
|
|
return (EnumMemberDeclarationSyntax)(object)EatNode();
|
|
}
|
|
SyntaxList<AttributeListSyntax> attributeLists = ParseAttributeDeclarations(inExpressionContext: false);
|
|
SyntaxToken identifier = ParseIdentifierToken();
|
|
EqualsValueClauseSyntax equalsValue = null;
|
|
if (base.CurrentToken.Kind == SyntaxKind.EqualsToken)
|
|
{
|
|
ContextAwareSyntax syntaxFactory = _syntaxFactory;
|
|
SyntaxToken equalsToken = EatToken(SyntaxKind.EqualsToken);
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
bool flag = ((kind == SyntaxKind.CloseBraceToken || kind == SyntaxKind.CommaToken) ? true : false);
|
|
equalsValue = syntaxFactory.EqualsValueClause(equalsToken, flag ? ParseIdentifierName(ErrorCode.ERR_ConstantExpected) : ParseExpressionCore());
|
|
}
|
|
return _syntaxFactory.EnumMemberDeclaration(attributeLists, default(SyntaxList<SyntaxToken>), identifier, equalsValue);
|
|
}
|
|
|
|
private bool IsPossibleEnumMemberDeclaration()
|
|
{
|
|
if (base.CurrentToken.Kind != SyntaxKind.OpenBracketToken)
|
|
{
|
|
return IsTrueIdentifier();
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private bool IsDotOrColonColon()
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
if (kind == SyntaxKind.DotToken || kind == SyntaxKind.ColonColonToken)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public NameSyntax ParseName()
|
|
{
|
|
return ParseQualifiedName();
|
|
}
|
|
|
|
private IdentifierNameSyntax CreateMissingIdentifierName()
|
|
{
|
|
return _syntaxFactory.IdentifierName(CreateMissingIdentifierToken());
|
|
}
|
|
|
|
private static SyntaxToken CreateMissingIdentifierToken()
|
|
{
|
|
return SyntaxFactory.MissingToken(SyntaxKind.IdentifierToken);
|
|
}
|
|
|
|
private bool IsTrueIdentifier()
|
|
{
|
|
if (base.CurrentToken.Kind == SyntaxKind.IdentifierToken && !IsCurrentTokenPartialKeywordOfPartialMethodOrType() && !IsCurrentTokenQueryKeywordInQuery() && !IsCurrentTokenWhereOfConstraintClause())
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private bool IsTrueIdentifier(SyntaxToken token)
|
|
{
|
|
if (token.Kind == SyntaxKind.IdentifierToken)
|
|
{
|
|
if (IsInQuery)
|
|
{
|
|
return !IsTokenQueryContextualKeyword(token);
|
|
}
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private IdentifierNameSyntax ParseIdentifierName(ErrorCode code = ErrorCode.ERR_IdentifierExpected)
|
|
{
|
|
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
|
|
if (IsIncrementalAndFactoryContextMatches && base.CurrentNodeKind == SyntaxKind.IdentifierName && !SyntaxFacts.IsContextualKeyword(((Microsoft.CodeAnalysis.CSharp.Syntax.IdentifierNameSyntax)base.CurrentNode).Identifier.Kind()))
|
|
{
|
|
return (IdentifierNameSyntax)(object)EatNode();
|
|
}
|
|
return SyntaxFactory.IdentifierName(ParseIdentifierToken(code));
|
|
}
|
|
|
|
private SyntaxToken ParseIdentifierToken(ErrorCode code = ErrorCode.ERR_IdentifierExpected)
|
|
{
|
|
if (base.CurrentToken.Kind == SyntaxKind.IdentifierToken)
|
|
{
|
|
if (IsCurrentTokenPartialKeywordOfPartialMethodOrType() || IsCurrentTokenQueryKeywordInQuery())
|
|
{
|
|
SyntaxToken node = CreateMissingIdentifierToken();
|
|
return AddError(node, ErrorCode.ERR_InvalidExprTerm, base.CurrentToken.Text);
|
|
}
|
|
SyntaxToken syntaxToken = EatToken();
|
|
if (IsInAsync && syntaxToken.ContextualKind == SyntaxKind.AwaitKeyword)
|
|
{
|
|
syntaxToken = AddError(syntaxToken, ErrorCode.ERR_BadAwaitAsIdentifier);
|
|
}
|
|
return syntaxToken;
|
|
}
|
|
return AddError(CreateMissingIdentifierToken(), code);
|
|
}
|
|
|
|
private bool IsCurrentTokenQueryKeywordInQuery()
|
|
{
|
|
if (IsInQuery)
|
|
{
|
|
return IsCurrentTokenQueryContextualKeyword;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private bool IsCurrentTokenPartialKeywordOfPartialMethodOrType()
|
|
{
|
|
if (base.CurrentToken.ContextualKind == SyntaxKind.PartialKeyword && (IsPartialType() || IsPartialMember()))
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private TypeParameterListSyntax ParseTypeParameterList()
|
|
{
|
|
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
|
|
if (base.CurrentToken.Kind != SyntaxKind.LessThanToken)
|
|
{
|
|
return null;
|
|
}
|
|
TerminatorState termState = _termState;
|
|
_termState |= TerminatorState.IsEndOfTypeParameterList;
|
|
SyntaxToken openToken = EatToken(SyntaxKind.LessThanToken);
|
|
SeparatedSyntaxList<TypeParameterSyntax> parameters = ParseCommaSeparatedSyntaxList(ref openToken, SyntaxKind.GreaterThanToken, (LanguageParser @this) => @this.IsStartOfTypeParameter(), (LanguageParser @this) => @this.ParseTypeParameter(), skipBadTypeParameterListTokens, allowTrailingSeparator: false, requireOneElement: true, allowSemicolonAsSeparator: false);
|
|
_termState = termState;
|
|
return _syntaxFactory.TypeParameterList(openToken, parameters, EatToken(SyntaxKind.GreaterThanToken));
|
|
static PostSkipAction skipBadTypeParameterListTokens(LanguageParser @this, ref SyntaxToken open, SeparatedSyntaxListBuilder<TypeParameterSyntax> list, SyntaxKind expectedKind, SyntaxKind closeKind)
|
|
{
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
|
return @this.SkipBadSeparatedListTokensWithExpectedKind<SyntaxToken, TypeParameterSyntax>(ref open, list, (LanguageParser p) => p.CurrentToken.Kind != SyntaxKind.CommaToken, (LanguageParser p, SyntaxKind syntaxKind) => p.CurrentToken.Kind == syntaxKind, expectedKind, closeKind);
|
|
}
|
|
}
|
|
|
|
private bool IsStartOfTypeParameter()
|
|
{
|
|
if (IsCurrentTokenWhereOfConstraintClause())
|
|
{
|
|
return false;
|
|
}
|
|
if (base.CurrentToken.Kind == SyntaxKind.OpenBracketToken && PeekToken(1).Kind != SyntaxKind.CloseBracketToken)
|
|
{
|
|
return true;
|
|
}
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
if (kind - 8361 <= SyntaxKind.List)
|
|
{
|
|
return true;
|
|
}
|
|
return IsTrueIdentifier();
|
|
}
|
|
|
|
private TypeParameterSyntax ParseTypeParameter()
|
|
{
|
|
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
|
|
if (IsCurrentTokenWhereOfConstraintClause())
|
|
{
|
|
return _syntaxFactory.TypeParameter(default(SyntaxList<AttributeListSyntax>), null, AddError(CreateMissingIdentifierToken(), ErrorCode.ERR_IdentifierExpected));
|
|
}
|
|
SyntaxList<AttributeListSyntax> val = default(SyntaxList<AttributeListSyntax>);
|
|
if (base.CurrentToken.Kind == SyntaxKind.OpenBracketToken && PeekToken(1).Kind != SyntaxKind.CloseBracketToken)
|
|
{
|
|
TerminatorState termState = _termState;
|
|
_termState = TerminatorState.IsEndOfTypeArgumentList;
|
|
val = ParseAttributeDeclarations(inExpressionContext: false);
|
|
_termState = termState;
|
|
}
|
|
ContextAwareSyntax syntaxFactory = _syntaxFactory;
|
|
SyntaxList<AttributeListSyntax> attributeLists = val;
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
bool flag = kind - 8361 <= SyntaxKind.List;
|
|
return syntaxFactory.TypeParameter(attributeLists, flag ? EatToken() : null, ParseIdentifierToken());
|
|
}
|
|
|
|
private SimpleNameSyntax ParseSimpleName(NameOptions options = NameOptions.None)
|
|
{
|
|
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
|
|
IdentifierNameSyntax identifierNameSyntax = ParseIdentifierName();
|
|
if (((GreenNode)identifierNameSyntax.Identifier).IsMissing)
|
|
{
|
|
return identifierNameSyntax;
|
|
}
|
|
SimpleNameSyntax result = identifierNameSyntax;
|
|
if (base.CurrentToken.Kind == SyntaxKind.LessThanToken)
|
|
{
|
|
ScanTypeArgumentListKind scanTypeArgumentListKind;
|
|
using (GetDisposableResetPoint(resetOnDispose: true))
|
|
{
|
|
scanTypeArgumentListKind = ScanTypeArgumentList(options);
|
|
}
|
|
if (scanTypeArgumentListKind == ScanTypeArgumentListKind.DefiniteTypeArgumentList || (scanTypeArgumentListKind == ScanTypeArgumentListKind.PossibleTypeArgumentList && (options & NameOptions.InTypeList) != NameOptions.None))
|
|
{
|
|
SeparatedSyntaxListBuilder<TypeSyntax> types = _pool.AllocateSeparated<TypeSyntax>();
|
|
ParseTypeArgumentList(out var open, types, out var close);
|
|
result = _syntaxFactory.GenericName(identifierNameSyntax.Identifier, _syntaxFactory.TypeArgumentList(open, _pool.ToListAndFree<TypeSyntax>(ref types), close));
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
private ScanTypeArgumentListKind ScanTypeArgumentList(NameOptions options)
|
|
{
|
|
if (base.CurrentToken.Kind != SyntaxKind.LessThanToken)
|
|
{
|
|
return ScanTypeArgumentListKind.NotTypeArgumentList;
|
|
}
|
|
if ((options & NameOptions.InExpression) == 0)
|
|
{
|
|
return ScanTypeArgumentListKind.DefiniteTypeArgumentList;
|
|
}
|
|
if (ScanPossibleTypeArgumentList(out var _, out var isDefinitelyTypeArgumentList) == ScanTypeFlags.NotType)
|
|
{
|
|
return ScanTypeArgumentListKind.NotTypeArgumentList;
|
|
}
|
|
if (isDefinitelyTypeArgumentList)
|
|
{
|
|
return ScanTypeArgumentListKind.DefiniteTypeArgumentList;
|
|
}
|
|
switch (base.CurrentToken.Kind)
|
|
{
|
|
case SyntaxKind.CaretToken:
|
|
case SyntaxKind.OpenParenToken:
|
|
case SyntaxKind.CloseParenToken:
|
|
case SyntaxKind.CloseBraceToken:
|
|
case SyntaxKind.CloseBracketToken:
|
|
case SyntaxKind.BarToken:
|
|
case SyntaxKind.ColonToken:
|
|
case SyntaxKind.SemicolonToken:
|
|
case SyntaxKind.CommaToken:
|
|
case SyntaxKind.DotToken:
|
|
case SyntaxKind.QuestionToken:
|
|
case SyntaxKind.ExclamationEqualsToken:
|
|
case SyntaxKind.EqualsEqualsToken:
|
|
return ScanTypeArgumentListKind.DefiniteTypeArgumentList;
|
|
case SyntaxKind.AmpersandToken:
|
|
case SyntaxKind.OpenBracketToken:
|
|
case SyntaxKind.LessThanToken:
|
|
case SyntaxKind.BarBarToken:
|
|
case SyntaxKind.AmpersandAmpersandToken:
|
|
case SyntaxKind.LessThanEqualsToken:
|
|
case SyntaxKind.GreaterThanEqualsToken:
|
|
case SyntaxKind.IsKeyword:
|
|
case SyntaxKind.AsKeyword:
|
|
return ScanTypeArgumentListKind.DefiniteTypeArgumentList;
|
|
case SyntaxKind.OpenBraceToken:
|
|
return ScanTypeArgumentListKind.DefiniteTypeArgumentList;
|
|
case SyntaxKind.GreaterThanToken:
|
|
if ((options & NameOptions.AfterIs) != NameOptions.None && PeekToken(1).Kind != SyntaxKind.GreaterThanToken)
|
|
{
|
|
return ScanTypeArgumentListKind.DefiniteTypeArgumentList;
|
|
}
|
|
break;
|
|
case SyntaxKind.IdentifierToken:
|
|
{
|
|
bool flag = (options & (NameOptions.AfterIs | NameOptions.DefinitePattern | NameOptions.AfterOut)) != 0;
|
|
if (!flag)
|
|
{
|
|
bool flag2 = (options & NameOptions.AfterTupleComma) != 0;
|
|
if (flag2)
|
|
{
|
|
SyntaxKind kind = PeekToken(1).Kind;
|
|
bool flag3 = ((kind == SyntaxKind.CloseParenToken || kind == SyntaxKind.CommaToken) ? true : false);
|
|
flag2 = flag3;
|
|
}
|
|
flag = flag2;
|
|
}
|
|
if (flag || ((options & NameOptions.FirstElementOfPossibleTupleLiteral) != NameOptions.None && PeekToken(1).Kind == SyntaxKind.CommaToken))
|
|
{
|
|
return ScanTypeArgumentListKind.DefiniteTypeArgumentList;
|
|
}
|
|
return ScanTypeArgumentListKind.PossibleTypeArgumentList;
|
|
}
|
|
case SyntaxKind.EndOfFileToken:
|
|
return ScanTypeArgumentListKind.DefiniteTypeArgumentList;
|
|
case SyntaxKind.EqualsGreaterThanToken:
|
|
return ScanTypeArgumentListKind.DefiniteTypeArgumentList;
|
|
}
|
|
return ScanTypeArgumentListKind.PossibleTypeArgumentList;
|
|
}
|
|
|
|
private ScanTypeFlags ScanPossibleTypeArgumentList(out SyntaxToken greaterThanToken, out bool isDefinitelyTypeArgumentList)
|
|
{
|
|
isDefinitelyTypeArgumentList = false;
|
|
if (IsOpenName())
|
|
{
|
|
isDefinitelyTypeArgumentList = true;
|
|
EatToken();
|
|
while (base.CurrentToken.Kind == SyntaxKind.CommaToken)
|
|
{
|
|
EatToken();
|
|
}
|
|
greaterThanToken = EatToken();
|
|
return ScanTypeFlags.GenericTypeOrMethod;
|
|
}
|
|
ScanTypeFlags result = ScanTypeFlags.GenericTypeOrExpression;
|
|
do
|
|
{
|
|
EatToken();
|
|
if (base.CurrentToken.Kind == SyntaxKind.OpenBracketToken)
|
|
{
|
|
greaterThanToken = null;
|
|
return ScanTypeFlags.NotType;
|
|
}
|
|
if (base.CurrentToken.Kind == SyntaxKind.GreaterThanToken)
|
|
{
|
|
greaterThanToken = EatToken();
|
|
return result;
|
|
}
|
|
SyntaxToken lastTokenOfType;
|
|
switch (ScanType(out lastTokenOfType))
|
|
{
|
|
case ScanTypeFlags.NotType:
|
|
greaterThanToken = null;
|
|
return ScanTypeFlags.NotType;
|
|
case ScanTypeFlags.MustBeType:
|
|
{
|
|
bool flag = isDefinitelyTypeArgumentList;
|
|
if (!flag)
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
bool flag2 = kind - 8216 <= SyntaxKind.List;
|
|
flag = flag2;
|
|
}
|
|
isDefinitelyTypeArgumentList = flag;
|
|
result = ScanTypeFlags.GenericTypeOrMethod;
|
|
break;
|
|
}
|
|
case ScanTypeFlags.NullableType:
|
|
{
|
|
bool flag = isDefinitelyTypeArgumentList;
|
|
if (!flag)
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
bool flag2 = kind - 8216 <= SyntaxKind.List;
|
|
flag = flag2;
|
|
}
|
|
isDefinitelyTypeArgumentList = flag;
|
|
if (isDefinitelyTypeArgumentList)
|
|
{
|
|
result = ScanTypeFlags.GenericTypeOrMethod;
|
|
}
|
|
break;
|
|
}
|
|
case ScanTypeFlags.GenericTypeOrExpression:
|
|
if (!isDefinitelyTypeArgumentList)
|
|
{
|
|
isDefinitelyTypeArgumentList = base.CurrentToken.Kind == SyntaxKind.CommaToken;
|
|
result = ScanTypeFlags.GenericTypeOrMethod;
|
|
}
|
|
break;
|
|
case ScanTypeFlags.GenericTypeOrMethod:
|
|
result = ScanTypeFlags.GenericTypeOrMethod;
|
|
break;
|
|
}
|
|
}
|
|
while (base.CurrentToken.Kind == SyntaxKind.CommaToken);
|
|
if (base.CurrentToken.Kind != SyntaxKind.GreaterThanToken)
|
|
{
|
|
greaterThanToken = null;
|
|
return ScanTypeFlags.NotType;
|
|
}
|
|
greaterThanToken = EatToken();
|
|
isDefinitelyTypeArgumentList = isDefinitelyTypeArgumentList || base.CurrentToken.Kind == SyntaxKind.CloseParenToken;
|
|
if (isDefinitelyTypeArgumentList)
|
|
{
|
|
result = ScanTypeFlags.GenericTypeOrMethod;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
private void ParseTypeArgumentList(out SyntaxToken open, SeparatedSyntaxListBuilder<TypeSyntax> types, out SyntaxToken close)
|
|
{
|
|
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
|
|
bool num = IsOpenName();
|
|
open = EatToken(SyntaxKind.LessThanToken);
|
|
open = CheckFeatureAvailability(open, MessageID.IDS_FeatureGenerics);
|
|
if (num)
|
|
{
|
|
OmittedTypeArgumentSyntax omittedTypeArgumentSyntax = _syntaxFactory.OmittedTypeArgument(SyntaxFactory.Token(SyntaxKind.OmittedTypeArgumentToken));
|
|
types.Add((TypeSyntax)omittedTypeArgumentSyntax);
|
|
while (base.CurrentToken.Kind == SyntaxKind.CommaToken)
|
|
{
|
|
types.AddSeparator((GreenNode)(object)EatToken(SyntaxKind.CommaToken));
|
|
types.Add((TypeSyntax)omittedTypeArgumentSyntax);
|
|
}
|
|
close = EatToken(SyntaxKind.GreaterThanToken);
|
|
return;
|
|
}
|
|
types.Add(ParseTypeArgument());
|
|
while (base.CurrentToken.Kind != SyntaxKind.GreaterThanToken)
|
|
{
|
|
if (base.CurrentToken.Kind == SyntaxKind.CommaToken || IsPossibleType())
|
|
{
|
|
types.AddSeparator((GreenNode)(object)EatToken(SyntaxKind.CommaToken));
|
|
types.Add(ParseTypeArgument());
|
|
}
|
|
else if (SkipBadTypeArgumentListTokens(types, SyntaxKind.CommaToken) == PostSkipAction.Abort)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
close = EatToken(SyntaxKind.GreaterThanToken);
|
|
}
|
|
|
|
private PostSkipAction SkipBadTypeArgumentListTokens(SeparatedSyntaxListBuilder<TypeSyntax> list, SyntaxKind expected)
|
|
{
|
|
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
|
|
CSharpSyntaxNode startToken = null;
|
|
return SkipBadSeparatedListTokensWithExpectedKind<CSharpSyntaxNode, TypeSyntax>(ref startToken, list, (LanguageParser p) => p.CurrentToken.Kind != SyntaxKind.CommaToken && !p.IsPossibleType(), (LanguageParser p, SyntaxKind _) => p.CurrentToken.Kind == SyntaxKind.GreaterThanToken, expected);
|
|
}
|
|
|
|
private TypeSyntax ParseTypeArgument()
|
|
{
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxList<AttributeListSyntax> val = default(SyntaxList<AttributeListSyntax>);
|
|
if (base.CurrentToken.Kind == SyntaxKind.OpenBracketToken && PeekToken(1).Kind != SyntaxKind.CloseBracketToken)
|
|
{
|
|
TerminatorState termState = _termState;
|
|
_termState = TerminatorState.IsEndOfTypeArgumentList;
|
|
val = ParseAttributeDeclarations(inExpressionContext: false);
|
|
_termState = termState;
|
|
}
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
bool flag = kind - 8361 <= SyntaxKind.List;
|
|
SyntaxToken syntaxToken = (flag ? AddError(EatToken(), ErrorCode.ERR_IllegalVarianceSyntax) : null);
|
|
TypeSyntax typeSyntax = ParseType();
|
|
int num;
|
|
if (((GreenNode)typeSyntax).IsMissing)
|
|
{
|
|
kind = base.CurrentToken.Kind;
|
|
num = ((kind != SyntaxKind.CommaToken && kind != SyntaxKind.GreaterThanToken) ? 1 : 0);
|
|
}
|
|
else
|
|
{
|
|
num = 0;
|
|
}
|
|
flag = (byte)num != 0;
|
|
if (flag)
|
|
{
|
|
kind = PeekToken(1).Kind;
|
|
bool flag2 = kind - 8216 <= SyntaxKind.List;
|
|
flag = flag2;
|
|
}
|
|
if (flag)
|
|
{
|
|
typeSyntax = AddTrailingSkippedSyntax(typeSyntax, (GreenNode)(object)EatToken());
|
|
}
|
|
if (syntaxToken != null)
|
|
{
|
|
typeSyntax = AddLeadingSkippedSyntax(typeSyntax, (GreenNode)(object)syntaxToken);
|
|
}
|
|
if (val.Count > 0)
|
|
{
|
|
typeSyntax = AddLeadingSkippedSyntax(typeSyntax, val.Node);
|
|
typeSyntax = AddError(typeSyntax, ErrorCode.ERR_TypeExpected);
|
|
}
|
|
return typeSyntax;
|
|
}
|
|
|
|
private bool IsEndOfTypeArgumentList()
|
|
{
|
|
return base.CurrentToken.Kind == SyntaxKind.GreaterThanToken;
|
|
}
|
|
|
|
private bool IsOpenName()
|
|
{
|
|
int i;
|
|
for (i = 1; PeekToken(i).Kind == SyntaxKind.CommaToken; i++)
|
|
{
|
|
}
|
|
return PeekToken(i).Kind == SyntaxKind.GreaterThanToken;
|
|
}
|
|
|
|
private void ParseMemberName(out ExplicitInterfaceSpecifierSyntax explicitInterfaceOpt, out SyntaxToken identifierOrThisOpt, out TypeParameterListSyntax typeParameterListOpt, bool isEvent)
|
|
{
|
|
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
|
|
identifierOrThisOpt = null;
|
|
explicitInterfaceOpt = null;
|
|
typeParameterListOpt = null;
|
|
if (!IsPossibleMemberName())
|
|
{
|
|
return;
|
|
}
|
|
NameSyntax explicitInterfaceName = null;
|
|
SyntaxToken separator = null;
|
|
ResetPoint state = default(ResetPoint);
|
|
bool flag = false;
|
|
try
|
|
{
|
|
while (true)
|
|
{
|
|
if (base.CurrentToken.Kind == SyntaxKind.ThisKeyword)
|
|
{
|
|
state = GetResetPoint();
|
|
flag = true;
|
|
identifierOrThisOpt = EatToken();
|
|
typeParameterListOpt = ParseTypeParameterList();
|
|
break;
|
|
}
|
|
bool flag2;
|
|
using (GetDisposableResetPoint(resetOnDispose: true))
|
|
{
|
|
ScanNamedTypePart();
|
|
flag2 = !IsDotOrColonColonOrDotDot();
|
|
}
|
|
if (flag2)
|
|
{
|
|
state = GetResetPoint();
|
|
flag = true;
|
|
if (separator != null && separator.Kind == SyntaxKind.ColonColonToken)
|
|
{
|
|
separator = AddError(separator, ErrorCode.ERR_AliasQualAsExpression);
|
|
separator = ConvertToMissingWithTrailingTrivia(separator, SyntaxKind.DotToken);
|
|
}
|
|
identifierOrThisOpt = ParseIdentifierToken();
|
|
typeParameterListOpt = ParseTypeParameterList();
|
|
break;
|
|
}
|
|
AccumulateExplicitInterfaceName(ref explicitInterfaceName, ref separator);
|
|
}
|
|
if (explicitInterfaceName == null)
|
|
{
|
|
return;
|
|
}
|
|
if (separator.Kind != SyntaxKind.DotToken)
|
|
{
|
|
separator = WithAdditionalDiagnostics(separator, GetExpectedTokenError(SyntaxKind.DotToken, separator.Kind, ((GreenNode)separator).GetLeadingTriviaWidth(), ((GreenNode)separator).Width));
|
|
separator = ConvertToMissingWithTrailingTrivia(separator, SyntaxKind.DotToken);
|
|
}
|
|
if (isEvent)
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
if (kind != SyntaxKind.OpenBraceToken && kind != SyntaxKind.SemicolonToken)
|
|
{
|
|
explicitInterfaceOpt = _syntaxFactory.ExplicitInterfaceSpecifier(explicitInterfaceName, AddError(separator, ErrorCode.ERR_ExplicitEventFieldImpl));
|
|
if (separator.TrailingTrivia.Any(8539))
|
|
{
|
|
Reset(ref state);
|
|
identifierOrThisOpt = null;
|
|
typeParameterListOpt = null;
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
explicitInterfaceOpt = _syntaxFactory.ExplicitInterfaceSpecifier(explicitInterfaceName, separator);
|
|
}
|
|
finally
|
|
{
|
|
if (flag)
|
|
{
|
|
Release(ref state);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void AccumulateExplicitInterfaceName(ref NameSyntax explicitInterfaceName, ref SyntaxToken separator)
|
|
{
|
|
TerminatorState termState = _termState;
|
|
_termState |= TerminatorState.IsEndOfNameInExplicitInterface;
|
|
if (explicitInterfaceName == null)
|
|
{
|
|
explicitInterfaceName = ParseSimpleName(NameOptions.InTypeList);
|
|
if (base.CurrentToken.Kind == SyntaxKind.DotDotToken)
|
|
{
|
|
separator = EatToken();
|
|
explicitInterfaceName = RecoverFromDotDot(explicitInterfaceName, ref separator);
|
|
}
|
|
else
|
|
{
|
|
separator = ((base.CurrentToken.Kind == SyntaxKind.ColonColonToken) ? EatToken() : EatToken(SyntaxKind.DotToken));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
NameSyntax nameSyntax = ParseQualifiedNameRight(NameOptions.InTypeList, explicitInterfaceName, separator);
|
|
explicitInterfaceName = nameSyntax;
|
|
if (base.CurrentToken.Kind == SyntaxKind.ColonColonToken)
|
|
{
|
|
separator = EatToken();
|
|
separator = AddError(separator, ErrorCode.ERR_UnexpectedAliasedName);
|
|
separator = ConvertToMissingWithTrailingTrivia(separator, SyntaxKind.DotToken);
|
|
}
|
|
else if (base.CurrentToken.Kind == SyntaxKind.DotDotToken)
|
|
{
|
|
separator = EatToken();
|
|
explicitInterfaceName = RecoverFromDotDot(explicitInterfaceName, ref separator);
|
|
}
|
|
else
|
|
{
|
|
separator = EatToken(SyntaxKind.DotToken);
|
|
}
|
|
}
|
|
_termState = termState;
|
|
}
|
|
|
|
private bool IsOperatorStart(out ExplicitInterfaceSpecifierSyntax explicitInterfaceOpt, bool advanceParser = true)
|
|
{
|
|
explicitInterfaceOpt = null;
|
|
if (IsOperatorKeyword())
|
|
{
|
|
return true;
|
|
}
|
|
if (base.CurrentToken.Kind != SyntaxKind.IdentifierToken)
|
|
{
|
|
return false;
|
|
}
|
|
NameSyntax explicitInterfaceName = null;
|
|
SyntaxToken separator = null;
|
|
using DisposableResetPoint disposableResetPoint = GetDisposableResetPoint(resetOnDispose: false);
|
|
while (true)
|
|
{
|
|
bool flag;
|
|
using (GetDisposableResetPoint(resetOnDispose: true))
|
|
{
|
|
if (IsOperatorKeyword())
|
|
{
|
|
flag = false;
|
|
}
|
|
else
|
|
{
|
|
ScanNamedTypePart();
|
|
flag = IsDotOrColonColonOrDotDot() || IsOperatorKeyword();
|
|
}
|
|
}
|
|
if (!flag)
|
|
{
|
|
break;
|
|
}
|
|
AccumulateExplicitInterfaceName(ref explicitInterfaceName, ref separator);
|
|
}
|
|
if (separator != null && separator.Kind == SyntaxKind.ColonColonToken)
|
|
{
|
|
separator = AddError(separator, ErrorCode.ERR_AliasQualAsExpression);
|
|
separator = ConvertToMissingWithTrailingTrivia(separator, SyntaxKind.DotToken);
|
|
}
|
|
if (!IsOperatorKeyword() || explicitInterfaceName == null)
|
|
{
|
|
disposableResetPoint.Reset();
|
|
return false;
|
|
}
|
|
if (!advanceParser)
|
|
{
|
|
disposableResetPoint.Reset();
|
|
return true;
|
|
}
|
|
if (separator.Kind != SyntaxKind.DotToken)
|
|
{
|
|
separator = WithAdditionalDiagnostics(separator, GetExpectedTokenError(SyntaxKind.DotToken, separator.Kind, ((GreenNode)separator).GetLeadingTriviaWidth(), ((GreenNode)separator).Width));
|
|
separator = ConvertToMissingWithTrailingTrivia(separator, SyntaxKind.DotToken);
|
|
}
|
|
explicitInterfaceOpt = _syntaxFactory.ExplicitInterfaceSpecifier(explicitInterfaceName, separator);
|
|
return true;
|
|
}
|
|
|
|
private NameSyntax ParseAliasQualifiedName(NameOptions allowedParts = NameOptions.None)
|
|
{
|
|
SimpleNameSyntax simpleNameSyntax = ParseSimpleName(allowedParts);
|
|
if (base.CurrentToken.Kind != SyntaxKind.ColonColonToken)
|
|
{
|
|
return simpleNameSyntax;
|
|
}
|
|
return ParseQualifiedNameRight(allowedParts, simpleNameSyntax, EatToken());
|
|
}
|
|
|
|
private NameSyntax ParseQualifiedName(NameOptions options = NameOptions.None)
|
|
{
|
|
NameSyntax nameSyntax = ParseAliasQualifiedName(options);
|
|
while (IsDotOrColonColonOrDotDot() && PeekToken(1).Kind != SyntaxKind.ThisKeyword)
|
|
{
|
|
SyntaxToken separator = EatToken();
|
|
nameSyntax = ParseQualifiedNameRight(options, nameSyntax, separator);
|
|
}
|
|
return nameSyntax;
|
|
}
|
|
|
|
private bool IsDotOrColonColonOrDotDot()
|
|
{
|
|
if (!IsDotOrColonColon())
|
|
{
|
|
return base.CurrentToken.Kind == SyntaxKind.DotDotToken;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private NameSyntax ParseQualifiedNameRight(NameOptions options, NameSyntax left, SyntaxToken separator)
|
|
{
|
|
SimpleNameSyntax simpleNameSyntax = ParseSimpleName(options);
|
|
switch (separator.Kind)
|
|
{
|
|
case SyntaxKind.DotToken:
|
|
return _syntaxFactory.QualifiedName(left, separator, simpleNameSyntax);
|
|
case SyntaxKind.DotDotToken:
|
|
return _syntaxFactory.QualifiedName(RecoverFromDotDot(left, ref separator), separator, simpleNameSyntax);
|
|
case SyntaxKind.ColonColonToken:
|
|
{
|
|
if (left.Kind != SyntaxKind.IdentifierName)
|
|
{
|
|
separator = AddError(separator, ErrorCode.ERR_UnexpectedAliasedName);
|
|
}
|
|
IdentifierNameSyntax identifierNameSyntax = left as IdentifierNameSyntax;
|
|
if (identifierNameSyntax == null)
|
|
{
|
|
separator = ConvertToMissingWithTrailingTrivia(separator, SyntaxKind.DotToken);
|
|
return _syntaxFactory.QualifiedName(left, separator, simpleNameSyntax);
|
|
}
|
|
if (identifierNameSyntax.Identifier.ContextualKind == SyntaxKind.GlobalKeyword)
|
|
{
|
|
identifierNameSyntax = _syntaxFactory.IdentifierName(SyntaxParser.ConvertToKeyword(identifierNameSyntax.Identifier));
|
|
}
|
|
return WithAdditionalDiagnostics(_syntaxFactory.AliasQualifiedName(identifierNameSyntax, separator, simpleNameSyntax), ((GreenNode)left).GetDiagnostics());
|
|
}
|
|
default:
|
|
throw ExceptionUtilities.Unreachable("/_/src/Compilers/CSharp/Portable/Parser/LanguageParser.cs", 6392);
|
|
}
|
|
}
|
|
|
|
private NameSyntax RecoverFromDotDot(NameSyntax left, ref SyntaxToken separator)
|
|
{
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxToken dotToken = SyntaxFactory.Token(separator.LeadingTrivia.Node, SyntaxKind.DotToken, null);
|
|
IdentifierNameSyntax right = AddError(CreateMissingIdentifierName(), ErrorCode.ERR_IdentifierExpected);
|
|
separator = SyntaxFactory.Token(null, SyntaxKind.DotToken, separator.TrailingTrivia.Node);
|
|
return _syntaxFactory.QualifiedName(left, dotToken, right);
|
|
}
|
|
|
|
private SyntaxToken ConvertToMissingWithTrailingTrivia(SyntaxToken token, SyntaxKind expectedKind)
|
|
{
|
|
SyntaxToken node = SyntaxFactory.MissingToken(expectedKind);
|
|
return AddTrailingSkippedSyntax(node, (GreenNode)(object)token);
|
|
}
|
|
|
|
private bool IsPossibleType()
|
|
{
|
|
if (!IsPredefinedType(base.CurrentToken.Kind))
|
|
{
|
|
return IsTrueIdentifier();
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private ScanTypeFlags ScanType(bool forPattern = false)
|
|
{
|
|
SyntaxToken lastTokenOfType;
|
|
return ScanType(out lastTokenOfType, forPattern);
|
|
}
|
|
|
|
private ScanTypeFlags ScanType(out SyntaxToken lastTokenOfType, bool forPattern = false)
|
|
{
|
|
return ScanType(forPattern ? ParseTypeMode.DefinitePattern : ParseTypeMode.Normal, out lastTokenOfType);
|
|
}
|
|
|
|
private void ScanNamedTypePart()
|
|
{
|
|
ScanNamedTypePart(out var _);
|
|
}
|
|
|
|
private ScanTypeFlags ScanNamedTypePart(out SyntaxToken lastTokenOfType)
|
|
{
|
|
if (base.CurrentToken.Kind != SyntaxKind.IdentifierToken || !IsTrueIdentifier())
|
|
{
|
|
lastTokenOfType = null;
|
|
return ScanTypeFlags.NotType;
|
|
}
|
|
lastTokenOfType = EatToken();
|
|
bool isDefinitelyTypeArgumentList;
|
|
if (base.CurrentToken.Kind == SyntaxKind.LessThanToken)
|
|
{
|
|
return ScanPossibleTypeArgumentList(out lastTokenOfType, out isDefinitelyTypeArgumentList);
|
|
}
|
|
return ScanTypeFlags.NonGenericTypeOrExpression;
|
|
}
|
|
|
|
private ScanTypeFlags ScanType(ParseTypeMode mode, out SyntaxToken lastTokenOfType)
|
|
{
|
|
if (base.CurrentToken.Kind == SyntaxKind.RefKeyword)
|
|
{
|
|
EatToken();
|
|
if (base.CurrentToken.Kind == SyntaxKind.ReadOnlyKeyword)
|
|
{
|
|
EatToken();
|
|
}
|
|
}
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
ScanTypeFlags scanTypeFlags;
|
|
if ((kind == SyntaxKind.ColonColonToken || kind == SyntaxKind.IdentifierToken) ? true : false)
|
|
{
|
|
bool flag;
|
|
if (base.CurrentToken.Kind == SyntaxKind.ColonColonToken)
|
|
{
|
|
scanTypeFlags = ScanTypeFlags.NonGenericTypeOrExpression;
|
|
flag = true;
|
|
lastTokenOfType = null;
|
|
}
|
|
else
|
|
{
|
|
flag = PeekToken(1).Kind == SyntaxKind.ColonColonToken;
|
|
scanTypeFlags = ScanNamedTypePart(out lastTokenOfType);
|
|
if (scanTypeFlags == ScanTypeFlags.NotType)
|
|
{
|
|
return ScanTypeFlags.NotType;
|
|
}
|
|
}
|
|
bool flag2 = true;
|
|
while (IsDotOrColonColon())
|
|
{
|
|
if (!flag2)
|
|
{
|
|
flag = false;
|
|
}
|
|
EatToken();
|
|
scanTypeFlags = ScanNamedTypePart(out lastTokenOfType);
|
|
if (scanTypeFlags == ScanTypeFlags.NotType)
|
|
{
|
|
return ScanTypeFlags.NotType;
|
|
}
|
|
flag2 = false;
|
|
}
|
|
if (flag)
|
|
{
|
|
scanTypeFlags = ScanTypeFlags.AliasQualifiedName;
|
|
}
|
|
}
|
|
else if (IsPredefinedType(base.CurrentToken.Kind))
|
|
{
|
|
lastTokenOfType = EatToken();
|
|
scanTypeFlags = ScanTypeFlags.MustBeType;
|
|
}
|
|
else if (base.CurrentToken.Kind == SyntaxKind.OpenParenToken)
|
|
{
|
|
lastTokenOfType = EatToken();
|
|
scanTypeFlags = ScanTupleType(out lastTokenOfType);
|
|
if (scanTypeFlags == ScanTypeFlags.NotType || (mode == ParseTypeMode.DefinitePattern && base.CurrentToken.Kind != SyntaxKind.OpenBracketToken))
|
|
{
|
|
return ScanTypeFlags.NotType;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (!IsFunctionPointerStart())
|
|
{
|
|
lastTokenOfType = null;
|
|
return ScanTypeFlags.NotType;
|
|
}
|
|
scanTypeFlags = ScanFunctionPointerType(out lastTokenOfType);
|
|
}
|
|
int lastTokenPosition = -1;
|
|
while (IsMakingProgress(ref lastTokenPosition))
|
|
{
|
|
switch (base.CurrentToken.Kind)
|
|
{
|
|
case SyntaxKind.QuestionToken:
|
|
{
|
|
SyntaxKind kind2 = lastTokenOfType.Kind;
|
|
if (kind2 != SyntaxKind.QuestionToken && kind2 != SyntaxKind.AsteriskToken)
|
|
{
|
|
lastTokenOfType = EatToken();
|
|
scanTypeFlags = ScanTypeFlags.NullableType;
|
|
continue;
|
|
}
|
|
break;
|
|
}
|
|
case SyntaxKind.AsteriskToken:
|
|
if (mode != ParseTypeMode.DefinitePattern && ((mode != ParseTypeMode.AfterTupleComma && mode != ParseTypeMode.FirstElementOfPossibleTupleLiteral) || PointerTypeModsFollowedByRankAndDimensionSpecifier()))
|
|
{
|
|
lastTokenOfType = EatToken();
|
|
if ((uint)(scanTypeFlags - 3) <= 1u)
|
|
{
|
|
scanTypeFlags = ScanTypeFlags.PointerOrMultiplication;
|
|
}
|
|
else if (scanTypeFlags == ScanTypeFlags.GenericTypeOrMethod)
|
|
{
|
|
scanTypeFlags = ScanTypeFlags.MustBeType;
|
|
}
|
|
continue;
|
|
}
|
|
break;
|
|
case SyntaxKind.OpenBracketToken:
|
|
EatToken();
|
|
while (base.CurrentToken.Kind == SyntaxKind.CommaToken)
|
|
{
|
|
EatToken();
|
|
}
|
|
if (base.CurrentToken.Kind != SyntaxKind.CloseBracketToken)
|
|
{
|
|
lastTokenOfType = null;
|
|
return ScanTypeFlags.NotType;
|
|
}
|
|
lastTokenOfType = EatToken();
|
|
scanTypeFlags = ScanTypeFlags.MustBeType;
|
|
continue;
|
|
}
|
|
break;
|
|
}
|
|
return scanTypeFlags;
|
|
}
|
|
|
|
private ScanTypeFlags ScanTupleType(out SyntaxToken lastTokenOfType)
|
|
{
|
|
if (ScanType(out lastTokenOfType) != ScanTypeFlags.NotType)
|
|
{
|
|
if (IsTrueIdentifier())
|
|
{
|
|
lastTokenOfType = EatToken();
|
|
}
|
|
if (base.CurrentToken.Kind == SyntaxKind.CommaToken)
|
|
{
|
|
do
|
|
{
|
|
lastTokenOfType = EatToken();
|
|
if (ScanType(out lastTokenOfType) == ScanTypeFlags.NotType)
|
|
{
|
|
lastTokenOfType = EatToken();
|
|
return ScanTypeFlags.NotType;
|
|
}
|
|
if (IsTrueIdentifier())
|
|
{
|
|
lastTokenOfType = EatToken();
|
|
}
|
|
}
|
|
while (base.CurrentToken.Kind == SyntaxKind.CommaToken);
|
|
if (base.CurrentToken.Kind == SyntaxKind.CloseParenToken)
|
|
{
|
|
lastTokenOfType = EatToken();
|
|
return ScanTypeFlags.TupleType;
|
|
}
|
|
}
|
|
}
|
|
lastTokenOfType = null;
|
|
return ScanTypeFlags.NotType;
|
|
}
|
|
|
|
private ScanTypeFlags ScanFunctionPointerType(out SyntaxToken lastTokenOfType)
|
|
{
|
|
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
|
|
EatToken(SyntaxKind.DelegateKeyword);
|
|
lastTokenOfType = EatToken(SyntaxKind.AsteriskToken);
|
|
SyntaxToken lastTokenOfType2;
|
|
if (base.CurrentToken.Kind == SyntaxKind.IdentifierToken)
|
|
{
|
|
SyntaxToken syntaxToken = PeekToken(1);
|
|
lastTokenOfType2 = base.CurrentToken;
|
|
if (lastTokenOfType2 != null)
|
|
{
|
|
SyntaxKind contextualKind = lastTokenOfType2.ContextualKind;
|
|
if (contextualKind - 8445 <= SyntaxKind.List)
|
|
{
|
|
goto IL_006b;
|
|
}
|
|
}
|
|
if (!IsPossibleFunctionPointerParameterListStart(syntaxToken) && syntaxToken.Kind != SyntaxKind.OpenBracketToken)
|
|
{
|
|
return ScanTypeFlags.MustBeType;
|
|
}
|
|
goto IL_006b;
|
|
}
|
|
goto IL_00f2;
|
|
IL_006b:
|
|
lastTokenOfType = EatToken();
|
|
TerminatorState termState;
|
|
if (base.CurrentToken.Kind == SyntaxKind.OpenBracketToken)
|
|
{
|
|
lastTokenOfType = EatToken(SyntaxKind.OpenBracketToken);
|
|
termState = _termState;
|
|
_termState |= TerminatorState.IsEndOfFunctionPointerCallingConvention;
|
|
try
|
|
{
|
|
while (true)
|
|
{
|
|
lastTokenOfType = TryEatToken(SyntaxKind.IdentifierToken) ?? lastTokenOfType;
|
|
if (skipBadFunctionPointerTokens() == PostSkipAction.Abort)
|
|
{
|
|
break;
|
|
}
|
|
lastTokenOfType = EatToken();
|
|
}
|
|
lastTokenOfType = TryEatToken(SyntaxKind.CloseBracketToken) ?? lastTokenOfType;
|
|
}
|
|
finally
|
|
{
|
|
_termState = termState;
|
|
}
|
|
}
|
|
goto IL_00f2;
|
|
IL_00f2:
|
|
if (!IsPossibleFunctionPointerParameterListStart(base.CurrentToken))
|
|
{
|
|
return ScanTypeFlags.MustBeType;
|
|
}
|
|
bool flag = EatToken().Kind == SyntaxKind.LessThanToken;
|
|
termState = _termState;
|
|
_termState |= (TerminatorState)(flag ? 8388608 : 16777216);
|
|
SyntaxListBuilder<SyntaxToken> val = _pool.Allocate<SyntaxToken>();
|
|
try
|
|
{
|
|
while (true)
|
|
{
|
|
ParseParameterModifiers(SyntaxListBuilder<SyntaxToken>.op_Implicit(val), isFunctionPointerParameter: true);
|
|
val.Clear();
|
|
ScanType(out lastTokenOfType2);
|
|
if (skipBadFunctionPointerTokens() == PostSkipAction.Abort)
|
|
{
|
|
break;
|
|
}
|
|
EatToken(SyntaxKind.CommaToken);
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
_termState = termState;
|
|
_pool.Free(SyntaxListBuilder<SyntaxToken>.op_Implicit(val));
|
|
}
|
|
if (!flag && base.CurrentToken.Kind == SyntaxKind.CloseParenToken)
|
|
{
|
|
lastTokenOfType = EatTokenAsKind(SyntaxKind.GreaterThanToken);
|
|
}
|
|
else
|
|
{
|
|
lastTokenOfType = EatToken(SyntaxKind.GreaterThanToken);
|
|
}
|
|
return ScanTypeFlags.MustBeType;
|
|
PostSkipAction skipBadFunctionPointerTokens()
|
|
{
|
|
GreenNode trailingTrivia;
|
|
return SkipBadTokensWithExpectedKind((LanguageParser p) => p.CurrentToken.Kind != SyntaxKind.CommaToken, (LanguageParser p, SyntaxKind _) => p.IsTerminator(), SyntaxKind.CommaToken, SyntaxKind.None, out trailingTrivia);
|
|
}
|
|
}
|
|
|
|
private static bool IsPredefinedType(SyntaxKind keyword)
|
|
{
|
|
return SyntaxFacts.IsPredefinedType(keyword);
|
|
}
|
|
|
|
public TypeSyntax ParseTypeName()
|
|
{
|
|
return ParseType();
|
|
}
|
|
|
|
private TypeSyntax ParseTypeOrVoid()
|
|
{
|
|
if (base.CurrentToken.Kind == SyntaxKind.VoidKeyword && PeekToken(1).Kind != SyntaxKind.AsteriskToken)
|
|
{
|
|
return _syntaxFactory.PredefinedType(EatToken());
|
|
}
|
|
return ParseType();
|
|
}
|
|
|
|
private TypeSyntax ParseType(ParseTypeMode mode = ParseTypeMode.Normal)
|
|
{
|
|
if (base.CurrentToken.Kind == SyntaxKind.RefKeyword)
|
|
{
|
|
return _syntaxFactory.RefType(EatToken(), (base.CurrentToken.Kind == SyntaxKind.ReadOnlyKeyword) ? EatToken() : null, ParseTypeCore(ParseTypeMode.AfterRef));
|
|
}
|
|
return ParseTypeCore(mode);
|
|
}
|
|
|
|
private TypeSyntax ParseTypeCore(ParseTypeMode mode)
|
|
{
|
|
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
|
|
NameOptions options;
|
|
switch (mode)
|
|
{
|
|
case ParseTypeMode.AfterIs:
|
|
options = NameOptions.InExpression | NameOptions.PossiblePattern | NameOptions.AfterIs;
|
|
break;
|
|
case ParseTypeMode.DefinitePattern:
|
|
options = NameOptions.InExpression | NameOptions.PossiblePattern | NameOptions.DefinitePattern;
|
|
break;
|
|
case ParseTypeMode.AfterOut:
|
|
options = NameOptions.InExpression | NameOptions.AfterOut;
|
|
break;
|
|
case ParseTypeMode.AfterTupleComma:
|
|
options = NameOptions.InExpression | NameOptions.AfterTupleComma;
|
|
break;
|
|
case ParseTypeMode.FirstElementOfPossibleTupleLiteral:
|
|
options = NameOptions.InExpression | NameOptions.FirstElementOfPossibleTupleLiteral;
|
|
break;
|
|
case ParseTypeMode.Normal:
|
|
case ParseTypeMode.Parameter:
|
|
case ParseTypeMode.AfterRef:
|
|
case ParseTypeMode.AsExpression:
|
|
case ParseTypeMode.NewExpression:
|
|
options = NameOptions.None;
|
|
break;
|
|
default:
|
|
throw ExceptionUtilities.UnexpectedValue((object)mode);
|
|
}
|
|
TypeSyntax type = ParseUnderlyingType(mode, options);
|
|
int lastTokenPosition = -1;
|
|
while (IsMakingProgress(ref lastTokenPosition))
|
|
{
|
|
switch (base.CurrentToken.Kind)
|
|
{
|
|
case SyntaxKind.QuestionToken:
|
|
if (canBeNullableType())
|
|
{
|
|
SyntaxToken syntaxToken = EatNullableQualifierIfApplicable(mode);
|
|
if (syntaxToken != null)
|
|
{
|
|
type = _syntaxFactory.NullableType(type, syntaxToken);
|
|
continue;
|
|
}
|
|
}
|
|
break;
|
|
case SyntaxKind.AsteriskToken:
|
|
switch (mode)
|
|
{
|
|
case ParseTypeMode.AfterIs:
|
|
case ParseTypeMode.DefinitePattern:
|
|
case ParseTypeMode.AfterTupleComma:
|
|
case ParseTypeMode.FirstElementOfPossibleTupleLiteral:
|
|
if (PointerTypeModsFollowedByRankAndDimensionSpecifier())
|
|
{
|
|
type = ParsePointerTypeMods(type);
|
|
continue;
|
|
}
|
|
break;
|
|
case ParseTypeMode.Normal:
|
|
case ParseTypeMode.Parameter:
|
|
case ParseTypeMode.AfterOut:
|
|
case ParseTypeMode.AfterRef:
|
|
case ParseTypeMode.AsExpression:
|
|
case ParseTypeMode.NewExpression:
|
|
type = ParsePointerTypeMods(type);
|
|
continue;
|
|
}
|
|
break;
|
|
case SyntaxKind.OpenBracketToken:
|
|
{
|
|
SyntaxListBuilder<ArrayRankSpecifierSyntax> val = _pool.Allocate<ArrayRankSpecifierSyntax>();
|
|
do
|
|
{
|
|
val.Add(ParseArrayRankSpecifier(out var _));
|
|
}
|
|
while (base.CurrentToken.Kind == SyntaxKind.OpenBracketToken);
|
|
type = _syntaxFactory.ArrayType(type, _pool.ToListAndFree<ArrayRankSpecifierSyntax>(val));
|
|
continue;
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
return type;
|
|
bool canBeNullableType()
|
|
{
|
|
if (type.Kind == SyntaxKind.NullableType || type.Kind == SyntaxKind.PointerType)
|
|
{
|
|
return false;
|
|
}
|
|
if (PeekToken(1).Kind == SyntaxKind.OpenBracketToken)
|
|
{
|
|
return true;
|
|
}
|
|
if (mode == ParseTypeMode.DefinitePattern)
|
|
{
|
|
return true;
|
|
}
|
|
if (mode == ParseTypeMode.NewExpression && type.Kind == SyntaxKind.TupleType)
|
|
{
|
|
SyntaxKind kind = PeekToken(1).Kind;
|
|
if (kind != SyntaxKind.OpenParenToken && kind != SyntaxKind.OpenBraceToken)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
|
|
private SyntaxToken EatNullableQualifierIfApplicable(ParseTypeMode mode)
|
|
{
|
|
using (DisposableResetPoint disposableResetPoint = GetDisposableResetPoint(resetOnDispose: false))
|
|
{
|
|
SyntaxToken result = EatToken();
|
|
if (!canFollowNullableType())
|
|
{
|
|
disposableResetPoint.Reset();
|
|
return null;
|
|
}
|
|
return result;
|
|
}
|
|
bool canFollowNullableType()
|
|
{
|
|
switch (mode)
|
|
{
|
|
case ParseTypeMode.AfterIs:
|
|
case ParseTypeMode.DefinitePattern:
|
|
case ParseTypeMode.AsExpression:
|
|
if (CanStartExpression())
|
|
{
|
|
return base.CurrentToken.Kind == SyntaxKind.OpenBracketToken;
|
|
}
|
|
return true;
|
|
case ParseTypeMode.NewExpression:
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
if (kind == SyntaxKind.OpenParenToken || kind == SyntaxKind.OpenBraceToken || kind == SyntaxKind.OpenBracketToken)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
default:
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool PointerTypeModsFollowedByRankAndDimensionSpecifier()
|
|
{
|
|
int num = 0;
|
|
while (true)
|
|
{
|
|
switch (PeekToken(num).Kind)
|
|
{
|
|
case SyntaxKind.OpenBracketToken:
|
|
return true;
|
|
default:
|
|
return false;
|
|
case SyntaxKind.AsteriskToken:
|
|
break;
|
|
}
|
|
num++;
|
|
}
|
|
}
|
|
|
|
private ArrayRankSpecifierSyntax ParseArrayRankSpecifier(out bool sawNonOmittedSize)
|
|
{
|
|
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
|
|
sawNonOmittedSize = false;
|
|
bool flag = false;
|
|
SyntaxToken openBracket = EatToken(SyntaxKind.OpenBracketToken);
|
|
SeparatedSyntaxListBuilder<ExpressionSyntax> list = _pool.AllocateSeparated<ExpressionSyntax>();
|
|
OmittedArraySizeExpressionSyntax omittedArraySizeExpressionSyntax = _syntaxFactory.OmittedArraySizeExpression(SyntaxFactory.Token(SyntaxKind.OmittedArraySizeExpressionToken));
|
|
int lastTokenPosition = -1;
|
|
while (IsMakingProgress(ref lastTokenPosition) && base.CurrentToken.Kind != SyntaxKind.CloseBracketToken)
|
|
{
|
|
if (base.CurrentToken.Kind == SyntaxKind.CommaToken)
|
|
{
|
|
flag = true;
|
|
list.Add((ExpressionSyntax)omittedArraySizeExpressionSyntax);
|
|
list.AddSeparator((GreenNode)(object)EatToken());
|
|
}
|
|
else if (IsPossibleExpression())
|
|
{
|
|
ExpressionSyntax expressionSyntax = ParseExpressionCore();
|
|
sawNonOmittedSize = true;
|
|
list.Add(expressionSyntax);
|
|
if (base.CurrentToken.Kind != SyntaxKind.CloseBracketToken)
|
|
{
|
|
list.AddSeparator((GreenNode)(object)EatToken(SyntaxKind.CommaToken));
|
|
}
|
|
}
|
|
else if (SkipBadArrayRankSpecifierTokens(ref openBracket, list, SyntaxKind.CommaToken) == PostSkipAction.Abort)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
if ((list.Count & 1) == 0)
|
|
{
|
|
flag = true;
|
|
list.Add((ExpressionSyntax)omittedArraySizeExpressionSyntax);
|
|
}
|
|
if (flag & sawNonOmittedSize)
|
|
{
|
|
for (int i = 0; i < list.Count; i++)
|
|
{
|
|
if (list[i].RawKind == 8654)
|
|
{
|
|
int width = list[i].Width;
|
|
int leadingTriviaWidth = list[i].GetLeadingTriviaWidth();
|
|
list[i] = (GreenNode)(object)AddError(CreateMissingIdentifierName(), leadingTriviaWidth, width, ErrorCode.ERR_ValueExpected);
|
|
}
|
|
}
|
|
}
|
|
return _syntaxFactory.ArrayRankSpecifier(openBracket, _pool.ToListAndFree<ExpressionSyntax>(ref list), EatToken(SyntaxKind.CloseBracketToken));
|
|
}
|
|
|
|
private TupleTypeSyntax ParseTupleType()
|
|
{
|
|
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxToken openParenToken = EatToken(SyntaxKind.OpenParenToken);
|
|
SeparatedSyntaxListBuilder<TupleElementSyntax> val = _pool.AllocateSeparated<TupleElementSyntax>();
|
|
if (base.CurrentToken.Kind != SyntaxKind.CloseParenToken)
|
|
{
|
|
val.Add(ParseTupleElement());
|
|
while (base.CurrentToken.Kind == SyntaxKind.CommaToken)
|
|
{
|
|
val.AddSeparator((GreenNode)(object)EatToken(SyntaxKind.CommaToken));
|
|
val.Add(ParseTupleElement());
|
|
}
|
|
}
|
|
if (val.Count < 2)
|
|
{
|
|
if (val.Count < 1)
|
|
{
|
|
val.Add(_syntaxFactory.TupleElement(CreateMissingIdentifierName(), null));
|
|
}
|
|
val.AddSeparator((GreenNode)(object)SyntaxFactory.MissingToken(SyntaxKind.CommaToken));
|
|
IdentifierNameSyntax type = AddError(CreateMissingIdentifierName(), ErrorCode.ERR_TupleTooFewElements);
|
|
val.Add(_syntaxFactory.TupleElement(type, null));
|
|
}
|
|
return _syntaxFactory.TupleType(openParenToken, _pool.ToListAndFree<TupleElementSyntax>(ref val), EatToken(SyntaxKind.CloseParenToken));
|
|
}
|
|
|
|
private TupleElementSyntax ParseTupleElement()
|
|
{
|
|
return _syntaxFactory.TupleElement(ParseType(), IsTrueIdentifier() ? ParseIdentifierToken() : null);
|
|
}
|
|
|
|
private PostSkipAction SkipBadArrayRankSpecifierTokens(ref SyntaxToken openBracket, SeparatedSyntaxListBuilder<ExpressionSyntax> list, SyntaxKind expected)
|
|
{
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
|
return SkipBadSeparatedListTokensWithExpectedKind<SyntaxToken, ExpressionSyntax>(ref openBracket, list, (LanguageParser p) => p.CurrentToken.Kind != SyntaxKind.CommaToken && !p.IsPossibleExpression(), (LanguageParser p, SyntaxKind _) => p.CurrentToken.Kind == SyntaxKind.CloseBracketToken, expected);
|
|
}
|
|
|
|
private TypeSyntax ParseUnderlyingType(ParseTypeMode mode, NameOptions options = NameOptions.None)
|
|
{
|
|
if (IsPredefinedType(base.CurrentToken.Kind))
|
|
{
|
|
SyntaxToken syntaxToken = EatToken();
|
|
if (syntaxToken.Kind == SyntaxKind.VoidKeyword && base.CurrentToken.Kind != SyntaxKind.AsteriskToken)
|
|
{
|
|
syntaxToken = AddError(syntaxToken, (mode == ParseTypeMode.Parameter) ? ErrorCode.ERR_NoVoidParameter : ErrorCode.ERR_NoVoidHere);
|
|
}
|
|
return _syntaxFactory.PredefinedType(syntaxToken);
|
|
}
|
|
if (IsTrueIdentifier() || base.CurrentToken.Kind == SyntaxKind.ColonColonToken)
|
|
{
|
|
return ParseQualifiedName(options);
|
|
}
|
|
if (base.CurrentToken.Kind == SyntaxKind.OpenParenToken)
|
|
{
|
|
return ParseTupleType();
|
|
}
|
|
if (IsFunctionPointerStart())
|
|
{
|
|
return ParseFunctionPointerTypeSyntax();
|
|
}
|
|
return AddError(CreateMissingIdentifierName(), (mode == ParseTypeMode.NewExpression) ? ErrorCode.ERR_BadNewExpr : ErrorCode.ERR_TypeExpected);
|
|
}
|
|
|
|
private FunctionPointerTypeSyntax ParseFunctionPointerTypeSyntax()
|
|
{
|
|
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxToken delegateKeyword = EatToken(SyntaxKind.DelegateKeyword);
|
|
SyntaxToken asteriskToken = EatToken(SyntaxKind.AsteriskToken);
|
|
FunctionPointerCallingConventionSyntax callingConvention = parseCallingConvention();
|
|
if (!IsPossibleFunctionPointerParameterListStart(base.CurrentToken))
|
|
{
|
|
SyntaxToken lessThanToken = WithAdditionalDiagnostics(SyntaxFactory.MissingToken(SyntaxKind.LessThanToken), GetExpectedTokenError(SyntaxKind.LessThanToken, SyntaxKind.None));
|
|
SeparatedSyntaxListBuilder<FunctionPointerParameterSyntax> val = _pool.AllocateSeparated<FunctionPointerParameterSyntax>();
|
|
FunctionPointerParameterSyntax functionPointerParameterSyntax = SyntaxFactory.FunctionPointerParameter(default(SyntaxList<AttributeListSyntax>), default(SyntaxList<SyntaxToken>), CreateMissingIdentifierName());
|
|
val.Add(functionPointerParameterSyntax);
|
|
return SyntaxFactory.FunctionPointerType(delegateKeyword, asteriskToken, callingConvention, SyntaxFactory.FunctionPointerParameterList(lessThanToken, _pool.ToListAndFree<FunctionPointerParameterSyntax>(ref val), TryEatToken(SyntaxKind.GreaterThanToken) ?? SyntaxFactory.MissingToken(SyntaxKind.GreaterThanToken)));
|
|
}
|
|
SyntaxToken syntaxToken = EatTokenAsKind(SyntaxKind.LessThanToken);
|
|
TerminatorState termState = _termState;
|
|
_termState |= (TerminatorState)(((GreenNode)syntaxToken).IsMissing ? 16777216 : 8388608);
|
|
SeparatedSyntaxListBuilder<FunctionPointerParameterSyntax> list = _pool.AllocateSeparated<FunctionPointerParameterSyntax>();
|
|
try
|
|
{
|
|
while (true)
|
|
{
|
|
SyntaxListBuilder<SyntaxToken> val2 = _pool.Allocate<SyntaxToken>();
|
|
ParseParameterModifiers(SyntaxListBuilder<SyntaxToken>.op_Implicit(val2), isFunctionPointerParameter: true);
|
|
list.Add(SyntaxFactory.FunctionPointerParameter(default(SyntaxList<AttributeListSyntax>), _pool.ToTokenListAndFree(SyntaxListBuilder<SyntaxToken>.op_Implicit(val2)), ParseTypeOrVoid()));
|
|
if (skipBadFunctionPointerTokens<FunctionPointerParameterSyntax>(list) == PostSkipAction.Abort)
|
|
{
|
|
break;
|
|
}
|
|
list.AddSeparator((GreenNode)(object)EatToken(SyntaxKind.CommaToken));
|
|
}
|
|
return SyntaxFactory.FunctionPointerType(delegateKeyword, asteriskToken, callingConvention, SyntaxFactory.FunctionPointerParameterList(syntaxToken, _pool.ToListAndFree<FunctionPointerParameterSyntax>(ref list), (((GreenNode)syntaxToken).IsMissing && base.CurrentToken.Kind == SyntaxKind.CloseParenToken) ? EatTokenAsKind(SyntaxKind.GreaterThanToken) : EatToken(SyntaxKind.GreaterThanToken)));
|
|
}
|
|
finally
|
|
{
|
|
_termState = termState;
|
|
}
|
|
FunctionPointerCallingConventionSyntax? parseCallingConvention()
|
|
{
|
|
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
|
|
if (base.CurrentToken.Kind != SyntaxKind.IdentifierToken)
|
|
{
|
|
return null;
|
|
}
|
|
SyntaxToken syntaxToken2 = PeekToken(1);
|
|
SyntaxToken currentToken = base.CurrentToken;
|
|
SyntaxToken syntaxToken3;
|
|
if (currentToken != null)
|
|
{
|
|
SyntaxKind contextualKind = currentToken.ContextualKind;
|
|
if (contextualKind - 8445 <= SyntaxKind.List)
|
|
{
|
|
syntaxToken3 = EatContextualToken(base.CurrentToken.ContextualKind);
|
|
goto IL_0082;
|
|
}
|
|
}
|
|
if (IsPossibleFunctionPointerParameterListStart(syntaxToken2))
|
|
{
|
|
syntaxToken3 = EatTokenAsKind(SyntaxKind.ManagedKeyword);
|
|
}
|
|
else
|
|
{
|
|
if (syntaxToken2.Kind != SyntaxKind.OpenBracketToken)
|
|
{
|
|
return null;
|
|
}
|
|
syntaxToken3 = EatTokenAsKind(SyntaxKind.UnmanagedKeyword);
|
|
}
|
|
goto IL_0082;
|
|
IL_0082:
|
|
FunctionPointerUnmanagedCallingConventionListSyntax functionPointerUnmanagedCallingConventionListSyntax = null;
|
|
if (base.CurrentToken.Kind == SyntaxKind.OpenBracketToken)
|
|
{
|
|
SyntaxToken openBracketToken = EatToken(SyntaxKind.OpenBracketToken);
|
|
SeparatedSyntaxListBuilder<FunctionPointerUnmanagedCallingConventionSyntax> list2 = _pool.AllocateSeparated<FunctionPointerUnmanagedCallingConventionSyntax>();
|
|
TerminatorState termState2 = _termState;
|
|
_termState |= TerminatorState.IsEndOfFunctionPointerCallingConvention;
|
|
try
|
|
{
|
|
while (true)
|
|
{
|
|
list2.Add(SyntaxFactory.FunctionPointerUnmanagedCallingConvention(EatToken(SyntaxKind.IdentifierToken)));
|
|
if (skipBadFunctionPointerTokens<FunctionPointerUnmanagedCallingConventionSyntax>(list2) == PostSkipAction.Abort)
|
|
{
|
|
break;
|
|
}
|
|
list2.AddSeparator((GreenNode)(object)EatToken(SyntaxKind.CommaToken));
|
|
}
|
|
SyntaxToken closeBracketToken = EatToken(SyntaxKind.CloseBracketToken);
|
|
functionPointerUnmanagedCallingConventionListSyntax = SyntaxFactory.FunctionPointerUnmanagedCallingConventionList(openBracketToken, _pool.ToListAndFree<FunctionPointerUnmanagedCallingConventionSyntax>(ref list2), closeBracketToken);
|
|
}
|
|
finally
|
|
{
|
|
_termState = termState2;
|
|
}
|
|
}
|
|
if (syntaxToken3.Kind == SyntaxKind.ManagedKeyword && functionPointerUnmanagedCallingConventionListSyntax != null)
|
|
{
|
|
functionPointerUnmanagedCallingConventionListSyntax = AddError(functionPointerUnmanagedCallingConventionListSyntax, ErrorCode.ERR_CannotSpecifyManagedWithUnmanagedSpecifiers);
|
|
}
|
|
return SyntaxFactory.FunctionPointerCallingConvention(syntaxToken3, functionPointerUnmanagedCallingConventionListSyntax);
|
|
}
|
|
PostSkipAction skipBadFunctionPointerTokens<T>(SeparatedSyntaxListBuilder<T> list2) where T : CSharpSyntaxNode
|
|
{
|
|
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
|
|
CSharpSyntaxNode startToken = null;
|
|
return SkipBadSeparatedListTokensWithExpectedKind<CSharpSyntaxNode, T>(ref startToken, list2, (LanguageParser p) => p.CurrentToken.Kind != SyntaxKind.CommaToken, (LanguageParser p, SyntaxKind _) => false, SyntaxKind.CommaToken);
|
|
}
|
|
}
|
|
|
|
private bool IsFunctionPointerStart()
|
|
{
|
|
if (base.CurrentToken.Kind == SyntaxKind.DelegateKeyword)
|
|
{
|
|
return PeekToken(1).Kind == SyntaxKind.AsteriskToken;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private static bool IsPossibleFunctionPointerParameterListStart(SyntaxToken token)
|
|
{
|
|
if (token.Kind != SyntaxKind.LessThanToken)
|
|
{
|
|
return token.Kind == SyntaxKind.OpenParenToken;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private TypeSyntax ParsePointerTypeMods(TypeSyntax type)
|
|
{
|
|
while (base.CurrentToken.Kind == SyntaxKind.AsteriskToken)
|
|
{
|
|
type = _syntaxFactory.PointerType(type, EatToken());
|
|
}
|
|
return type;
|
|
}
|
|
|
|
public StatementSyntax ParseStatement()
|
|
{
|
|
return ParseWithStackGuard((LanguageParser @this) => @this.ParsePossiblyAttributedStatement() ?? @this.ParseExpressionStatement(default(SyntaxList<AttributeListSyntax>)), (LanguageParser @this) => SyntaxFactory.EmptyStatement(default(SyntaxList<AttributeListSyntax>), SyntaxFactory.MissingToken(SyntaxKind.SemicolonToken)));
|
|
}
|
|
|
|
private StatementSyntax ParsePossiblyAttributedStatement()
|
|
{
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
|
return ParseStatementCore(ParseStatementAttributeDeclarations(), isGlobal: false);
|
|
}
|
|
|
|
private SyntaxList<AttributeListSyntax> ParseStatementAttributeDeclarations()
|
|
{
|
|
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_016c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
|
|
if (base.CurrentToken.Kind != SyntaxKind.OpenBracketToken)
|
|
{
|
|
return default(SyntaxList<AttributeListSyntax>);
|
|
}
|
|
ResetPoint state = GetResetPoint();
|
|
ParseCollectionExpression();
|
|
bool flag = false;
|
|
while (base.CurrentToken.Kind == SyntaxKind.OpenBracketToken)
|
|
{
|
|
ParseBracketedArgumentList();
|
|
flag = true;
|
|
}
|
|
bool flag2;
|
|
switch (base.CurrentToken.Kind)
|
|
{
|
|
case SyntaxKind.ExclamationToken:
|
|
case SyntaxKind.DotToken:
|
|
case SyntaxKind.QuestionToken:
|
|
case SyntaxKind.MinusMinusToken:
|
|
case SyntaxKind.PlusPlusToken:
|
|
case SyntaxKind.MinusGreaterThanToken:
|
|
flag2 = true;
|
|
break;
|
|
default:
|
|
flag2 = false;
|
|
break;
|
|
}
|
|
flag2 = flag2 || IsExpectedBinaryOperator(base.CurrentToken.Kind) || IsExpectedAssignmentOperator(base.CurrentToken.Kind) || base.CurrentToken.Kind == SyntaxKind.DotDotToken;
|
|
if (!flag2)
|
|
{
|
|
SyntaxKind contextualKind = base.CurrentToken.ContextualKind;
|
|
bool flag3 = ((contextualKind == SyntaxKind.SwitchKeyword || contextualKind == SyntaxKind.WithKeyword) ? true : false);
|
|
flag2 = flag3 && PeekToken(1).Kind == SyntaxKind.OpenBraceToken;
|
|
}
|
|
bool flag4 = flag2;
|
|
if (!flag4 && flag && base.CurrentToken.Kind == SyntaxKind.OpenParenToken)
|
|
{
|
|
flag4 = ContainsErrorDiagnostic((GreenNode)(object)ParseReturnType()) || !IsTrueIdentifier();
|
|
}
|
|
Reset(ref state);
|
|
_003F result = (flag4 ? default(SyntaxList<AttributeListSyntax>) : ParseAttributeDeclarations(inExpressionContext: true));
|
|
Release(ref state);
|
|
return (SyntaxList<AttributeListSyntax>)result;
|
|
}
|
|
|
|
private StatementSyntax ParseStatementCore(SyntaxList<AttributeListSyntax> attributes, bool isGlobal)
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0202: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01df: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0211: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0231: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0221: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_016c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0179: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
|
|
if (canReuseStatement(attributes, isGlobal))
|
|
{
|
|
return (StatementSyntax)(object)EatNode();
|
|
}
|
|
ResetPoint resetPointBeforeStatement = GetResetPoint();
|
|
try
|
|
{
|
|
_recursionDepth++;
|
|
StackGuard.EnsureSufficientExecutionStack(_recursionDepth);
|
|
switch (base.CurrentToken.Kind)
|
|
{
|
|
case SyntaxKind.FixedKeyword:
|
|
return ParseFixedStatement(attributes);
|
|
case SyntaxKind.BreakKeyword:
|
|
return ParseBreakStatement(attributes);
|
|
case SyntaxKind.ContinueKeyword:
|
|
return ParseContinueStatement(attributes);
|
|
case SyntaxKind.TryKeyword:
|
|
case SyntaxKind.CatchKeyword:
|
|
case SyntaxKind.FinallyKeyword:
|
|
return ParseTryStatement(attributes);
|
|
case SyntaxKind.CheckedKeyword:
|
|
case SyntaxKind.UncheckedKeyword:
|
|
return ParseCheckedStatement(attributes);
|
|
case SyntaxKind.DoKeyword:
|
|
return ParseDoStatement(attributes);
|
|
case SyntaxKind.ForKeyword:
|
|
return ParseForOrForEachStatement(attributes);
|
|
case SyntaxKind.ForEachKeyword:
|
|
return ParseForEachStatement(attributes, null);
|
|
case SyntaxKind.GotoKeyword:
|
|
return ParseGotoStatement(attributes);
|
|
case SyntaxKind.IfKeyword:
|
|
return ParseIfStatement(attributes);
|
|
case SyntaxKind.ElseKeyword:
|
|
return ParseMisplacedElse(attributes);
|
|
case SyntaxKind.LockKeyword:
|
|
return ParseLockStatement(attributes);
|
|
case SyntaxKind.ReturnKeyword:
|
|
return ParseReturnStatement(attributes);
|
|
case SyntaxKind.SwitchKeyword:
|
|
case SyntaxKind.CaseKeyword:
|
|
return ParseSwitchStatement(attributes);
|
|
case SyntaxKind.ThrowKeyword:
|
|
return ParseThrowStatement(attributes);
|
|
case SyntaxKind.UnsafeKeyword:
|
|
{
|
|
StatementSyntax statementSyntax = TryParseStatementStartingWithUnsafe(attributes);
|
|
if (statementSyntax != null)
|
|
{
|
|
return statementSyntax;
|
|
}
|
|
break;
|
|
}
|
|
case SyntaxKind.UsingKeyword:
|
|
return ParseStatementStartingWithUsing(attributes);
|
|
case SyntaxKind.WhileKeyword:
|
|
return ParseWhileStatement(attributes);
|
|
case SyntaxKind.OpenBraceToken:
|
|
return ParseBlock(attributes);
|
|
case SyntaxKind.SemicolonToken:
|
|
return _syntaxFactory.EmptyStatement(attributes, EatToken());
|
|
case SyntaxKind.IdentifierToken:
|
|
{
|
|
StatementSyntax statementSyntax = TryParseStatementStartingWithIdentifier(attributes, isGlobal);
|
|
if (statementSyntax != null)
|
|
{
|
|
return statementSyntax;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
return ParseStatementCoreRest(attributes, isGlobal, ref resetPointBeforeStatement);
|
|
}
|
|
finally
|
|
{
|
|
_recursionDepth--;
|
|
Release(ref resetPointBeforeStatement);
|
|
}
|
|
bool canReuseStatement(SyntaxList<AttributeListSyntax> val, bool flag)
|
|
{
|
|
if (IsIncrementalAndFactoryContextMatches && base.CurrentNode is Microsoft.CodeAnalysis.CSharp.Syntax.StatementSyntax && !flag)
|
|
{
|
|
return val.Count == 0;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
private StatementSyntax ParseStatementCoreRest(SyntaxList<AttributeListSyntax> attributes, bool isGlobal, ref ResetPoint resetPointBeforeStatement)
|
|
{
|
|
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
|
|
isGlobal = isGlobal && base.IsScript;
|
|
if (!IsPossibleLocalDeclarationStatement(isGlobal))
|
|
{
|
|
return ParseExpressionStatement(attributes);
|
|
}
|
|
if (isGlobal)
|
|
{
|
|
return null;
|
|
}
|
|
bool flag = base.CurrentToken.ContextualKind == SyntaxKind.AwaitKeyword;
|
|
StatementSyntax statementSyntax = ParseLocalDeclarationStatement(attributes);
|
|
if (statementSyntax == null)
|
|
{
|
|
Reset(ref resetPointBeforeStatement);
|
|
return null;
|
|
}
|
|
if (((GreenNode)statementSyntax).ContainsDiagnostics && flag && !IsInAsync)
|
|
{
|
|
Reset(ref resetPointBeforeStatement);
|
|
IsInAsync = true;
|
|
statementSyntax = ParseExpressionStatement(attributes);
|
|
IsInAsync = false;
|
|
}
|
|
return statementSyntax;
|
|
}
|
|
|
|
private StatementSyntax TryParseStatementStartingWithIdentifier(SyntaxList<AttributeListSyntax> attributes, bool isGlobal)
|
|
{
|
|
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
|
|
if (base.CurrentToken.ContextualKind == SyntaxKind.AwaitKeyword && PeekToken(1).Kind == SyntaxKind.ForEachKeyword)
|
|
{
|
|
return ParseForEachStatement(attributes, EatContextualToken(SyntaxKind.AwaitKeyword));
|
|
}
|
|
if (IsPossibleAwaitUsing())
|
|
{
|
|
if (PeekToken(2).Kind == SyntaxKind.OpenParenToken)
|
|
{
|
|
return ParseUsingStatement(attributes, EatContextualToken(SyntaxKind.AwaitKeyword));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (IsPossibleLabeledStatement())
|
|
{
|
|
return ParseLabeledStatement(attributes);
|
|
}
|
|
if (IsPossibleYieldStatement())
|
|
{
|
|
return ParseYieldStatement(attributes);
|
|
}
|
|
if (IsPossibleAwaitExpressionStatement())
|
|
{
|
|
return ParseExpressionStatement(attributes);
|
|
}
|
|
if (IsQueryExpression(mayBeVariableDeclaration: true, isGlobal && base.IsScript))
|
|
{
|
|
return ParseExpressionStatement(attributes, ParseQueryExpression(Precedence.Expression));
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
private StatementSyntax ParseStatementStartingWithUsing(SyntaxList<AttributeListSyntax> attributes)
|
|
{
|
|
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
|
|
if (PeekToken(1).Kind != SyntaxKind.OpenParenToken)
|
|
{
|
|
return ParseLocalDeclarationStatement(attributes);
|
|
}
|
|
return ParseUsingStatement(attributes);
|
|
}
|
|
|
|
private StatementSyntax TryParseStatementStartingWithUnsafe(SyntaxList<AttributeListSyntax> attributes)
|
|
{
|
|
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
|
|
if (!IsPossibleUnsafeStatement())
|
|
{
|
|
return null;
|
|
}
|
|
return ParseUnsafeStatement(attributes);
|
|
}
|
|
|
|
private bool IsPossibleAwaitUsing()
|
|
{
|
|
if (base.CurrentToken.ContextualKind == SyntaxKind.AwaitKeyword)
|
|
{
|
|
return PeekToken(1).Kind == SyntaxKind.UsingKeyword;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private bool IsPossibleLabeledStatement()
|
|
{
|
|
if (PeekToken(1).Kind == SyntaxKind.ColonToken)
|
|
{
|
|
return IsTrueIdentifier();
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private bool IsPossibleUnsafeStatement()
|
|
{
|
|
return PeekToken(1).Kind == SyntaxKind.OpenBraceToken;
|
|
}
|
|
|
|
private bool IsPossibleYieldStatement()
|
|
{
|
|
bool flag = base.CurrentToken.ContextualKind == SyntaxKind.YieldKeyword;
|
|
if (flag)
|
|
{
|
|
SyntaxKind kind = PeekToken(1).Kind;
|
|
bool flag2 = ((kind == SyntaxKind.BreakKeyword || kind == SyntaxKind.ReturnKeyword) ? true : false);
|
|
flag = flag2;
|
|
}
|
|
return flag;
|
|
}
|
|
|
|
private bool IsPossibleLocalDeclarationStatement(bool isGlobalScriptLevel)
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
if (kind != SyntaxKind.RefKeyword && !IsDeclarationModifier(kind))
|
|
{
|
|
if (SyntaxFacts.IsPredefinedType(kind))
|
|
{
|
|
SyntaxKind kind2 = PeekToken(1).Kind;
|
|
if (kind2 != SyntaxKind.DotToken && kind2 != SyntaxKind.OpenParenToken)
|
|
{
|
|
goto IL_0041;
|
|
}
|
|
}
|
|
if (kind == SyntaxKind.UsingKeyword)
|
|
{
|
|
return true;
|
|
}
|
|
if (IsPossibleAwaitUsing())
|
|
{
|
|
return true;
|
|
}
|
|
if (IsPossibleScopedKeyword(isFunctionPointerParameter: false))
|
|
{
|
|
return true;
|
|
}
|
|
kind = base.CurrentToken.ContextualKind;
|
|
bool flag = IsAdditionalLocalFunctionModifier(kind);
|
|
if (flag)
|
|
{
|
|
bool flag2 = ((kind == SyntaxKind.AsyncKeyword || kind == SyntaxKind.ScopedKeyword) ? true : false);
|
|
flag = !flag2 || ShouldContextualKeywordBeTreatedAsModifier(parsingStatementNotDeclaration: true);
|
|
}
|
|
if (flag)
|
|
{
|
|
return true;
|
|
}
|
|
return IsPossibleFirstTypedIdentifierInLocaDeclarationStatement(isGlobalScriptLevel);
|
|
}
|
|
goto IL_0041;
|
|
IL_0041:
|
|
return true;
|
|
}
|
|
|
|
private bool IsPossibleScopedKeyword(bool isFunctionPointerParameter)
|
|
{
|
|
using (GetDisposableResetPoint(resetOnDispose: true))
|
|
{
|
|
return ParsePossibleScopedKeyword(isFunctionPointerParameter) != null;
|
|
}
|
|
}
|
|
|
|
private bool IsPossibleFirstTypedIdentifierInLocaDeclarationStatement(bool isGlobalScriptLevel)
|
|
{
|
|
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
|
|
bool? flag = IsPossibleTypedIdentifierStart(base.CurrentToken, PeekToken(1), allowThisKeyword: false);
|
|
if (flag.HasValue)
|
|
{
|
|
return flag.Value;
|
|
}
|
|
if (base.CurrentToken.ContextualKind == SyntaxKind.IdentifierToken)
|
|
{
|
|
SyntaxToken syntaxToken = PeekToken(1);
|
|
if (syntaxToken.Kind == SyntaxKind.DotToken && syntaxToken.TrailingTrivia.Any(8539) && PeekToken(2).Kind == SyntaxKind.IdentifierToken && PeekToken(3).Kind == SyntaxKind.IdentifierToken)
|
|
{
|
|
SyntaxKind kind = PeekToken(4).Kind;
|
|
if (kind != SyntaxKind.SemicolonToken && kind != SyntaxKind.EqualsToken && kind != SyntaxKind.CommaToken && kind != SyntaxKind.OpenParenToken && kind != SyntaxKind.LessThanToken)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
using (GetDisposableResetPoint(resetOnDispose: true))
|
|
{
|
|
ScanTypeFlags scanTypeFlags = ScanType();
|
|
if (scanTypeFlags == ScanTypeFlags.MustBeType)
|
|
{
|
|
SyntaxKind kind2 = base.CurrentToken.Kind;
|
|
if (kind2 != SyntaxKind.DotToken && kind2 != SyntaxKind.OpenParenToken)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
if (scanTypeFlags == ScanTypeFlags.NotType || base.CurrentToken.Kind != SyntaxKind.IdentifierToken)
|
|
{
|
|
return false;
|
|
}
|
|
if (isGlobalScriptLevel)
|
|
{
|
|
switch (scanTypeFlags)
|
|
{
|
|
case ScanTypeFlags.PointerOrMultiplication:
|
|
return false;
|
|
case ScanTypeFlags.NullableType:
|
|
return IsPossibleDeclarationStatementFollowingNullableType(isGlobalScriptLevel);
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
|
|
private bool IsPossibleTopLevelUsingLocalDeclarationStatement()
|
|
{
|
|
if (base.CurrentToken.Kind != SyntaxKind.UsingKeyword)
|
|
{
|
|
return false;
|
|
}
|
|
SyntaxKind kind = PeekToken(1).Kind;
|
|
if (kind == SyntaxKind.RefKeyword)
|
|
{
|
|
return true;
|
|
}
|
|
if (IsDeclarationModifier(kind))
|
|
{
|
|
if (kind != SyntaxKind.StaticKeyword)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
else if (SyntaxFacts.IsPredefinedType(kind))
|
|
{
|
|
return true;
|
|
}
|
|
using (GetDisposableResetPoint(resetOnDispose: true))
|
|
{
|
|
EatToken();
|
|
if (IsPossibleScopedKeyword(isFunctionPointerParameter: false))
|
|
{
|
|
return true;
|
|
}
|
|
if (kind == SyntaxKind.StaticKeyword)
|
|
{
|
|
EatToken();
|
|
}
|
|
return IsPossibleFirstTypedIdentifierInLocaDeclarationStatement(isGlobalScriptLevel: false);
|
|
}
|
|
}
|
|
|
|
private bool IsPossibleDeclarationStatementFollowingNullableType(bool isGlobalScriptLevel)
|
|
{
|
|
if (IsFieldDeclaration(isEvent: false, isGlobalScriptLevel))
|
|
{
|
|
return IsPossibleFieldDeclarationFollowingNullableType();
|
|
}
|
|
ParseMemberName(out var explicitInterfaceOpt, out var identifierOrThisOpt, out var typeParameterListOpt, isEvent: false);
|
|
if (explicitInterfaceOpt == null && identifierOrThisOpt == null && typeParameterListOpt == null)
|
|
{
|
|
return false;
|
|
}
|
|
if (base.CurrentToken.Kind == SyntaxKind.OpenBraceToken)
|
|
{
|
|
return true;
|
|
}
|
|
if (identifierOrThisOpt.Kind == SyntaxKind.ThisKeyword)
|
|
{
|
|
return false;
|
|
}
|
|
return IsPossibleMethodDeclarationFollowingNullableType();
|
|
}
|
|
|
|
private bool IsPossibleFieldDeclarationFollowingNullableType()
|
|
{
|
|
if (base.CurrentToken.Kind != SyntaxKind.IdentifierToken)
|
|
{
|
|
return false;
|
|
}
|
|
EatToken();
|
|
if (base.CurrentToken.Kind == SyntaxKind.EqualsToken)
|
|
{
|
|
TerminatorState termState = _termState;
|
|
_termState |= TerminatorState.IsEndOfFieldDeclaration;
|
|
EatToken();
|
|
ParseVariableInitializer();
|
|
_termState = termState;
|
|
}
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
if (kind == SyntaxKind.SemicolonToken || kind == SyntaxKind.CommaToken)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private bool IsPossibleMethodDeclarationFollowingNullableType()
|
|
{
|
|
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
|
|
TerminatorState termState = _termState;
|
|
_termState |= TerminatorState.IsEndOfMethodSignature;
|
|
ParameterListSyntax parameterListSyntax = ParseParenthesizedParameterList();
|
|
_termState = termState;
|
|
SyntaxList<GreenNode> withSeparators = parameterListSyntax.Parameters.GetWithSeparators();
|
|
if (!((GreenNode)parameterListSyntax.CloseParenToken).IsMissing)
|
|
{
|
|
if (base.CurrentToken.Kind == SyntaxKind.OpenBraceToken || base.CurrentToken.ContextualKind == SyntaxKind.WhereKeyword)
|
|
{
|
|
return true;
|
|
}
|
|
if (base.CurrentToken.Kind == SyntaxKind.ColonToken)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
if (withSeparators.Count == 0)
|
|
{
|
|
return false;
|
|
}
|
|
ParameterSyntax parameterSyntax = (ParameterSyntax)(object)withSeparators[0];
|
|
if (parameterSyntax.AttributeLists.Count > 0)
|
|
{
|
|
return true;
|
|
}
|
|
for (int i = 0; i < parameterSyntax.Modifiers.Count; i++)
|
|
{
|
|
if (parameterSyntax.Modifiers[i].Kind == SyntaxKind.ParamsKeyword)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
if (parameterSyntax.Type == null)
|
|
{
|
|
if (parameterSyntax.Identifier.Kind == SyntaxKind.ArgListKeyword)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
else if (parameterSyntax.Type.Kind == SyntaxKind.NullableType)
|
|
{
|
|
if (parameterSyntax.Modifiers.Count > 0)
|
|
{
|
|
return true;
|
|
}
|
|
if (!((GreenNode)parameterSyntax.Identifier).IsMissing && ((withSeparators.Count >= 2 && !withSeparators[1].IsMissing) || (withSeparators.Count == 1 && !((GreenNode)parameterListSyntax.CloseParenToken).IsMissing)))
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (parameterSyntax.Type.Kind == SyntaxKind.IdentifierName && ((IdentifierNameSyntax)parameterSyntax.Type).Identifier.ContextualKind == SyntaxKind.FromKeyword)
|
|
{
|
|
return false;
|
|
}
|
|
if (!((GreenNode)parameterSyntax.Identifier).IsMissing)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private bool IsPossibleNewExpression()
|
|
{
|
|
SyntaxToken syntaxToken = PeekToken(1);
|
|
SyntaxKind kind = syntaxToken.Kind;
|
|
if (kind == SyntaxKind.OpenBraceToken || kind == SyntaxKind.OpenBracketToken)
|
|
{
|
|
return true;
|
|
}
|
|
if (SyntaxFacts.GetBaseTypeDeclarationKind(syntaxToken.Kind) != SyntaxKind.None)
|
|
{
|
|
return false;
|
|
}
|
|
switch (GetModifierExcludingScoped(syntaxToken))
|
|
{
|
|
case DeclarationModifiers.Partial:
|
|
if (SyntaxFacts.IsPredefinedType(PeekToken(2).Kind))
|
|
{
|
|
return false;
|
|
}
|
|
if (IsTypeModifierOrTypeKeyword(PeekToken(2).Kind))
|
|
{
|
|
return false;
|
|
}
|
|
break;
|
|
default:
|
|
return false;
|
|
case DeclarationModifiers.None:
|
|
break;
|
|
}
|
|
bool? flag = IsPossibleTypedIdentifierStart(syntaxToken, PeekToken(2), allowThisKeyword: true);
|
|
if (flag.HasValue)
|
|
{
|
|
return !flag.Value;
|
|
}
|
|
using (GetDisposableResetPoint(resetOnDispose: true))
|
|
{
|
|
EatToken();
|
|
ScanTypeFlags scanTypeFlags = ScanType();
|
|
return !IsPossibleMemberName() || scanTypeFlags == ScanTypeFlags.NotType;
|
|
}
|
|
}
|
|
|
|
private bool? IsPossibleTypedIdentifierStart(SyntaxToken current, SyntaxToken next, bool allowThisKeyword)
|
|
{
|
|
if (IsTrueIdentifier(current))
|
|
{
|
|
switch (next.Kind)
|
|
{
|
|
case SyntaxKind.AsteriskToken:
|
|
case SyntaxKind.OpenBracketToken:
|
|
case SyntaxKind.LessThanToken:
|
|
case SyntaxKind.DotToken:
|
|
case SyntaxKind.QuestionToken:
|
|
case SyntaxKind.ColonColonToken:
|
|
return null;
|
|
case SyntaxKind.OpenParenToken:
|
|
if (current.IsIdentifierVar())
|
|
{
|
|
return null;
|
|
}
|
|
return false;
|
|
case SyntaxKind.IdentifierToken:
|
|
return IsTrueIdentifier(next);
|
|
case SyntaxKind.ThisKeyword:
|
|
return allowThisKeyword;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
private BlockSyntax ParsePossiblyAttributedBlock()
|
|
{
|
|
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
|
|
return ParseBlock(ParseAttributeDeclarations(inExpressionContext: false));
|
|
}
|
|
|
|
private BlockSyntax ParseMethodOrAccessorBodyBlock(SyntaxList<AttributeListSyntax> attributes, bool isAccessorBody)
|
|
{
|
|
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
|
|
if (IsIncrementalAndFactoryContextMatches && base.CurrentNodeKind == SyntaxKind.Block && attributes.Count == 0)
|
|
{
|
|
return (BlockSyntax)(object)EatNode();
|
|
}
|
|
CSharpSyntaxNode previousNode = ((isAccessorBody && base.CurrentToken.Kind != SyntaxKind.OpenBraceToken) ? AddError(SyntaxFactory.MissingToken(SyntaxKind.OpenBraceToken), IsFeatureEnabled(MessageID.IDS_FeatureExpressionBodiedAccessor) ? ErrorCode.ERR_SemiOrLBraceOrArrowExpected : ErrorCode.ERR_SemiOrLBraceExpected) : EatToken(SyntaxKind.OpenBraceToken));
|
|
SyntaxListBuilder<StatementSyntax> val = _pool.Allocate<StatementSyntax>();
|
|
ParseStatements(ref previousNode, val, stopOnSwitchSections: false);
|
|
BlockSyntax result = _syntaxFactory.Block(attributes, (SyntaxToken)previousNode, IsLargeEnoughNonEmptyStatementList(val) ? new SyntaxList<StatementSyntax>(SyntaxList.List(SyntaxListBuilder<StatementSyntax>.op_Implicit(val).ToArray())) : SyntaxListBuilder<StatementSyntax>.op_Implicit(val), EatToken(SyntaxKind.CloseBraceToken));
|
|
_pool.Free(SyntaxListBuilder<StatementSyntax>.op_Implicit(val));
|
|
return result;
|
|
}
|
|
|
|
private BlockSyntax ParseBlock(SyntaxList<AttributeListSyntax> attributes)
|
|
{
|
|
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
|
|
if (IsIncrementalAndFactoryContextMatches && base.CurrentNodeKind == SyntaxKind.Block && attributes.Count == 0)
|
|
{
|
|
return (BlockSyntax)(object)EatNode();
|
|
}
|
|
CSharpSyntaxNode previousNode = EatToken(SyntaxKind.OpenBraceToken);
|
|
SyntaxListBuilder<StatementSyntax> val = _pool.Allocate<StatementSyntax>();
|
|
ParseStatements(ref previousNode, val, stopOnSwitchSections: false);
|
|
return _syntaxFactory.Block(attributes, (SyntaxToken)previousNode, _pool.ToListAndFree<StatementSyntax>(val), EatToken(SyntaxKind.CloseBraceToken));
|
|
}
|
|
|
|
private static bool IsLargeEnoughNonEmptyStatementList(SyntaxListBuilder<StatementSyntax> statements)
|
|
{
|
|
if (statements.Count == 0)
|
|
{
|
|
return false;
|
|
}
|
|
if (statements.Count == 1)
|
|
{
|
|
return ((GreenNode)statements[0]).Width > 60;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private void ParseStatements(ref CSharpSyntaxNode previousNode, SyntaxListBuilder<StatementSyntax> statements, bool stopOnSwitchSections)
|
|
{
|
|
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
|
|
TerminatorState termState = _termState;
|
|
_termState |= TerminatorState.IsPossibleStatementStartOrStop;
|
|
if (stopOnSwitchSections)
|
|
{
|
|
_termState |= TerminatorState.IsSwitchSectionStart;
|
|
}
|
|
int lastTokenPosition = -1;
|
|
PostSkipAction num;
|
|
do
|
|
{
|
|
IL_006f:
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
if (kind == SyntaxKind.CloseBraceToken || kind == SyntaxKind.EndOfFileToken || (stopOnSwitchSections && IsPossibleSwitchSection()) || !IsMakingProgress(ref lastTokenPosition))
|
|
{
|
|
break;
|
|
}
|
|
if (IsPossibleStatement(acceptAccessibilityMods: true))
|
|
{
|
|
StatementSyntax statementSyntax = ParsePossiblyAttributedStatement();
|
|
if (statementSyntax != null)
|
|
{
|
|
statements.Add(statementSyntax);
|
|
goto IL_006f;
|
|
}
|
|
}
|
|
num = SkipBadStatementListTokens(statements, SyntaxKind.CloseBraceToken, out var trailingTrivia);
|
|
if (trailingTrivia != null)
|
|
{
|
|
previousNode = AddTrailingSkippedSyntax(previousNode, trailingTrivia);
|
|
}
|
|
}
|
|
while (num != PostSkipAction.Abort);
|
|
_termState = termState;
|
|
}
|
|
|
|
private bool IsPossibleStatementStartOrStop()
|
|
{
|
|
if (base.CurrentToken.Kind != SyntaxKind.SemicolonToken)
|
|
{
|
|
return IsPossibleStatement(acceptAccessibilityMods: true);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private PostSkipAction SkipBadStatementListTokens(SyntaxListBuilder<StatementSyntax> statements, SyntaxKind expected, out GreenNode trailingTrivia)
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
return SkipBadListTokensWithExpectedKindHelper(SyntaxListBuilder<StatementSyntax>.op_Implicit(statements), (LanguageParser p) => !p.IsPossibleStatement(acceptAccessibilityMods: false), (LanguageParser p, SyntaxKind _) => p.CurrentToken.Kind == SyntaxKind.CloseBraceToken, expected, SyntaxKind.None, out trailingTrivia);
|
|
}
|
|
|
|
private bool IsPossibleStatement(bool acceptAccessibilityMods)
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
switch (kind)
|
|
{
|
|
case SyntaxKind.OpenBraceToken:
|
|
case SyntaxKind.OpenBracketToken:
|
|
case SyntaxKind.SemicolonToken:
|
|
case SyntaxKind.IfKeyword:
|
|
case SyntaxKind.ElseKeyword:
|
|
case SyntaxKind.WhileKeyword:
|
|
case SyntaxKind.ForKeyword:
|
|
case SyntaxKind.ForEachKeyword:
|
|
case SyntaxKind.DoKeyword:
|
|
case SyntaxKind.SwitchKeyword:
|
|
case SyntaxKind.CaseKeyword:
|
|
case SyntaxKind.TryKeyword:
|
|
case SyntaxKind.LockKeyword:
|
|
case SyntaxKind.GotoKeyword:
|
|
case SyntaxKind.BreakKeyword:
|
|
case SyntaxKind.ContinueKeyword:
|
|
case SyntaxKind.ReturnKeyword:
|
|
case SyntaxKind.ThrowKeyword:
|
|
case SyntaxKind.StaticKeyword:
|
|
case SyntaxKind.ReadOnlyKeyword:
|
|
case SyntaxKind.ConstKeyword:
|
|
case SyntaxKind.FixedKeyword:
|
|
case SyntaxKind.VolatileKeyword:
|
|
case SyntaxKind.ExternKeyword:
|
|
case SyntaxKind.RefKeyword:
|
|
case SyntaxKind.UsingKeyword:
|
|
case SyntaxKind.CheckedKeyword:
|
|
case SyntaxKind.UncheckedKeyword:
|
|
case SyntaxKind.UnsafeKeyword:
|
|
return true;
|
|
case SyntaxKind.IdentifierToken:
|
|
return IsTrueIdentifier();
|
|
case SyntaxKind.PublicKeyword:
|
|
case SyntaxKind.PrivateKeyword:
|
|
case SyntaxKind.InternalKeyword:
|
|
case SyntaxKind.ProtectedKeyword:
|
|
return acceptAccessibilityMods;
|
|
default:
|
|
if (!IsPredefinedType(kind))
|
|
{
|
|
return IsPossibleExpression();
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
|
|
private FixedStatementSyntax ParseFixedStatement(SyntaxList<AttributeListSyntax> attributes)
|
|
{
|
|
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxToken fixedKeyword = EatToken(SyntaxKind.FixedKeyword);
|
|
SyntaxToken openParenToken = EatToken(SyntaxKind.OpenParenToken);
|
|
TerminatorState termState = _termState;
|
|
_termState |= TerminatorState.IsEndOfFixedStatement;
|
|
VariableDeclarationSyntax declaration = ParseParenthesizedVariableDeclaration();
|
|
_termState = termState;
|
|
return _syntaxFactory.FixedStatement(attributes, fixedKeyword, openParenToken, declaration, EatToken(SyntaxKind.CloseParenToken), ParseEmbeddedStatement());
|
|
}
|
|
|
|
private bool IsEndOfFixedStatement()
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
if (kind == SyntaxKind.CloseParenToken || kind == SyntaxKind.OpenBraceToken || kind == SyntaxKind.SemicolonToken)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private StatementSyntax ParseEmbeddedStatement()
|
|
{
|
|
return parseEmbeddedStatementRest(ParsePossiblyAttributedStatement());
|
|
StatementSyntax parseEmbeddedStatementRest(StatementSyntax statement)
|
|
{
|
|
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
|
|
if (statement == null)
|
|
{
|
|
return SyntaxFactory.EmptyStatement(default(SyntaxList<AttributeListSyntax>), EatToken(SyntaxKind.SemicolonToken));
|
|
}
|
|
if (statement.Kind == SyntaxKind.ExpressionStatement && base.IsScript)
|
|
{
|
|
ExpressionStatementSyntax expressionStatementSyntax = (ExpressionStatementSyntax)statement;
|
|
SyntaxToken semicolonToken = expressionStatementSyntax.SemicolonToken;
|
|
if (((GreenNode)semicolonToken).IsMissing && !EnumerableExtensions.Contains<DiagnosticInfo>((IEnumerable<DiagnosticInfo>)((GreenNode)semicolonToken).GetDiagnostics(), (Func<DiagnosticInfo, bool>)((DiagnosticInfo diagnosticInfo) => diagnosticInfo.Code == 1002)))
|
|
{
|
|
semicolonToken = AddError(semicolonToken, ErrorCode.ERR_SemicolonExpected);
|
|
return expressionStatementSyntax.Update(expressionStatementSyntax.AttributeLists, expressionStatementSyntax.Expression, semicolonToken);
|
|
}
|
|
}
|
|
return statement;
|
|
}
|
|
}
|
|
|
|
private BreakStatementSyntax ParseBreakStatement(SyntaxList<AttributeListSyntax> attributes)
|
|
{
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
|
return _syntaxFactory.BreakStatement(attributes, EatToken(SyntaxKind.BreakKeyword), EatToken(SyntaxKind.SemicolonToken));
|
|
}
|
|
|
|
private ContinueStatementSyntax ParseContinueStatement(SyntaxList<AttributeListSyntax> attributes)
|
|
{
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
|
return _syntaxFactory.ContinueStatement(attributes, EatToken(SyntaxKind.ContinueKeyword), EatToken(SyntaxKind.SemicolonToken));
|
|
}
|
|
|
|
private TryStatementSyntax ParseTryStatement(SyntaxList<AttributeListSyntax> attributes)
|
|
{
|
|
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxToken syntaxToken = EatToken(SyntaxKind.TryKeyword);
|
|
BlockSyntax blockSyntax;
|
|
if (((GreenNode)syntaxToken).IsMissing)
|
|
{
|
|
blockSyntax = missingBlock();
|
|
}
|
|
else
|
|
{
|
|
TerminatorState termState = _termState;
|
|
_termState |= TerminatorState.IsEndOfTryBlock;
|
|
blockSyntax = ParsePossiblyAttributedBlock();
|
|
_termState = termState;
|
|
}
|
|
SyntaxListBuilder<CatchClauseSyntax> val = default(SyntaxListBuilder<CatchClauseSyntax>);
|
|
FinallyClauseSyntax finallyClauseSyntax = null;
|
|
if (base.CurrentToken.Kind == SyntaxKind.CatchKeyword)
|
|
{
|
|
val = _pool.Allocate<CatchClauseSyntax>();
|
|
while (base.CurrentToken.Kind == SyntaxKind.CatchKeyword)
|
|
{
|
|
val.Add(ParseCatchClause());
|
|
}
|
|
}
|
|
if (base.CurrentToken.Kind == SyntaxKind.FinallyKeyword)
|
|
{
|
|
finallyClauseSyntax = _syntaxFactory.FinallyClause(EatToken(), ParsePossiblyAttributedBlock());
|
|
}
|
|
if (val.IsNull && finallyClauseSyntax == null)
|
|
{
|
|
if (!ContainsErrorDiagnostic((GreenNode)(object)blockSyntax))
|
|
{
|
|
blockSyntax = AddErrorToLastToken(blockSyntax, ErrorCode.ERR_ExpectedEndTry);
|
|
}
|
|
finallyClauseSyntax = _syntaxFactory.FinallyClause(SyntaxFactory.MissingToken(SyntaxKind.FinallyKeyword), missingBlock());
|
|
}
|
|
return _syntaxFactory.TryStatement(attributes, syntaxToken, blockSyntax, _pool.ToListAndFree<CatchClauseSyntax>(val), finallyClauseSyntax);
|
|
BlockSyntax missingBlock()
|
|
{
|
|
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
|
|
return _syntaxFactory.Block(default(SyntaxList<AttributeListSyntax>), SyntaxFactory.MissingToken(SyntaxKind.OpenBraceToken), default(SyntaxList<StatementSyntax>), SyntaxFactory.MissingToken(SyntaxKind.CloseBraceToken));
|
|
}
|
|
}
|
|
|
|
private bool IsEndOfTryBlock()
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
if (kind == SyntaxKind.CloseBraceToken || kind - 8335 <= SyntaxKind.List)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private CatchClauseSyntax ParseCatchClause()
|
|
{
|
|
SyntaxToken catchKeyword = EatToken();
|
|
CatchDeclarationSyntax declaration = null;
|
|
TerminatorState termState = _termState;
|
|
if (base.CurrentToken.Kind == SyntaxKind.OpenParenToken)
|
|
{
|
|
SyntaxToken openParenToken = EatToken();
|
|
_termState |= TerminatorState.IsEndOfCatchClause;
|
|
TypeSyntax type = ParseType();
|
|
SyntaxToken identifier = null;
|
|
if (IsTrueIdentifier())
|
|
{
|
|
identifier = ParseIdentifierToken();
|
|
}
|
|
_termState = termState;
|
|
SyntaxToken closeParenToken = EatToken(SyntaxKind.CloseParenToken);
|
|
declaration = _syntaxFactory.CatchDeclaration(openParenToken, type, identifier, closeParenToken);
|
|
}
|
|
CatchFilterClauseSyntax filter = null;
|
|
SyntaxKind contextualKind = base.CurrentToken.ContextualKind;
|
|
if (contextualKind == SyntaxKind.WhenKeyword || contextualKind == SyntaxKind.IfKeyword)
|
|
{
|
|
SyntaxToken syntaxToken = EatContextualToken(SyntaxKind.WhenKeyword);
|
|
if (contextualKind == SyntaxKind.IfKeyword)
|
|
{
|
|
syntaxToken = AddTrailingSkippedSyntax(syntaxToken, (GreenNode)(object)EatToken());
|
|
}
|
|
_termState |= TerminatorState.IsEndOfFilterClause;
|
|
SyntaxToken openParenToken2 = EatToken(SyntaxKind.OpenParenToken);
|
|
ExpressionSyntax filterExpression = ParseExpressionCore();
|
|
_termState = termState;
|
|
SyntaxToken closeParenToken2 = EatToken(SyntaxKind.CloseParenToken);
|
|
filter = _syntaxFactory.CatchFilterClause(syntaxToken, openParenToken2, filterExpression, closeParenToken2);
|
|
}
|
|
_termState |= TerminatorState.IsEndOfCatchBlock;
|
|
BlockSyntax block = ParsePossiblyAttributedBlock();
|
|
_termState = termState;
|
|
return _syntaxFactory.CatchClause(catchKeyword, declaration, filter, block);
|
|
}
|
|
|
|
private bool IsEndOfCatchClause()
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
if (kind == SyntaxKind.CloseParenToken || kind - 8205 <= SyntaxKind.List || kind - 8335 <= SyntaxKind.List)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private bool IsEndOfFilterClause()
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
if (kind == SyntaxKind.CloseParenToken || kind - 8205 <= SyntaxKind.List || kind - 8335 <= SyntaxKind.List)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private bool IsEndOfCatchBlock()
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
if (kind == SyntaxKind.CloseBraceToken || kind - 8335 <= SyntaxKind.List)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private StatementSyntax ParseCheckedStatement(SyntaxList<AttributeListSyntax> attributes)
|
|
{
|
|
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
|
|
if (PeekToken(1).Kind == SyntaxKind.OpenParenToken)
|
|
{
|
|
return ParseExpressionStatement(attributes);
|
|
}
|
|
SyntaxToken syntaxToken = EatToken();
|
|
return _syntaxFactory.CheckedStatement(SyntaxFacts.GetCheckStatement(syntaxToken.Kind), attributes, syntaxToken, ParsePossiblyAttributedBlock());
|
|
}
|
|
|
|
private DoStatementSyntax ParseDoStatement(SyntaxList<AttributeListSyntax> attributes)
|
|
{
|
|
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxToken doKeyword = EatToken(SyntaxKind.DoKeyword);
|
|
StatementSyntax statement = ParseEmbeddedStatement();
|
|
SyntaxToken whileKeyword = EatToken(SyntaxKind.WhileKeyword);
|
|
SyntaxToken openParenToken = EatToken(SyntaxKind.OpenParenToken);
|
|
TerminatorState termState = _termState;
|
|
_termState |= TerminatorState.IsEndOfDoWhileExpression;
|
|
ExpressionSyntax condition = ParseExpressionCore();
|
|
_termState = termState;
|
|
return _syntaxFactory.DoStatement(attributes, doKeyword, statement, whileKeyword, openParenToken, condition, EatToken(SyntaxKind.CloseParenToken), EatToken(SyntaxKind.SemicolonToken));
|
|
}
|
|
|
|
private bool IsEndOfDoWhileExpression()
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
if (kind == SyntaxKind.CloseParenToken || kind == SyntaxKind.SemicolonToken)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private StatementSyntax ParseForOrForEachStatement(SyntaxList<AttributeListSyntax> attributes)
|
|
{
|
|
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
|
|
using DisposableResetPoint disposableResetPoint = GetDisposableResetPoint(resetOnDispose: false);
|
|
EatToken();
|
|
if (EatToken().Kind == SyntaxKind.OpenParenToken && ScanType() != ScanTypeFlags.NotType && EatToken().Kind == SyntaxKind.IdentifierToken && EatToken().Kind == SyntaxKind.InKeyword)
|
|
{
|
|
disposableResetPoint.Reset();
|
|
return ParseForEachStatement(attributes, null);
|
|
}
|
|
disposableResetPoint.Reset();
|
|
return ParseForStatement(attributes);
|
|
}
|
|
|
|
private ForStatementSyntax ParseForStatement(SyntaxList<AttributeListSyntax> attributes)
|
|
{
|
|
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxToken forKeyword = EatToken(SyntaxKind.ForKeyword);
|
|
SyntaxToken startToken = EatToken(SyntaxKind.OpenParenToken);
|
|
TerminatorState termState = _termState;
|
|
_termState |= TerminatorState.IsEndOfForStatementArgument;
|
|
ResetPoint state = GetResetPoint();
|
|
SeparatedSyntaxList<ExpressionSyntax> initializers = default(SeparatedSyntaxList<ExpressionSyntax>);
|
|
SeparatedSyntaxList<ExpressionSyntax> incrementors = default(SeparatedSyntaxList<ExpressionSyntax>);
|
|
try
|
|
{
|
|
VariableDeclarationSyntax variableDeclarationSyntax = null;
|
|
bool flag = false;
|
|
bool flag2 = false;
|
|
if (base.CurrentToken.ContextualKind == SyntaxKind.ScopedKeyword)
|
|
{
|
|
if (PeekToken(1).Kind == SyntaxKind.RefKeyword)
|
|
{
|
|
flag = true;
|
|
}
|
|
else
|
|
{
|
|
EatToken();
|
|
flag = ScanType() != ScanTypeFlags.NotType && base.CurrentToken.Kind == SyntaxKind.IdentifierToken;
|
|
Reset(ref state);
|
|
}
|
|
flag2 = flag;
|
|
}
|
|
else if (base.CurrentToken.Kind == SyntaxKind.RefKeyword)
|
|
{
|
|
flag = true;
|
|
}
|
|
if (!flag)
|
|
{
|
|
flag = !IsQueryExpression(mayBeVariableDeclaration: true, mayBeMemberDeclaration: false) && ScanType() != ScanTypeFlags.NotType && IsTrueIdentifier();
|
|
Reset(ref state);
|
|
}
|
|
if (flag)
|
|
{
|
|
SyntaxToken syntaxToken = null;
|
|
if (flag2)
|
|
{
|
|
syntaxToken = EatContextualToken(SyntaxKind.ScopedKeyword);
|
|
}
|
|
variableDeclarationSyntax = ParseParenthesizedVariableDeclaration();
|
|
TypeSyntax typeSyntax = variableDeclarationSyntax.Type;
|
|
if (syntaxToken != null)
|
|
{
|
|
typeSyntax = _syntaxFactory.ScopedType(syntaxToken, typeSyntax);
|
|
}
|
|
if (typeSyntax != variableDeclarationSyntax.Type)
|
|
{
|
|
variableDeclarationSyntax = variableDeclarationSyntax.Update(typeSyntax, variableDeclarationSyntax.Variables);
|
|
}
|
|
}
|
|
else if (base.CurrentToken.Kind != SyntaxKind.SemicolonToken)
|
|
{
|
|
initializers = ParseForStatementExpressionList(ref startToken);
|
|
}
|
|
SyntaxToken firstSemicolonToken = EatToken(SyntaxKind.SemicolonToken);
|
|
ExpressionSyntax condition = null;
|
|
if (base.CurrentToken.Kind != SyntaxKind.SemicolonToken)
|
|
{
|
|
condition = ParseExpressionCore();
|
|
}
|
|
SyntaxToken startToken2 = EatToken(SyntaxKind.SemicolonToken);
|
|
if (base.CurrentToken.Kind != SyntaxKind.CloseParenToken)
|
|
{
|
|
incrementors = ParseForStatementExpressionList(ref startToken2);
|
|
}
|
|
return _syntaxFactory.ForStatement(attributes, forKeyword, startToken, variableDeclarationSyntax, initializers, firstSemicolonToken, condition, startToken2, incrementors, EatToken(SyntaxKind.CloseParenToken), ParseEmbeddedStatement());
|
|
}
|
|
finally
|
|
{
|
|
_termState = termState;
|
|
Release(ref state);
|
|
}
|
|
}
|
|
|
|
private bool IsEndOfForStatementArgument()
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
if (kind == SyntaxKind.CloseParenToken || kind == SyntaxKind.OpenBraceToken || kind == SyntaxKind.SemicolonToken)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private SeparatedSyntaxList<ExpressionSyntax> ParseForStatementExpressionList(ref SyntaxToken startToken)
|
|
{
|
|
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
|
|
return ParseCommaSeparatedSyntaxList(ref startToken, SyntaxKind.CloseParenToken, (LanguageParser @this) => @this.IsPossibleExpression(), (LanguageParser @this) => @this.ParseExpressionCore(), skipBadForStatementExpressionListTokens, allowTrailingSeparator: false, requireOneElement: false, allowSemicolonAsSeparator: false);
|
|
static PostSkipAction skipBadForStatementExpressionListTokens(LanguageParser @this, ref SyntaxToken startToken2, SeparatedSyntaxListBuilder<ExpressionSyntax> list, SyntaxKind expectedKind, SyntaxKind closeKind)
|
|
{
|
|
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxKind kind = @this.CurrentToken.Kind;
|
|
if ((kind == SyntaxKind.CloseParenToken || kind == SyntaxKind.SemicolonToken) ? true : false)
|
|
{
|
|
return PostSkipAction.Abort;
|
|
}
|
|
return @this.SkipBadSeparatedListTokensWithExpectedKind<SyntaxToken, ExpressionSyntax>(ref startToken2, list, (LanguageParser p) => p.CurrentToken.Kind != SyntaxKind.CommaToken && !p.IsPossibleExpression(), (LanguageParser p, SyntaxKind syntaxKind) => p.CurrentToken.Kind == syntaxKind || p.CurrentToken.Kind == SyntaxKind.SemicolonToken, expectedKind, closeKind);
|
|
}
|
|
}
|
|
|
|
private CommonForEachStatementSyntax ParseForEachStatement(SyntaxList<AttributeListSyntax> attributes, SyntaxToken awaitTokenOpt)
|
|
{
|
|
//IL_0199: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0179: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxToken forEachKeyword;
|
|
if (base.CurrentToken.Kind == SyntaxKind.ForKeyword)
|
|
{
|
|
SyntaxToken node = EatToken();
|
|
node = AddError(node, ErrorCode.ERR_SyntaxError, SyntaxFacts.GetText(SyntaxKind.ForEachKeyword));
|
|
forEachKeyword = ConvertToMissingWithTrailingTrivia(node, SyntaxKind.ForEachKeyword);
|
|
}
|
|
else
|
|
{
|
|
forEachKeyword = EatToken(SyntaxKind.ForEachKeyword);
|
|
}
|
|
SyntaxToken openParenToken = EatToken(SyntaxKind.OpenParenToken);
|
|
ExpressionSyntax expressionSyntax = ParseExpressionOrDeclaration(ParseTypeMode.Normal, permitTupleDesignation: true);
|
|
SyntaxToken syntaxToken = EatToken(SyntaxKind.InKeyword, ErrorCode.ERR_InExpected);
|
|
if (!IsValidForeachVariable(expressionSyntax))
|
|
{
|
|
syntaxToken = AddError(syntaxToken, ErrorCode.ERR_BadForeachDecl);
|
|
}
|
|
ExpressionSyntax expression = ParseExpressionCore();
|
|
SyntaxToken closeParenToken = EatToken(SyntaxKind.CloseParenToken);
|
|
StatementSyntax statement = ParseEmbeddedStatement();
|
|
if (expressionSyntax is DeclarationExpressionSyntax declarationExpressionSyntax && declarationExpressionSyntax.designation.Kind != SyntaxKind.ParenthesizedVariableDesignation)
|
|
{
|
|
SyntaxToken identifier;
|
|
switch (declarationExpressionSyntax.designation.Kind)
|
|
{
|
|
case SyntaxKind.SingleVariableDesignation:
|
|
identifier = ((SingleVariableDesignationSyntax)declarationExpressionSyntax.designation).identifier;
|
|
break;
|
|
case SyntaxKind.DiscardDesignation:
|
|
{
|
|
SyntaxToken underscoreToken = ((DiscardDesignationSyntax)declarationExpressionSyntax.designation).underscoreToken;
|
|
identifier = SyntaxToken.WithValue(SyntaxKind.IdentifierToken, underscoreToken.LeadingTrivia.Node, underscoreToken.Text, underscoreToken.ValueText, underscoreToken.TrailingTrivia.Node);
|
|
break;
|
|
}
|
|
default:
|
|
throw ExceptionUtilities.UnexpectedValue((object)declarationExpressionSyntax.designation.Kind);
|
|
}
|
|
return _syntaxFactory.ForEachStatement(attributes, awaitTokenOpt, forEachKeyword, openParenToken, declarationExpressionSyntax.Type, identifier, syntaxToken, expression, closeParenToken, statement);
|
|
}
|
|
return _syntaxFactory.ForEachVariableStatement(attributes, awaitTokenOpt, forEachKeyword, openParenToken, expressionSyntax, syntaxToken, expression, closeParenToken, statement);
|
|
}
|
|
|
|
private ExpressionSyntax ParseExpressionOrDeclaration(ParseTypeMode mode, bool permitTupleDesignation)
|
|
{
|
|
if (!IsPossibleDeclarationExpression(mode, permitTupleDesignation, out var isScoped))
|
|
{
|
|
return ParseSubExpression(Precedence.Expression);
|
|
}
|
|
return ParseDeclarationExpression(mode, isScoped);
|
|
}
|
|
|
|
private bool IsPossibleDeclarationExpression(ParseTypeMode mode, bool permitTupleDesignation, out bool isScoped)
|
|
{
|
|
isScoped = false;
|
|
if (IsInAsync && base.CurrentToken.ContextualKind == SyntaxKind.AwaitKeyword)
|
|
{
|
|
return false;
|
|
}
|
|
using DisposableResetPoint disposableResetPoint = GetDisposableResetPoint(resetOnDispose: true);
|
|
if (base.CurrentToken.ContextualKind == SyntaxKind.ScopedKeyword)
|
|
{
|
|
EatToken();
|
|
if (ScanType() != ScanTypeFlags.NotType && base.CurrentToken.Kind == SyntaxKind.IdentifierToken)
|
|
{
|
|
switch (mode)
|
|
{
|
|
case ParseTypeMode.FirstElementOfPossibleTupleLiteral:
|
|
if (PeekToken(1).Kind == SyntaxKind.CommaToken)
|
|
{
|
|
isScoped = true;
|
|
return true;
|
|
}
|
|
break;
|
|
case ParseTypeMode.AfterTupleComma:
|
|
{
|
|
SyntaxKind kind = PeekToken(1).Kind;
|
|
if ((kind == SyntaxKind.CloseParenToken || kind == SyntaxKind.CommaToken) ? true : false)
|
|
{
|
|
isScoped = true;
|
|
return true;
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
isScoped = true;
|
|
return true;
|
|
}
|
|
}
|
|
disposableResetPoint.Reset();
|
|
}
|
|
bool flag = IsVarType();
|
|
if (ScanType(mode, out var lastTokenOfType) == ScanTypeFlags.NotType)
|
|
{
|
|
return false;
|
|
}
|
|
if (!ScanDesignation(permitTupleDesignation && (flag || IsPredefinedType(lastTokenOfType.Kind))))
|
|
{
|
|
return false;
|
|
}
|
|
switch (mode)
|
|
{
|
|
case ParseTypeMode.FirstElementOfPossibleTupleLiteral:
|
|
return base.CurrentToken.Kind == SyntaxKind.CommaToken;
|
|
case ParseTypeMode.AfterTupleComma:
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
return (kind == SyntaxKind.CloseParenToken || kind == SyntaxKind.CommaToken) ? true : false;
|
|
}
|
|
default:
|
|
return true;
|
|
}
|
|
}
|
|
|
|
private bool IsVarType()
|
|
{
|
|
if (!base.CurrentToken.IsIdentifierVar())
|
|
{
|
|
return false;
|
|
}
|
|
switch (PeekToken(1).Kind)
|
|
{
|
|
case SyntaxKind.AsteriskToken:
|
|
case SyntaxKind.OpenBracketToken:
|
|
case SyntaxKind.LessThanToken:
|
|
case SyntaxKind.DotToken:
|
|
case SyntaxKind.QuestionToken:
|
|
case SyntaxKind.ColonColonToken:
|
|
return false;
|
|
default:
|
|
return true;
|
|
}
|
|
}
|
|
|
|
private static bool IsValidForeachVariable(ExpressionSyntax variable)
|
|
{
|
|
return variable.Kind switch
|
|
{
|
|
SyntaxKind.DeclarationExpression => true,
|
|
SyntaxKind.TupleExpression => true,
|
|
SyntaxKind.IdentifierName => ((IdentifierNameSyntax)variable).Identifier.ContextualKind == SyntaxKind.UnderscoreToken,
|
|
_ => false,
|
|
};
|
|
}
|
|
|
|
private GotoStatementSyntax ParseGotoStatement(SyntaxList<AttributeListSyntax> attributes)
|
|
{
|
|
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxToken gotoKeyword = EatToken(SyntaxKind.GotoKeyword);
|
|
SyntaxToken syntaxToken = null;
|
|
ExpressionSyntax expression = null;
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
SyntaxKind kind2;
|
|
if (kind - 8332 <= SyntaxKind.List)
|
|
{
|
|
syntaxToken = EatToken();
|
|
if (syntaxToken.Kind == SyntaxKind.CaseKeyword)
|
|
{
|
|
kind2 = SyntaxKind.GotoCaseStatement;
|
|
expression = ParseExpressionCore();
|
|
}
|
|
else
|
|
{
|
|
kind2 = SyntaxKind.GotoDefaultStatement;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
kind2 = SyntaxKind.GotoStatement;
|
|
expression = ParseIdentifierName();
|
|
}
|
|
return _syntaxFactory.GotoStatement(kind2, attributes, gotoKeyword, syntaxToken, expression, EatToken(SyntaxKind.SemicolonToken));
|
|
}
|
|
|
|
private IfStatementSyntax ParseIfStatement(SyntaxList<AttributeListSyntax> attributes)
|
|
{
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
|
return _syntaxFactory.IfStatement(attributes, EatToken(SyntaxKind.IfKeyword), EatToken(SyntaxKind.OpenParenToken), ParseExpressionCore(), EatToken(SyntaxKind.CloseParenToken), ParseEmbeddedStatement(), ParseElseClauseOpt());
|
|
}
|
|
|
|
private IfStatementSyntax ParseMisplacedElse(SyntaxList<AttributeListSyntax> attributes)
|
|
{
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
|
|
return _syntaxFactory.IfStatement(attributes, EatToken(SyntaxKind.IfKeyword, ErrorCode.ERR_ElseCannotStartStatement), EatToken(SyntaxKind.OpenParenToken), ParseExpressionCore(), EatToken(SyntaxKind.CloseParenToken), ParseExpressionStatement(default(SyntaxList<AttributeListSyntax>)), ParseElseClauseOpt());
|
|
}
|
|
|
|
private ElseClauseSyntax ParseElseClauseOpt()
|
|
{
|
|
if (base.CurrentToken.Kind == SyntaxKind.ElseKeyword)
|
|
{
|
|
return _syntaxFactory.ElseClause(EatToken(SyntaxKind.ElseKeyword), ParseEmbeddedStatement());
|
|
}
|
|
return null;
|
|
}
|
|
|
|
private LockStatementSyntax ParseLockStatement(SyntaxList<AttributeListSyntax> attributes)
|
|
{
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
|
return _syntaxFactory.LockStatement(attributes, EatToken(SyntaxKind.LockKeyword), EatToken(SyntaxKind.OpenParenToken), ParseExpressionCore(), EatToken(SyntaxKind.CloseParenToken), ParseEmbeddedStatement());
|
|
}
|
|
|
|
private ReturnStatementSyntax ParseReturnStatement(SyntaxList<AttributeListSyntax> attributes)
|
|
{
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
|
return _syntaxFactory.ReturnStatement(attributes, EatToken(SyntaxKind.ReturnKeyword), (base.CurrentToken.Kind != SyntaxKind.SemicolonToken) ? ParsePossibleRefExpression() : null, EatToken(SyntaxKind.SemicolonToken));
|
|
}
|
|
|
|
private YieldStatementSyntax ParseYieldStatement(SyntaxList<AttributeListSyntax> attributes)
|
|
{
|
|
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxToken yieldKeyword = SyntaxParser.ConvertToKeyword(EatToken());
|
|
ExpressionSyntax expression = null;
|
|
SyntaxKind kind;
|
|
SyntaxToken syntaxToken;
|
|
if (base.CurrentToken.Kind == SyntaxKind.BreakKeyword)
|
|
{
|
|
kind = SyntaxKind.YieldBreakStatement;
|
|
syntaxToken = EatToken();
|
|
}
|
|
else
|
|
{
|
|
kind = SyntaxKind.YieldReturnStatement;
|
|
syntaxToken = EatToken(SyntaxKind.ReturnKeyword);
|
|
if (base.CurrentToken.Kind == SyntaxKind.SemicolonToken)
|
|
{
|
|
syntaxToken = AddError(syntaxToken, ErrorCode.ERR_EmptyYield);
|
|
}
|
|
else
|
|
{
|
|
expression = ParseExpressionCore();
|
|
}
|
|
}
|
|
return _syntaxFactory.YieldStatement(kind, attributes, yieldKeyword, syntaxToken, expression, EatToken(SyntaxKind.SemicolonToken));
|
|
}
|
|
|
|
private SwitchStatementSyntax ParseSwitchStatement(SyntaxList<AttributeListSyntax> attributes)
|
|
{
|
|
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
|
|
parseSwitchHeader(out var switchKeyword, out var openParen, out var expression, out var closeParen, out var openBrace);
|
|
SyntaxListBuilder<SwitchSectionSyntax> val = _pool.Allocate<SwitchSectionSyntax>();
|
|
while (IsPossibleSwitchSection())
|
|
{
|
|
val.Add(ParseSwitchSection());
|
|
}
|
|
return _syntaxFactory.SwitchStatement(attributes, switchKeyword, openParen, expression, closeParen, openBrace, _pool.ToListAndFree<SwitchSectionSyntax>(val), EatToken(SyntaxKind.CloseBraceToken));
|
|
void parseSwitchHeader(out SyntaxToken reference, out SyntaxToken reference2, out ExpressionSyntax reference3, out SyntaxToken reference4, out SyntaxToken reference5)
|
|
{
|
|
if (base.CurrentToken.Kind == SyntaxKind.CaseKeyword)
|
|
{
|
|
reference = EatToken(SyntaxKind.SwitchKeyword);
|
|
reference2 = SyntaxFactory.MissingToken(SyntaxKind.OpenParenToken);
|
|
reference3 = CreateMissingIdentifierName();
|
|
reference4 = SyntaxFactory.MissingToken(SyntaxKind.CloseParenToken);
|
|
reference5 = SyntaxFactory.MissingToken(SyntaxKind.OpenBraceToken);
|
|
}
|
|
else
|
|
{
|
|
reference = EatToken(SyntaxKind.SwitchKeyword);
|
|
reference3 = ParseExpressionCore();
|
|
if (reference3.Kind == SyntaxKind.ParenthesizedExpression)
|
|
{
|
|
ParenthesizedExpressionSyntax parenthesizedExpressionSyntax = (ParenthesizedExpressionSyntax)reference3;
|
|
reference2 = parenthesizedExpressionSyntax.OpenParenToken;
|
|
reference3 = parenthesizedExpressionSyntax.Expression;
|
|
reference4 = parenthesizedExpressionSyntax.CloseParenToken;
|
|
}
|
|
else if (reference3.Kind == SyntaxKind.TupleExpression)
|
|
{
|
|
reference2 = (reference4 = null);
|
|
}
|
|
else
|
|
{
|
|
reference2 = SyntaxFactory.MissingToken(SyntaxKind.OpenParenToken);
|
|
reference3 = AddError(reference3, ErrorCode.ERR_SwitchGoverningExpressionRequiresParens);
|
|
reference4 = SyntaxFactory.MissingToken(SyntaxKind.CloseParenToken);
|
|
}
|
|
reference5 = EatToken(SyntaxKind.OpenBraceToken);
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool IsPossibleSwitchSection()
|
|
{
|
|
if (base.CurrentToken.Kind != SyntaxKind.CaseKeyword)
|
|
{
|
|
if (base.CurrentToken.Kind == SyntaxKind.DefaultKeyword)
|
|
{
|
|
return PeekToken(1).Kind != SyntaxKind.OpenParenToken;
|
|
}
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private SwitchSectionSyntax ParseSwitchSection()
|
|
{
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0193: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxListBuilder<SwitchLabelSyntax> val = _pool.Allocate<SwitchLabelSyntax>();
|
|
SyntaxListBuilder<StatementSyntax> val2 = _pool.Allocate<StatementSyntax>();
|
|
do
|
|
{
|
|
SwitchLabelSyntax switchLabelSyntax;
|
|
if (base.CurrentToken.Kind == SyntaxKind.CaseKeyword)
|
|
{
|
|
SyntaxToken keyword = EatToken();
|
|
if (base.CurrentToken.Kind == SyntaxKind.ColonToken)
|
|
{
|
|
switchLabelSyntax = _syntaxFactory.CaseSwitchLabel(keyword, ParseIdentifierName(ErrorCode.ERR_ConstantExpected), EatToken(SyntaxKind.ColonToken));
|
|
}
|
|
else
|
|
{
|
|
CSharpSyntaxNode cSharpSyntaxNode = ParseExpressionOrPatternForSwitchStatement();
|
|
if (base.CurrentToken.ContextualKind == SyntaxKind.WhenKeyword && cSharpSyntaxNode is ExpressionSyntax expression)
|
|
{
|
|
cSharpSyntaxNode = _syntaxFactory.ConstantPattern(expression);
|
|
}
|
|
if (cSharpSyntaxNode.Kind == SyntaxKind.DiscardPattern)
|
|
{
|
|
cSharpSyntaxNode = AddError(cSharpSyntaxNode, ErrorCode.ERR_DiscardPatternInSwitchStatement);
|
|
}
|
|
switchLabelSyntax = ((!(cSharpSyntaxNode is PatternSyntax pattern)) ? ((SwitchLabelSyntax)_syntaxFactory.CaseSwitchLabel(keyword, (ExpressionSyntax)cSharpSyntaxNode, EatToken(SyntaxKind.ColonToken))) : ((SwitchLabelSyntax)_syntaxFactory.CasePatternSwitchLabel(keyword, pattern, ParseWhenClause(Precedence.Expression), EatToken(SyntaxKind.ColonToken))));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
switchLabelSyntax = _syntaxFactory.DefaultSwitchLabel(EatToken(SyntaxKind.DefaultKeyword), EatToken(SyntaxKind.ColonToken));
|
|
}
|
|
val.Add(switchLabelSyntax);
|
|
}
|
|
while (IsPossibleSwitchSection());
|
|
CSharpSyntaxNode previousNode = val[val.Count - 1];
|
|
ParseStatements(ref previousNode, val2, stopOnSwitchSections: true);
|
|
val[val.Count - 1] = (SwitchLabelSyntax)previousNode;
|
|
return _syntaxFactory.SwitchSection(_pool.ToListAndFree<SwitchLabelSyntax>(val), _pool.ToListAndFree<StatementSyntax>(val2));
|
|
}
|
|
|
|
private ThrowStatementSyntax ParseThrowStatement(SyntaxList<AttributeListSyntax> attributes)
|
|
{
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
|
return _syntaxFactory.ThrowStatement(attributes, EatToken(SyntaxKind.ThrowKeyword), (base.CurrentToken.Kind != SyntaxKind.SemicolonToken) ? ParseExpressionCore() : null, EatToken(SyntaxKind.SemicolonToken));
|
|
}
|
|
|
|
private UnsafeStatementSyntax ParseUnsafeStatement(SyntaxList<AttributeListSyntax> attributes)
|
|
{
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
|
return _syntaxFactory.UnsafeStatement(attributes, EatToken(SyntaxKind.UnsafeKeyword), ParsePossiblyAttributedBlock());
|
|
}
|
|
|
|
private UsingStatementSyntax ParseUsingStatement(SyntaxList<AttributeListSyntax> attributes, SyntaxToken awaitTokenOpt = null)
|
|
{
|
|
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxToken usingKeyword = EatToken(SyntaxKind.UsingKeyword);
|
|
SyntaxToken openParenToken = EatToken(SyntaxKind.OpenParenToken);
|
|
VariableDeclarationSyntax declaration = null;
|
|
ExpressionSyntax expression = null;
|
|
ResetPoint resetPoint = GetResetPoint();
|
|
ParseUsingExpression(ref declaration, ref expression, ref resetPoint);
|
|
Release(ref resetPoint);
|
|
return _syntaxFactory.UsingStatement(attributes, awaitTokenOpt, usingKeyword, openParenToken, declaration, expression, EatToken(SyntaxKind.CloseParenToken), ParseEmbeddedStatement());
|
|
}
|
|
|
|
private void ParseUsingExpression(ref VariableDeclarationSyntax declaration, ref ExpressionSyntax expression, ref ResetPoint resetPoint)
|
|
{
|
|
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
|
|
if (IsAwaitExpression())
|
|
{
|
|
expression = ParseExpressionCore();
|
|
return;
|
|
}
|
|
ScanTypeFlags scanTypeFlags;
|
|
if (IsQueryExpression(mayBeVariableDeclaration: true, mayBeMemberDeclaration: false))
|
|
{
|
|
scanTypeFlags = ScanTypeFlags.NotType;
|
|
}
|
|
else
|
|
{
|
|
SyntaxToken syntaxToken = ParsePossibleScopedKeyword(isFunctionPointerParameter: false);
|
|
if (syntaxToken != null)
|
|
{
|
|
declaration = ParseParenthesizedVariableDeclaration();
|
|
declaration = declaration.Update(_syntaxFactory.ScopedType(syntaxToken, declaration.Type), declaration.Variables);
|
|
return;
|
|
}
|
|
scanTypeFlags = ScanType();
|
|
}
|
|
if (scanTypeFlags == ScanTypeFlags.NullableType)
|
|
{
|
|
if (base.CurrentToken.Kind != SyntaxKind.IdentifierToken)
|
|
{
|
|
Reset(ref resetPoint);
|
|
expression = ParseExpressionCore();
|
|
return;
|
|
}
|
|
switch (PeekToken(1).Kind)
|
|
{
|
|
default:
|
|
Reset(ref resetPoint);
|
|
expression = ParseExpressionCore();
|
|
break;
|
|
case SyntaxKind.CloseParenToken:
|
|
case SyntaxKind.CommaToken:
|
|
Reset(ref resetPoint);
|
|
declaration = ParseParenthesizedVariableDeclaration();
|
|
break;
|
|
case SyntaxKind.EqualsToken:
|
|
Reset(ref resetPoint);
|
|
declaration = ParseParenthesizedVariableDeclaration();
|
|
if (base.CurrentToken.Kind == SyntaxKind.ColonToken && declaration.Type.Kind == SyntaxKind.NullableType && SyntaxFacts.IsName(((NullableTypeSyntax)declaration.Type).ElementType.Kind) && declaration.Variables.Count == 1)
|
|
{
|
|
Reset(ref resetPoint);
|
|
declaration = null;
|
|
expression = ParseExpressionCore();
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
else if (IsUsingStatementVariableDeclaration(scanTypeFlags))
|
|
{
|
|
Reset(ref resetPoint);
|
|
declaration = ParseParenthesizedVariableDeclaration();
|
|
}
|
|
else
|
|
{
|
|
Reset(ref resetPoint);
|
|
expression = ParseExpressionCore();
|
|
}
|
|
}
|
|
|
|
private bool IsUsingStatementVariableDeclaration(ScanTypeFlags st)
|
|
{
|
|
bool num = st == ScanTypeFlags.MustBeType && base.CurrentToken.Kind != SyntaxKind.DotToken;
|
|
bool flag = st != ScanTypeFlags.NotType && base.CurrentToken.Kind == SyntaxKind.IdentifierToken;
|
|
bool flag2 = st == ScanTypeFlags.NonGenericTypeOrExpression || PeekToken(1).Kind == SyntaxKind.EqualsToken;
|
|
if (!num)
|
|
{
|
|
return flag && flag2;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private WhileStatementSyntax ParseWhileStatement(SyntaxList<AttributeListSyntax> attributes)
|
|
{
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
|
return _syntaxFactory.WhileStatement(attributes, EatToken(SyntaxKind.WhileKeyword), EatToken(SyntaxKind.OpenParenToken), ParseExpressionCore(), EatToken(SyntaxKind.CloseParenToken), ParseEmbeddedStatement());
|
|
}
|
|
|
|
private LabeledStatementSyntax ParseLabeledStatement(SyntaxList<AttributeListSyntax> attributes)
|
|
{
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
|
|
return _syntaxFactory.LabeledStatement(attributes, ParseIdentifierToken(), EatToken(SyntaxKind.ColonToken), ParsePossiblyAttributedStatement() ?? SyntaxFactory.EmptyStatement(default(SyntaxList<AttributeListSyntax>), EatToken(SyntaxKind.SemicolonToken)));
|
|
}
|
|
|
|
private StatementSyntax ParseLocalDeclarationStatement(SyntaxList<AttributeListSyntax> attributes)
|
|
{
|
|
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
|
|
bool flag = false;
|
|
SyntaxToken awaitKeyword;
|
|
SyntaxToken usingKeyword;
|
|
if (IsPossibleAwaitUsing())
|
|
{
|
|
awaitKeyword = EatContextualToken(SyntaxKind.AwaitKeyword);
|
|
usingKeyword = EatToken();
|
|
}
|
|
else if (base.CurrentToken.Kind == SyntaxKind.UsingKeyword)
|
|
{
|
|
awaitKeyword = null;
|
|
usingKeyword = EatToken();
|
|
}
|
|
else
|
|
{
|
|
awaitKeyword = null;
|
|
usingKeyword = null;
|
|
flag = true;
|
|
}
|
|
SyntaxListBuilder val = _pool.Allocate();
|
|
ParseDeclarationModifiers(val);
|
|
SeparatedSyntaxListBuilder<VariableDeclaratorSyntax> variables = _pool.AllocateSeparated<VariableDeclaratorSyntax>();
|
|
try
|
|
{
|
|
SyntaxToken syntaxToken = ParsePossibleScopedKeyword(isFunctionPointerParameter: false);
|
|
if (syntaxToken != null)
|
|
{
|
|
val.Add((GreenNode)(object)syntaxToken);
|
|
}
|
|
ParseLocalDeclaration(variables, flag, stopOnCloseParen: false, attributes, SyntaxList<SyntaxToken>.op_Implicit(val.ToList()), out var type, out var localFunction);
|
|
if (localFunction != null)
|
|
{
|
|
return localFunction;
|
|
}
|
|
if (flag && attributes.Count == 0 && val.Count > 0 && IsAccessibilityModifier(((SyntaxToken)(object)val[0]).ContextualKind))
|
|
{
|
|
return null;
|
|
}
|
|
if (syntaxToken != null)
|
|
{
|
|
val.RemoveLast();
|
|
type = _syntaxFactory.ScopedType(syntaxToken, type);
|
|
}
|
|
for (int i = 0; i < val.Count; i++)
|
|
{
|
|
SyntaxToken syntaxToken2 = (SyntaxToken)(object)val[i];
|
|
if (IsAdditionalLocalFunctionModifier(syntaxToken2.ContextualKind))
|
|
{
|
|
val[i] = (GreenNode)(object)AddError(syntaxToken2, ErrorCode.ERR_BadMemberFlag, syntaxToken2.Text);
|
|
}
|
|
}
|
|
return _syntaxFactory.LocalDeclarationStatement(attributes, awaitKeyword, usingKeyword, SyntaxList<SyntaxToken>.op_Implicit(val.ToList()), _syntaxFactory.VariableDeclaration(type, _pool.ToListAndFree<VariableDeclaratorSyntax>(ref variables)), EatToken(SyntaxKind.SemicolonToken));
|
|
}
|
|
finally
|
|
{
|
|
_pool.Free(val);
|
|
}
|
|
}
|
|
|
|
private SyntaxToken ParsePossibleScopedKeyword(bool isFunctionPointerParameter)
|
|
{
|
|
if (base.CurrentToken.ContextualKind == SyntaxKind.ScopedKeyword)
|
|
{
|
|
using (DisposableResetPoint disposableResetPoint = GetDisposableResetPoint(resetOnDispose: false))
|
|
{
|
|
SyntaxToken result = EatContextualToken(SyntaxKind.ScopedKeyword);
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
if (kind - 8360 > (SyntaxKind)2)
|
|
{
|
|
using DisposableResetPoint disposableResetPoint2 = GetDisposableResetPoint(resetOnDispose: false);
|
|
bool flag = ScanType() == ScanTypeFlags.NotType;
|
|
if (!flag)
|
|
{
|
|
bool flag3;
|
|
if (isFunctionPointerParameter)
|
|
{
|
|
kind = base.CurrentToken.Kind;
|
|
bool flag2 = kind - 8216 <= SyntaxKind.List;
|
|
flag3 = !flag2;
|
|
}
|
|
else
|
|
{
|
|
flag3 = base.CurrentToken.Kind != SyntaxKind.IdentifierToken;
|
|
}
|
|
flag = flag3;
|
|
}
|
|
if (flag)
|
|
{
|
|
disposableResetPoint.Reset();
|
|
return null;
|
|
}
|
|
disposableResetPoint2.Reset();
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
private VariableDesignationSyntax ParseDesignation(bool forPattern)
|
|
{
|
|
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
|
|
if (base.CurrentToken.Kind == SyntaxKind.OpenParenToken)
|
|
{
|
|
SyntaxToken openParenToken = EatToken(SyntaxKind.OpenParenToken);
|
|
SeparatedSyntaxListBuilder<VariableDesignationSyntax> val = _pool.AllocateSeparated<VariableDesignationSyntax>();
|
|
bool flag = false;
|
|
if (forPattern)
|
|
{
|
|
flag = base.CurrentToken.Kind == SyntaxKind.CloseParenToken;
|
|
}
|
|
else
|
|
{
|
|
val.Add(ParseDesignation(forPattern));
|
|
val.AddSeparator((GreenNode)(object)EatToken(SyntaxKind.CommaToken));
|
|
}
|
|
if (!flag)
|
|
{
|
|
while (true)
|
|
{
|
|
val.Add(ParseDesignation(forPattern));
|
|
if (base.CurrentToken.Kind != SyntaxKind.CommaToken)
|
|
{
|
|
break;
|
|
}
|
|
val.AddSeparator((GreenNode)(object)EatToken(SyntaxKind.CommaToken));
|
|
}
|
|
}
|
|
return _syntaxFactory.ParenthesizedVariableDesignation(openParenToken, _pool.ToListAndFree<VariableDesignationSyntax>(ref val), EatToken(SyntaxKind.CloseParenToken));
|
|
}
|
|
return ParseSimpleDesignation();
|
|
}
|
|
|
|
private VariableDesignationSyntax ParseSimpleDesignation()
|
|
{
|
|
if (base.CurrentToken.ContextualKind != SyntaxKind.UnderscoreToken)
|
|
{
|
|
return _syntaxFactory.SingleVariableDesignation(EatToken(SyntaxKind.IdentifierToken));
|
|
}
|
|
return _syntaxFactory.DiscardDesignation(EatContextualToken(SyntaxKind.UnderscoreToken));
|
|
}
|
|
|
|
private WhenClauseSyntax ParseWhenClause(Precedence precedence)
|
|
{
|
|
if (base.CurrentToken.ContextualKind != SyntaxKind.WhenKeyword)
|
|
{
|
|
return null;
|
|
}
|
|
return _syntaxFactory.WhenClause(EatContextualToken(SyntaxKind.WhenKeyword), ParseSubExpression(precedence));
|
|
}
|
|
|
|
private VariableDeclarationSyntax ParseParenthesizedVariableDeclaration()
|
|
{
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
|
|
SeparatedSyntaxListBuilder<VariableDeclaratorSyntax> variables = _pool.AllocateSeparated<VariableDeclaratorSyntax>();
|
|
ParseLocalDeclaration(variables, allowLocalFunctions: false, stopOnCloseParen: true, default(SyntaxList<AttributeListSyntax>), default(SyntaxList<SyntaxToken>), out var type, out var _);
|
|
return _syntaxFactory.VariableDeclaration(type, _pool.ToListAndFree<VariableDeclaratorSyntax>(ref variables));
|
|
}
|
|
|
|
private void ParseLocalDeclaration(SeparatedSyntaxListBuilder<VariableDeclaratorSyntax> variables, bool allowLocalFunctions, bool stopOnCloseParen, SyntaxList<AttributeListSyntax> attributes, SyntaxList<SyntaxToken> mods, out TypeSyntax type, out LocalFunctionStatementSyntax localFunction)
|
|
{
|
|
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
|
|
type = (allowLocalFunctions ? ParseReturnType() : ParseType());
|
|
VariableFlags variableFlags = VariableFlags.LocalOrField;
|
|
if (mods.Any(8350))
|
|
{
|
|
variableFlags |= VariableFlags.Const;
|
|
}
|
|
TerminatorState termState = _termState;
|
|
_termState |= TerminatorState.IsEndOfDeclarationClause;
|
|
ParseVariableDeclarators(type, variableFlags, variables, variableDeclarationsExpected: true, allowLocalFunctions, stopOnCloseParen, attributes, mods, out localFunction);
|
|
_termState = termState;
|
|
if (allowLocalFunctions && localFunction == null && type is PredefinedTypeSyntax predefinedTypeSyntax)
|
|
{
|
|
SyntaxToken keyword = predefinedTypeSyntax.Keyword;
|
|
if (keyword != null && keyword.Kind == SyntaxKind.VoidKeyword)
|
|
{
|
|
type = AddError(type, ErrorCode.ERR_NoVoidHere);
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool IsEndOfDeclarationClause()
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
if (kind - 8211 <= SyntaxKind.List)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private void ParseDeclarationModifiers(SyntaxListBuilder list)
|
|
{
|
|
SyntaxKind contextualKind;
|
|
while (IsDeclarationModifier(contextualKind = base.CurrentToken.ContextualKind) || IsAdditionalLocalFunctionModifier(contextualKind))
|
|
{
|
|
SyntaxToken syntaxToken;
|
|
if (contextualKind == SyntaxKind.AsyncKeyword)
|
|
{
|
|
if (!shouldTreatAsModifier())
|
|
{
|
|
break;
|
|
}
|
|
syntaxToken = EatContextualToken(contextualKind);
|
|
}
|
|
else
|
|
{
|
|
syntaxToken = EatToken();
|
|
}
|
|
if ((contextualKind == SyntaxKind.ReadOnlyKeyword || contextualKind == SyntaxKind.VolatileKeyword) ? true : false)
|
|
{
|
|
syntaxToken = AddError(syntaxToken, ErrorCode.ERR_BadMemberFlag, syntaxToken.Text);
|
|
}
|
|
else if (list.Any(((GreenNode)syntaxToken).RawKind))
|
|
{
|
|
syntaxToken = AddError(syntaxToken, ErrorCode.ERR_TypeExpected);
|
|
}
|
|
list.Add((GreenNode)(object)syntaxToken);
|
|
}
|
|
bool shouldTreatAsModifier()
|
|
{
|
|
using (GetDisposableResetPoint(resetOnDispose: true))
|
|
{
|
|
do
|
|
{
|
|
EatToken();
|
|
if (IsDeclarationModifier(base.CurrentToken.Kind) || IsAdditionalLocalFunctionModifier(base.CurrentToken.Kind))
|
|
{
|
|
return true;
|
|
}
|
|
using (GetDisposableResetPoint(resetOnDispose: true))
|
|
{
|
|
if (ScanType() != ScanTypeFlags.NotType && base.CurrentToken.Kind == SyntaxKind.IdentifierToken)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
while (IsAdditionalLocalFunctionModifier(base.CurrentToken.ContextualKind));
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
private static bool IsDeclarationModifier(SyntaxKind kind)
|
|
{
|
|
switch (kind)
|
|
{
|
|
case SyntaxKind.StaticKeyword:
|
|
case SyntaxKind.ReadOnlyKeyword:
|
|
case SyntaxKind.ConstKeyword:
|
|
case SyntaxKind.VolatileKeyword:
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
|
|
private static bool IsAdditionalLocalFunctionModifier(SyntaxKind kind)
|
|
{
|
|
switch (kind)
|
|
{
|
|
case SyntaxKind.PublicKeyword:
|
|
case SyntaxKind.PrivateKeyword:
|
|
case SyntaxKind.InternalKeyword:
|
|
case SyntaxKind.ProtectedKeyword:
|
|
case SyntaxKind.StaticKeyword:
|
|
case SyntaxKind.ExternKeyword:
|
|
case SyntaxKind.UnsafeKeyword:
|
|
case SyntaxKind.AsyncKeyword:
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
|
|
private static bool IsAccessibilityModifier(SyntaxKind kind)
|
|
{
|
|
if (kind - 8343 <= (SyntaxKind)3)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private LocalFunctionStatementSyntax TryParseLocalFunctionStatementBody(SyntaxList<AttributeListSyntax> attributes, SyntaxList<SyntaxToken> modifiers, TypeSyntax type, SyntaxToken identifier)
|
|
{
|
|
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0182: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
|
|
ResetPoint state = GetResetPoint();
|
|
bool flag = true;
|
|
if (type.Kind == SyntaxKind.IdentifierName)
|
|
{
|
|
flag = ((IdentifierNameSyntax)type).Identifier.ContextualKind != SyntaxKind.AwaitKeyword;
|
|
}
|
|
bool isInAsync = IsInAsync;
|
|
IsInAsync = false;
|
|
SyntaxListBuilder val = null;
|
|
for (int i = 0; i < modifiers.Count; i++)
|
|
{
|
|
SyntaxToken syntaxToken = modifiers[i];
|
|
switch (syntaxToken.ContextualKind)
|
|
{
|
|
case SyntaxKind.AsyncKeyword:
|
|
IsInAsync = true;
|
|
flag = true;
|
|
continue;
|
|
case SyntaxKind.UnsafeKeyword:
|
|
flag = true;
|
|
continue;
|
|
case SyntaxKind.StaticKeyword:
|
|
case SyntaxKind.ReadOnlyKeyword:
|
|
case SyntaxKind.VolatileKeyword:
|
|
case SyntaxKind.ExternKeyword:
|
|
continue;
|
|
}
|
|
syntaxToken = AddError(syntaxToken, ErrorCode.ERR_BadMemberFlag, syntaxToken.Text);
|
|
if (val == null)
|
|
{
|
|
val = _pool.Allocate();
|
|
val.AddRange<SyntaxToken>(modifiers);
|
|
}
|
|
val[i] = (GreenNode)(object)syntaxToken;
|
|
}
|
|
if (val != null)
|
|
{
|
|
modifiers = SyntaxList<SyntaxToken>.op_Implicit(val.ToList());
|
|
_pool.Free(val);
|
|
}
|
|
TypeParameterListSyntax typeParameterList = ParseTypeParameterList();
|
|
ParameterListSyntax parameterListSyntax = ParseParenthesizedParameterList();
|
|
if (!flag)
|
|
{
|
|
SeparatedSyntaxList<ParameterSyntax> parameters = parameterListSyntax.Parameters;
|
|
for (int j = 0; j < parameters.Count; j++)
|
|
{
|
|
flag |= !((GreenNode)parameters[j]).ContainsDiagnostics;
|
|
if (flag)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
SyntaxListBuilder<TypeParameterConstraintClauseSyntax> val2 = default(SyntaxListBuilder<TypeParameterConstraintClauseSyntax>);
|
|
if (base.CurrentToken.ContextualKind == SyntaxKind.WhereKeyword)
|
|
{
|
|
val2 = _pool.Allocate<TypeParameterConstraintClauseSyntax>();
|
|
ParseTypeParameterConstraintClauses(SyntaxListBuilder<TypeParameterConstraintClauseSyntax>.op_Implicit(val2));
|
|
flag = true;
|
|
}
|
|
ParseBlockAndExpressionBodiesWithSemicolon(out var blockBody, out var expressionBody, out var semicolon, parseSemicolonAfterBlock: false);
|
|
IsInAsync = isInAsync;
|
|
if (!flag && blockBody == null && expressionBody == null)
|
|
{
|
|
Reset(ref state);
|
|
Release(ref state);
|
|
return null;
|
|
}
|
|
Release(ref state);
|
|
return _syntaxFactory.LocalFunctionStatement(attributes, modifiers, type, identifier, typeParameterList, parameterListSyntax, SyntaxListBuilder<TypeParameterConstraintClauseSyntax>.op_Implicit(val2), blockBody, expressionBody, semicolon);
|
|
}
|
|
|
|
private ExpressionStatementSyntax ParseExpressionStatement(SyntaxList<AttributeListSyntax> attributes)
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
return ParseExpressionStatement(attributes, ParseExpressionCore());
|
|
}
|
|
|
|
private ExpressionStatementSyntax ParseExpressionStatement(SyntaxList<AttributeListSyntax> attributes, ExpressionSyntax expression)
|
|
{
|
|
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxToken semicolonToken = ((!base.IsScript || base.CurrentToken.Kind != SyntaxKind.EndOfFileToken) ? EatToken(SyntaxKind.SemicolonToken) : SyntaxFactory.MissingToken(SyntaxKind.SemicolonToken));
|
|
return _syntaxFactory.ExpressionStatement(attributes, expression, semicolonToken);
|
|
}
|
|
|
|
public ExpressionSyntax ParseExpression()
|
|
{
|
|
return ParseWithStackGuard((LanguageParser @this) => @this.ParseExpressionCore(), (LanguageParser @this) => @this.CreateMissingIdentifierName());
|
|
}
|
|
|
|
private ExpressionSyntax ParseExpressionCore()
|
|
{
|
|
return ParseSubExpression(Precedence.Expression);
|
|
}
|
|
|
|
private bool CanStartExpression()
|
|
{
|
|
return IsPossibleExpression(allowBinaryExpressions: false, allowAssignmentExpressions: false);
|
|
}
|
|
|
|
private bool IsPossibleExpression()
|
|
{
|
|
return IsPossibleExpression(allowBinaryExpressions: true, allowAssignmentExpressions: true);
|
|
}
|
|
|
|
private bool IsPossibleExpression(bool allowBinaryExpressions, bool allowAssignmentExpressions)
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
switch (kind)
|
|
{
|
|
case SyntaxKind.OpenParenToken:
|
|
case SyntaxKind.OpenBracketToken:
|
|
case SyntaxKind.DotDotToken:
|
|
case SyntaxKind.ColonColonToken:
|
|
case SyntaxKind.TypeOfKeyword:
|
|
case SyntaxKind.SizeOfKeyword:
|
|
case SyntaxKind.NullKeyword:
|
|
case SyntaxKind.TrueKeyword:
|
|
case SyntaxKind.FalseKeyword:
|
|
case SyntaxKind.DefaultKeyword:
|
|
case SyntaxKind.ThrowKeyword:
|
|
case SyntaxKind.StackAllocKeyword:
|
|
case SyntaxKind.NewKeyword:
|
|
case SyntaxKind.RefKeyword:
|
|
case SyntaxKind.ArgListKeyword:
|
|
case SyntaxKind.MakeRefKeyword:
|
|
case SyntaxKind.RefTypeKeyword:
|
|
case SyntaxKind.RefValueKeyword:
|
|
case SyntaxKind.ThisKeyword:
|
|
case SyntaxKind.BaseKeyword:
|
|
case SyntaxKind.DelegateKeyword:
|
|
case SyntaxKind.CheckedKeyword:
|
|
case SyntaxKind.UncheckedKeyword:
|
|
case SyntaxKind.InterpolatedStringStartToken:
|
|
case SyntaxKind.InterpolatedVerbatimStringStartToken:
|
|
case SyntaxKind.NumericLiteralToken:
|
|
case SyntaxKind.CharacterLiteralToken:
|
|
case SyntaxKind.StringLiteralToken:
|
|
case SyntaxKind.InterpolatedStringToken:
|
|
case SyntaxKind.SingleLineRawStringLiteralToken:
|
|
case SyntaxKind.MultiLineRawStringLiteralToken:
|
|
case SyntaxKind.Utf8StringLiteralToken:
|
|
case SyntaxKind.Utf8SingleLineRawStringLiteralToken:
|
|
case SyntaxKind.Utf8MultiLineRawStringLiteralToken:
|
|
case SyntaxKind.InterpolatedSingleLineRawStringStartToken:
|
|
case SyntaxKind.InterpolatedMultiLineRawStringStartToken:
|
|
return true;
|
|
case SyntaxKind.StaticKeyword:
|
|
if (!IsPossibleAnonymousMethodExpression())
|
|
{
|
|
return IsPossibleLambdaExpression(Precedence.Expression);
|
|
}
|
|
return true;
|
|
case SyntaxKind.IdentifierToken:
|
|
if (!IsTrueIdentifier())
|
|
{
|
|
return base.CurrentToken.ContextualKind == SyntaxKind.FromKeyword;
|
|
}
|
|
return true;
|
|
default:
|
|
if (!IsPredefinedType(kind) && !SyntaxFacts.IsAnyUnaryExpression(kind) && (!allowBinaryExpressions || !SyntaxFacts.IsBinaryExpression(kind)))
|
|
{
|
|
if (allowAssignmentExpressions)
|
|
{
|
|
return SyntaxFacts.IsAssignmentExpressionOperatorToken(kind);
|
|
}
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
|
|
private static bool IsInvalidSubExpression(SyntaxKind kind)
|
|
{
|
|
switch (kind)
|
|
{
|
|
case SyntaxKind.IfKeyword:
|
|
case SyntaxKind.ElseKeyword:
|
|
case SyntaxKind.WhileKeyword:
|
|
case SyntaxKind.ForKeyword:
|
|
case SyntaxKind.ForEachKeyword:
|
|
case SyntaxKind.DoKeyword:
|
|
case SyntaxKind.SwitchKeyword:
|
|
case SyntaxKind.CaseKeyword:
|
|
case SyntaxKind.TryKeyword:
|
|
case SyntaxKind.CatchKeyword:
|
|
case SyntaxKind.FinallyKeyword:
|
|
case SyntaxKind.LockKeyword:
|
|
case SyntaxKind.GotoKeyword:
|
|
case SyntaxKind.BreakKeyword:
|
|
case SyntaxKind.ContinueKeyword:
|
|
case SyntaxKind.ReturnKeyword:
|
|
case SyntaxKind.ConstKeyword:
|
|
case SyntaxKind.UsingKeyword:
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
|
|
internal static bool IsRightAssociative(SyntaxKind op)
|
|
{
|
|
if (op == SyntaxKind.CoalesceExpression || op - 8714 <= (SyntaxKind)12)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private static Precedence GetPrecedence(SyntaxKind op)
|
|
{
|
|
switch (op)
|
|
{
|
|
case SyntaxKind.QueryExpression:
|
|
return Precedence.Expression;
|
|
case SyntaxKind.AnonymousMethodExpression:
|
|
case SyntaxKind.SimpleLambdaExpression:
|
|
case SyntaxKind.ParenthesizedLambdaExpression:
|
|
return Precedence.Expression;
|
|
case SyntaxKind.SimpleAssignmentExpression:
|
|
case SyntaxKind.AddAssignmentExpression:
|
|
case SyntaxKind.SubtractAssignmentExpression:
|
|
case SyntaxKind.MultiplyAssignmentExpression:
|
|
case SyntaxKind.DivideAssignmentExpression:
|
|
case SyntaxKind.ModuloAssignmentExpression:
|
|
case SyntaxKind.AndAssignmentExpression:
|
|
case SyntaxKind.ExclusiveOrAssignmentExpression:
|
|
case SyntaxKind.OrAssignmentExpression:
|
|
case SyntaxKind.LeftShiftAssignmentExpression:
|
|
case SyntaxKind.RightShiftAssignmentExpression:
|
|
case SyntaxKind.CoalesceAssignmentExpression:
|
|
case SyntaxKind.UnsignedRightShiftAssignmentExpression:
|
|
return Precedence.Expression;
|
|
case SyntaxKind.CoalesceExpression:
|
|
case SyntaxKind.ThrowExpression:
|
|
return Precedence.Coalescing;
|
|
case SyntaxKind.LogicalOrExpression:
|
|
return Precedence.ConditionalOr;
|
|
case SyntaxKind.LogicalAndExpression:
|
|
return Precedence.ConditionalAnd;
|
|
case SyntaxKind.BitwiseOrExpression:
|
|
return Precedence.LogicalOr;
|
|
case SyntaxKind.ExclusiveOrExpression:
|
|
return Precedence.LogicalXor;
|
|
case SyntaxKind.BitwiseAndExpression:
|
|
return Precedence.LogicalAnd;
|
|
case SyntaxKind.EqualsExpression:
|
|
case SyntaxKind.NotEqualsExpression:
|
|
return Precedence.Equality;
|
|
case SyntaxKind.IsPatternExpression:
|
|
case SyntaxKind.LessThanExpression:
|
|
case SyntaxKind.LessThanOrEqualExpression:
|
|
case SyntaxKind.GreaterThanExpression:
|
|
case SyntaxKind.GreaterThanOrEqualExpression:
|
|
case SyntaxKind.IsExpression:
|
|
case SyntaxKind.AsExpression:
|
|
return Precedence.Relational;
|
|
case SyntaxKind.SwitchExpression:
|
|
case SyntaxKind.WithExpression:
|
|
return Precedence.Switch;
|
|
case SyntaxKind.LeftShiftExpression:
|
|
case SyntaxKind.RightShiftExpression:
|
|
case SyntaxKind.UnsignedRightShiftExpression:
|
|
return Precedence.Shift;
|
|
case SyntaxKind.AddExpression:
|
|
case SyntaxKind.SubtractExpression:
|
|
return Precedence.Additive;
|
|
case SyntaxKind.MultiplyExpression:
|
|
case SyntaxKind.DivideExpression:
|
|
case SyntaxKind.ModuloExpression:
|
|
return Precedence.Multiplicative;
|
|
case SyntaxKind.UnaryPlusExpression:
|
|
case SyntaxKind.UnaryMinusExpression:
|
|
case SyntaxKind.BitwiseNotExpression:
|
|
case SyntaxKind.LogicalNotExpression:
|
|
case SyntaxKind.PreIncrementExpression:
|
|
case SyntaxKind.PreDecrementExpression:
|
|
case SyntaxKind.AwaitExpression:
|
|
case SyntaxKind.IndexExpression:
|
|
case SyntaxKind.TypeOfExpression:
|
|
case SyntaxKind.SizeOfExpression:
|
|
case SyntaxKind.CheckedExpression:
|
|
case SyntaxKind.UncheckedExpression:
|
|
case SyntaxKind.MakeRefExpression:
|
|
case SyntaxKind.RefValueExpression:
|
|
case SyntaxKind.RefTypeExpression:
|
|
return Precedence.Unary;
|
|
case SyntaxKind.CastExpression:
|
|
return Precedence.Cast;
|
|
case SyntaxKind.PointerIndirectionExpression:
|
|
return Precedence.PointerIndirection;
|
|
case SyntaxKind.AddressOfExpression:
|
|
return Precedence.AddressOf;
|
|
case SyntaxKind.RangeExpression:
|
|
return Precedence.Range;
|
|
case SyntaxKind.ConditionalExpression:
|
|
return Precedence.Expression;
|
|
case SyntaxKind.IdentifierName:
|
|
case SyntaxKind.GenericName:
|
|
case SyntaxKind.AliasQualifiedName:
|
|
case SyntaxKind.PredefinedType:
|
|
case SyntaxKind.ParenthesizedExpression:
|
|
case SyntaxKind.InvocationExpression:
|
|
case SyntaxKind.ElementAccessExpression:
|
|
case SyntaxKind.ObjectCreationExpression:
|
|
case SyntaxKind.AnonymousObjectCreationExpression:
|
|
case SyntaxKind.ArrayCreationExpression:
|
|
case SyntaxKind.ImplicitArrayCreationExpression:
|
|
case SyntaxKind.StackAllocArrayCreationExpression:
|
|
case SyntaxKind.InterpolatedStringExpression:
|
|
case SyntaxKind.ImplicitObjectCreationExpression:
|
|
case SyntaxKind.SimpleMemberAccessExpression:
|
|
case SyntaxKind.PointerMemberAccessExpression:
|
|
case SyntaxKind.ConditionalAccessExpression:
|
|
case SyntaxKind.PostIncrementExpression:
|
|
case SyntaxKind.PostDecrementExpression:
|
|
case SyntaxKind.ThisExpression:
|
|
case SyntaxKind.BaseExpression:
|
|
case SyntaxKind.ArgListExpression:
|
|
case SyntaxKind.NumericLiteralExpression:
|
|
case SyntaxKind.StringLiteralExpression:
|
|
case SyntaxKind.CharacterLiteralExpression:
|
|
case SyntaxKind.TrueLiteralExpression:
|
|
case SyntaxKind.FalseLiteralExpression:
|
|
case SyntaxKind.NullLiteralExpression:
|
|
case SyntaxKind.DefaultLiteralExpression:
|
|
case SyntaxKind.Utf8StringLiteralExpression:
|
|
case SyntaxKind.DefaultExpression:
|
|
case SyntaxKind.TupleExpression:
|
|
case SyntaxKind.DeclarationExpression:
|
|
case SyntaxKind.RefExpression:
|
|
case SyntaxKind.ImplicitStackAllocArrayCreationExpression:
|
|
case SyntaxKind.SuppressNullableWarningExpression:
|
|
case SyntaxKind.CollectionExpression:
|
|
return Precedence.Primary;
|
|
default:
|
|
throw ExceptionUtilities.UnexpectedValue((object)op);
|
|
}
|
|
}
|
|
|
|
private static bool IsExpectedPrefixUnaryOperator(SyntaxKind kind)
|
|
{
|
|
if (SyntaxFacts.IsPrefixUnaryExpression(kind))
|
|
{
|
|
if (kind != SyntaxKind.RefKeyword)
|
|
{
|
|
return kind != SyntaxKind.OutKeyword;
|
|
}
|
|
return false;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private static bool IsExpectedBinaryOperator(SyntaxKind kind)
|
|
{
|
|
return SyntaxFacts.IsBinaryExpression(kind);
|
|
}
|
|
|
|
private static bool IsExpectedAssignmentOperator(SyntaxKind kind)
|
|
{
|
|
return SyntaxFacts.IsAssignmentExpressionOperatorToken(kind);
|
|
}
|
|
|
|
private bool IsPossibleAwaitExpressionStatement()
|
|
{
|
|
if (base.IsScript || IsInAsync)
|
|
{
|
|
return base.CurrentToken.ContextualKind == SyntaxKind.AwaitKeyword;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private bool IsAwaitExpression()
|
|
{
|
|
if (base.CurrentToken.ContextualKind == SyntaxKind.AwaitKeyword)
|
|
{
|
|
if (IsInAsync)
|
|
{
|
|
return true;
|
|
}
|
|
SyntaxToken syntaxToken = PeekToken(1);
|
|
switch (syntaxToken.Kind)
|
|
{
|
|
case SyntaxKind.IdentifierToken:
|
|
return syntaxToken.ContextualKind != SyntaxKind.WithKeyword;
|
|
case SyntaxKind.TypeOfKeyword:
|
|
case SyntaxKind.NullKeyword:
|
|
case SyntaxKind.TrueKeyword:
|
|
case SyntaxKind.FalseKeyword:
|
|
case SyntaxKind.DefaultKeyword:
|
|
case SyntaxKind.NewKeyword:
|
|
case SyntaxKind.ThisKeyword:
|
|
case SyntaxKind.BaseKeyword:
|
|
case SyntaxKind.DelegateKeyword:
|
|
case SyntaxKind.CheckedKeyword:
|
|
case SyntaxKind.UncheckedKeyword:
|
|
case SyntaxKind.InterpolatedStringStartToken:
|
|
case SyntaxKind.InterpolatedVerbatimStringStartToken:
|
|
case SyntaxKind.NumericLiteralToken:
|
|
case SyntaxKind.CharacterLiteralToken:
|
|
case SyntaxKind.StringLiteralToken:
|
|
case SyntaxKind.InterpolatedStringToken:
|
|
case SyntaxKind.SingleLineRawStringLiteralToken:
|
|
case SyntaxKind.MultiLineRawStringLiteralToken:
|
|
case SyntaxKind.Utf8StringLiteralToken:
|
|
case SyntaxKind.Utf8SingleLineRawStringLiteralToken:
|
|
case SyntaxKind.Utf8MultiLineRawStringLiteralToken:
|
|
case SyntaxKind.InterpolatedSingleLineRawStringStartToken:
|
|
case SyntaxKind.InterpolatedMultiLineRawStringStartToken:
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private ExpressionSyntax ParseSubExpression(Precedence precedence)
|
|
{
|
|
_recursionDepth++;
|
|
StackGuard.EnsureSufficientExecutionStack(_recursionDepth);
|
|
ExpressionSyntax result = ParseSubExpressionCore(precedence);
|
|
_recursionDepth--;
|
|
return result;
|
|
}
|
|
|
|
private ExpressionSyntax ParseSubExpressionCore(Precedence precedence)
|
|
{
|
|
Precedence precedence2 = Precedence.Expression;
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
if (IsInvalidSubExpression(kind))
|
|
{
|
|
return AddError(CreateMissingIdentifierName(), ErrorCode.ERR_InvalidExprTerm, SyntaxFacts.GetText(kind));
|
|
}
|
|
ExpressionSyntax leftOperand;
|
|
if (IsExpectedPrefixUnaryOperator(kind))
|
|
{
|
|
SyntaxKind prefixUnaryExpression = SyntaxFacts.GetPrefixUnaryExpression(kind);
|
|
precedence2 = GetPrecedence(prefixUnaryExpression);
|
|
SyntaxToken operatorToken = EatToken();
|
|
ExpressionSyntax operand = ParseSubExpression(precedence2);
|
|
leftOperand = _syntaxFactory.PrefixUnaryExpression(prefixUnaryExpression, operatorToken, operand);
|
|
}
|
|
else if (kind == SyntaxKind.DotDotToken)
|
|
{
|
|
SyntaxToken operatorToken2 = EatToken();
|
|
precedence2 = GetPrecedence(SyntaxKind.RangeExpression);
|
|
ExpressionSyntax rightOperand = ((!CanStartExpression()) ? null : ParseSubExpression(precedence2));
|
|
leftOperand = _syntaxFactory.RangeExpression(null, operatorToken2, rightOperand);
|
|
}
|
|
else if (IsAwaitExpression())
|
|
{
|
|
precedence2 = GetPrecedence(SyntaxKind.AwaitExpression);
|
|
leftOperand = _syntaxFactory.AwaitExpression(EatContextualToken(SyntaxKind.AwaitKeyword), ParseSubExpression(precedence2));
|
|
}
|
|
else if (IsQueryExpression(mayBeVariableDeclaration: false, mayBeMemberDeclaration: false))
|
|
{
|
|
leftOperand = ParseQueryExpression(precedence);
|
|
}
|
|
else if (base.CurrentToken.ContextualKind == SyntaxKind.FromKeyword && IsInQuery)
|
|
{
|
|
SyntaxToken node = EatToken();
|
|
node = AddError(node, ErrorCode.ERR_InvalidExprTerm, base.CurrentToken.Text);
|
|
leftOperand = AddTrailingSkippedSyntax(CreateMissingIdentifierName(), (GreenNode)(object)node);
|
|
}
|
|
else
|
|
{
|
|
if (kind == SyntaxKind.ThrowKeyword)
|
|
{
|
|
ExpressionSyntax expressionSyntax = ParseThrowExpression();
|
|
if (precedence > Precedence.Coalescing)
|
|
{
|
|
return AddError(expressionSyntax, ErrorCode.ERR_InvalidExprTerm, SyntaxFacts.GetText(kind));
|
|
}
|
|
return expressionSyntax;
|
|
}
|
|
leftOperand = ((!IsPossibleDeconstructionLeft(precedence)) ? ParseTerm(precedence) : ParseDeclarationExpression(ParseTypeMode.Normal, isScoped: false));
|
|
}
|
|
return ParseExpressionContinued(leftOperand, precedence);
|
|
}
|
|
|
|
private ExpressionSyntax ParseExpressionContinued(ExpressionSyntax leftOperand, Precedence precedence)
|
|
{
|
|
while (true)
|
|
{
|
|
SyntaxKind contextualKind = base.CurrentToken.ContextualKind;
|
|
bool flag = false;
|
|
SyntaxKind syntaxKind;
|
|
if (IsExpectedBinaryOperator(contextualKind))
|
|
{
|
|
syntaxKind = SyntaxFacts.GetBinaryExpression(contextualKind);
|
|
}
|
|
else if (IsExpectedAssignmentOperator(contextualKind))
|
|
{
|
|
syntaxKind = SyntaxFacts.GetAssignmentExpression(contextualKind);
|
|
flag = true;
|
|
}
|
|
else if (contextualKind == SyntaxKind.DotDotToken)
|
|
{
|
|
syntaxKind = SyntaxKind.RangeExpression;
|
|
}
|
|
else if (contextualKind == SyntaxKind.SwitchKeyword && PeekToken(1).Kind == SyntaxKind.OpenBraceToken)
|
|
{
|
|
syntaxKind = SyntaxKind.SwitchExpression;
|
|
}
|
|
else
|
|
{
|
|
if (contextualKind != SyntaxKind.WithKeyword || PeekToken(1).Kind != SyntaxKind.OpenBraceToken)
|
|
{
|
|
break;
|
|
}
|
|
syntaxKind = SyntaxKind.WithExpression;
|
|
}
|
|
Precedence precedence2 = GetPrecedence(syntaxKind);
|
|
int num = 1;
|
|
bool flag2 = contextualKind == SyntaxKind.GreaterThanToken;
|
|
if (flag2)
|
|
{
|
|
SyntaxKind kind = PeekToken(1).Kind;
|
|
bool flag3 = ((kind == SyntaxKind.GreaterThanToken || kind == SyntaxKind.GreaterThanEqualsToken) ? true : false);
|
|
flag2 = flag3;
|
|
}
|
|
if (flag2 && NoTriviaBetween(base.CurrentToken, PeekToken(1)))
|
|
{
|
|
if (PeekToken(1).Kind == SyntaxKind.GreaterThanToken)
|
|
{
|
|
SyntaxKind kind = PeekToken(2).Kind;
|
|
flag2 = ((kind == SyntaxKind.GreaterThanToken || kind == SyntaxKind.GreaterThanEqualsToken) ? true : false);
|
|
if (flag2 && NoTriviaBetween(PeekToken(1), PeekToken(2)))
|
|
{
|
|
if (PeekToken(2).Kind == SyntaxKind.GreaterThanToken)
|
|
{
|
|
syntaxKind = SyntaxFacts.GetBinaryExpression(SyntaxKind.GreaterThanGreaterThanGreaterThanToken);
|
|
}
|
|
else
|
|
{
|
|
syntaxKind = SyntaxFacts.GetAssignmentExpression(SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken);
|
|
flag = true;
|
|
}
|
|
num = 3;
|
|
}
|
|
else
|
|
{
|
|
syntaxKind = SyntaxFacts.GetBinaryExpression(SyntaxKind.GreaterThanGreaterThanToken);
|
|
num = 2;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
syntaxKind = SyntaxFacts.GetAssignmentExpression(SyntaxKind.GreaterThanGreaterThanEqualsToken);
|
|
flag = true;
|
|
num = 2;
|
|
}
|
|
precedence2 = GetPrecedence(syntaxKind);
|
|
}
|
|
if (precedence2 < precedence || (precedence2 == precedence && !IsRightAssociative(syntaxKind)))
|
|
{
|
|
break;
|
|
}
|
|
SyntaxToken syntaxToken = EatContextualToken(contextualKind);
|
|
Precedence precedence3 = GetPrecedence(leftOperand.Kind);
|
|
if (precedence2 > precedence3)
|
|
{
|
|
ErrorCode code = ((leftOperand.Kind == SyntaxKind.IsPatternExpression) ? ErrorCode.ERR_UnexpectedToken : ErrorCode.WRN_PrecedenceInversion);
|
|
syntaxToken = AddError(syntaxToken, code, syntaxToken.Text);
|
|
}
|
|
switch (num)
|
|
{
|
|
case 2:
|
|
{
|
|
SyntaxToken syntaxToken3 = EatToken();
|
|
SyntaxKind kind3 = ((syntaxToken3.Kind == SyntaxKind.GreaterThanToken) ? SyntaxKind.GreaterThanGreaterThanToken : SyntaxKind.GreaterThanGreaterThanEqualsToken);
|
|
syntaxToken = SyntaxFactory.Token(syntaxToken.GetLeadingTrivia(), kind3, syntaxToken3.GetTrailingTrivia());
|
|
break;
|
|
}
|
|
case 3:
|
|
{
|
|
SyntaxToken syntaxToken2 = EatToken();
|
|
syntaxToken2 = EatToken();
|
|
SyntaxKind kind2 = ((syntaxToken2.Kind == SyntaxKind.GreaterThanToken) ? SyntaxKind.GreaterThanGreaterThanGreaterThanToken : SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken);
|
|
syntaxToken = SyntaxFactory.Token(syntaxToken.GetLeadingTrivia(), kind2, syntaxToken2.GetTrailingTrivia());
|
|
break;
|
|
}
|
|
default:
|
|
throw ExceptionUtilities.UnexpectedValue((object)num);
|
|
case 1:
|
|
break;
|
|
}
|
|
switch (syntaxKind)
|
|
{
|
|
case SyntaxKind.AsExpression:
|
|
{
|
|
TypeSyntax right = ParseType(ParseTypeMode.AsExpression);
|
|
leftOperand = _syntaxFactory.BinaryExpression(syntaxKind, leftOperand, syntaxToken, right);
|
|
continue;
|
|
}
|
|
case SyntaxKind.IsExpression:
|
|
leftOperand = ParseIsExpression(leftOperand, syntaxToken);
|
|
continue;
|
|
}
|
|
if (flag)
|
|
{
|
|
ExpressionSyntax right2 = ((syntaxKind != SyntaxKind.SimpleAssignmentExpression || base.CurrentToken.Kind != SyntaxKind.RefKeyword || IsPossibleLambdaExpression(precedence2)) ? ParseSubExpression(precedence2) : _syntaxFactory.RefExpression(EatToken(), ParseExpressionCore()));
|
|
leftOperand = _syntaxFactory.AssignmentExpression(syntaxKind, leftOperand, syntaxToken, right2);
|
|
continue;
|
|
}
|
|
switch (syntaxKind)
|
|
{
|
|
case SyntaxKind.SwitchExpression:
|
|
leftOperand = ParseSwitchExpression(leftOperand, syntaxToken);
|
|
continue;
|
|
case SyntaxKind.WithExpression:
|
|
leftOperand = ParseWithExpression(leftOperand, syntaxToken);
|
|
continue;
|
|
}
|
|
if (contextualKind == SyntaxKind.DotDotToken)
|
|
{
|
|
ExpressionSyntax rightOperand;
|
|
if (CanStartExpression())
|
|
{
|
|
precedence2 = GetPrecedence(syntaxKind);
|
|
rightOperand = ParseSubExpression(precedence2);
|
|
}
|
|
else
|
|
{
|
|
rightOperand = null;
|
|
}
|
|
leftOperand = _syntaxFactory.RangeExpression(leftOperand, syntaxToken, rightOperand);
|
|
}
|
|
else
|
|
{
|
|
leftOperand = _syntaxFactory.BinaryExpression(syntaxKind, leftOperand, syntaxToken, ParseSubExpression(precedence2));
|
|
}
|
|
}
|
|
if (base.CurrentToken.Kind != SyntaxKind.QuestionToken || precedence > Precedence.Conditional)
|
|
{
|
|
return leftOperand;
|
|
}
|
|
SyntaxToken questionToken = EatToken();
|
|
using (DisposableResetPoint disposableResetPoint = GetDisposableResetPoint(resetOnDispose: false))
|
|
{
|
|
ExpressionSyntax expressionSyntax = ParsePossibleRefExpression();
|
|
if (base.CurrentToken.Kind != SyntaxKind.ColonToken && !ForceConditionalAccessExpression && containsTernaryCollectionToReinterpret(expressionSyntax))
|
|
{
|
|
using DisposableResetPoint disposableResetPoint2 = GetDisposableResetPoint(resetOnDispose: false);
|
|
disposableResetPoint.Reset();
|
|
ForceConditionalAccessExpression = true;
|
|
ExpressionSyntax expressionSyntax2 = ParsePossibleRefExpression();
|
|
ForceConditionalAccessExpression = false;
|
|
if (base.CurrentToken.Kind == SyntaxKind.ColonToken)
|
|
{
|
|
expressionSyntax = expressionSyntax2;
|
|
}
|
|
else
|
|
{
|
|
disposableResetPoint2.Reset();
|
|
}
|
|
}
|
|
if (base.CurrentToken.Kind == SyntaxKind.EndOfFileToken && lexer.InterpolationFollowedByColon)
|
|
{
|
|
leftOperand = _syntaxFactory.ConditionalExpression(leftOperand, questionToken, expressionSyntax, SyntaxFactory.MissingToken(SyntaxKind.ColonToken), _syntaxFactory.IdentifierName(SyntaxFactory.MissingToken(SyntaxKind.IdentifierToken)));
|
|
return AddError(leftOperand, ErrorCode.ERR_ConditionalInInterpolation);
|
|
}
|
|
return _syntaxFactory.ConditionalExpression(leftOperand, questionToken, expressionSyntax, EatToken(SyntaxKind.ColonToken), ParsePossibleRefExpression());
|
|
}
|
|
static bool containsTernaryCollectionToReinterpret(ExpressionSyntax expression)
|
|
{
|
|
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
|
|
ArrayBuilder<GreenNode> instance = ArrayBuilder<GreenNode>.GetInstance();
|
|
ArrayBuilderExtensions.Push<GreenNode>(instance, (GreenNode)(object)expression);
|
|
while (instance.Count > 0)
|
|
{
|
|
GreenNode val = ArrayBuilderExtensions.Pop<GreenNode>(instance);
|
|
if (val is ConditionalExpressionSyntax conditionalExpressionSyntax && conditionalExpressionSyntax.WhenTrue.GetFirstToken().Kind == SyntaxKind.OpenBracketToken)
|
|
{
|
|
instance.Free();
|
|
return true;
|
|
}
|
|
ChildSyntaxList val2 = val.ChildNodesAndTokens();
|
|
Enumerator enumerator = ((ChildSyntaxList)(ref val2)).GetEnumerator();
|
|
while (((Enumerator)(ref enumerator)).MoveNext())
|
|
{
|
|
GreenNode current = ((Enumerator)(ref enumerator)).Current;
|
|
ArrayBuilderExtensions.Push<GreenNode>(instance, current);
|
|
}
|
|
}
|
|
instance.Free();
|
|
return false;
|
|
}
|
|
}
|
|
|
|
private DeclarationExpressionSyntax ParseDeclarationExpression(ParseTypeMode mode, bool isScoped)
|
|
{
|
|
SyntaxToken syntaxToken = (isScoped ? EatContextualToken(SyntaxKind.ScopedKeyword) : null);
|
|
TypeSyntax typeSyntax = ParseType(mode);
|
|
return _syntaxFactory.DeclarationExpression((syntaxToken == null) ? typeSyntax : _syntaxFactory.ScopedType(syntaxToken, typeSyntax), ParseDesignation(forPattern: false));
|
|
}
|
|
|
|
private ExpressionSyntax ParseThrowExpression()
|
|
{
|
|
return _syntaxFactory.ThrowExpression(EatToken(SyntaxKind.ThrowKeyword), ParseSubExpression(Precedence.Coalescing));
|
|
}
|
|
|
|
private ExpressionSyntax ParseIsExpression(ExpressionSyntax leftOperand, SyntaxToken opToken)
|
|
{
|
|
CSharpSyntaxNode cSharpSyntaxNode = ParseTypeOrPatternForIsOperator();
|
|
if (!(cSharpSyntaxNode is PatternSyntax pattern))
|
|
{
|
|
if (cSharpSyntaxNode is TypeSyntax right)
|
|
{
|
|
return _syntaxFactory.BinaryExpression(SyntaxKind.IsExpression, leftOperand, opToken, right);
|
|
}
|
|
throw ExceptionUtilities.UnexpectedValue((object)cSharpSyntaxNode);
|
|
}
|
|
return _syntaxFactory.IsPatternExpression(leftOperand, opToken, pattern);
|
|
}
|
|
|
|
private ExpressionSyntax ParseTerm(Precedence precedence)
|
|
{
|
|
return ParsePostFixExpression(ParseTermWithoutPostfix(precedence));
|
|
}
|
|
|
|
private ExpressionSyntax ParseTermWithoutPostfix(Precedence precedence)
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
switch (kind)
|
|
{
|
|
case SyntaxKind.TypeOfKeyword:
|
|
return ParseTypeOfExpression();
|
|
case SyntaxKind.DefaultKeyword:
|
|
return ParseDefaultExpression();
|
|
case SyntaxKind.SizeOfKeyword:
|
|
return ParseSizeOfExpression();
|
|
case SyntaxKind.MakeRefKeyword:
|
|
return ParseMakeRefExpression();
|
|
case SyntaxKind.RefTypeKeyword:
|
|
return ParseRefTypeExpression();
|
|
case SyntaxKind.CheckedKeyword:
|
|
case SyntaxKind.UncheckedKeyword:
|
|
return ParseCheckedOrUncheckedExpression();
|
|
case SyntaxKind.RefValueKeyword:
|
|
return ParseRefValueExpression();
|
|
case SyntaxKind.ColonColonToken:
|
|
return ParseAliasQualifiedName(NameOptions.InExpression);
|
|
case SyntaxKind.EqualsGreaterThanToken:
|
|
return ParseLambdaExpression();
|
|
case SyntaxKind.StaticKeyword:
|
|
if (IsPossibleAnonymousMethodExpression())
|
|
{
|
|
return ParseAnonymousMethodExpression();
|
|
}
|
|
if (IsPossibleLambdaExpression(precedence))
|
|
{
|
|
return ParseLambdaExpression();
|
|
}
|
|
return AddError(CreateMissingIdentifierName(), ErrorCode.ERR_InvalidExprTerm, base.CurrentToken.Text);
|
|
case SyntaxKind.IdentifierToken:
|
|
if (IsTrueIdentifier())
|
|
{
|
|
if (IsPossibleAnonymousMethodExpression())
|
|
{
|
|
return ParseAnonymousMethodExpression();
|
|
}
|
|
if (IsPossibleLambdaExpression(precedence))
|
|
{
|
|
LambdaExpressionSyntax lambdaExpressionSyntax = TryParseLambdaExpression();
|
|
if (lambdaExpressionSyntax != null)
|
|
{
|
|
return lambdaExpressionSyntax;
|
|
}
|
|
}
|
|
if (IsPossibleDeconstructionLeft(precedence))
|
|
{
|
|
return ParseDeclarationExpression(ParseTypeMode.Normal, isScoped: false);
|
|
}
|
|
return ParseAliasQualifiedName(NameOptions.InExpression);
|
|
}
|
|
return AddError(CreateMissingIdentifierName(), ErrorCode.ERR_InvalidExprTerm, base.CurrentToken.Text);
|
|
case SyntaxKind.OpenBracketToken:
|
|
if (!IsPossibleLambdaExpression(precedence))
|
|
{
|
|
return ParseCollectionExpression();
|
|
}
|
|
return ParseLambdaExpression();
|
|
case SyntaxKind.ThisKeyword:
|
|
return _syntaxFactory.ThisExpression(EatToken());
|
|
case SyntaxKind.BaseKeyword:
|
|
return ParseBaseExpression();
|
|
case SyntaxKind.NullKeyword:
|
|
case SyntaxKind.TrueKeyword:
|
|
case SyntaxKind.FalseKeyword:
|
|
case SyntaxKind.ArgListKeyword:
|
|
case SyntaxKind.NumericLiteralToken:
|
|
case SyntaxKind.CharacterLiteralToken:
|
|
case SyntaxKind.StringLiteralToken:
|
|
case SyntaxKind.SingleLineRawStringLiteralToken:
|
|
case SyntaxKind.MultiLineRawStringLiteralToken:
|
|
case SyntaxKind.Utf8StringLiteralToken:
|
|
case SyntaxKind.Utf8SingleLineRawStringLiteralToken:
|
|
case SyntaxKind.Utf8MultiLineRawStringLiteralToken:
|
|
return _syntaxFactory.LiteralExpression(SyntaxFacts.GetLiteralExpression(kind), EatToken());
|
|
case SyntaxKind.InterpolatedStringStartToken:
|
|
case SyntaxKind.InterpolatedVerbatimStringStartToken:
|
|
case SyntaxKind.InterpolatedSingleLineRawStringStartToken:
|
|
case SyntaxKind.InterpolatedMultiLineRawStringStartToken:
|
|
throw new NotImplementedException();
|
|
case SyntaxKind.InterpolatedStringToken:
|
|
return ParseInterpolatedStringToken();
|
|
case SyntaxKind.OpenParenToken:
|
|
if (IsPossibleLambdaExpression(precedence))
|
|
{
|
|
LambdaExpressionSyntax lambdaExpressionSyntax2 = TryParseLambdaExpression();
|
|
if (lambdaExpressionSyntax2 != null)
|
|
{
|
|
return lambdaExpressionSyntax2;
|
|
}
|
|
}
|
|
return ParseCastOrParenExpressionOrTuple();
|
|
case SyntaxKind.NewKeyword:
|
|
return ParseNewExpression();
|
|
case SyntaxKind.StackAllocKeyword:
|
|
return ParseStackAllocExpression();
|
|
case SyntaxKind.DelegateKeyword:
|
|
if (!IsPossibleLambdaExpression(precedence))
|
|
{
|
|
return ParseAnonymousMethodExpression();
|
|
}
|
|
return ParseLambdaExpression();
|
|
case SyntaxKind.RefKeyword:
|
|
{
|
|
if (IsPossibleLambdaExpression(precedence))
|
|
{
|
|
return ParseLambdaExpression();
|
|
}
|
|
SyntaxToken refKeyword = EatToken();
|
|
return AddError(_syntaxFactory.RefExpression(refKeyword, ParseExpressionCore()), ErrorCode.ERR_InvalidExprTerm, SyntaxFacts.GetText(kind));
|
|
}
|
|
default:
|
|
{
|
|
if (IsPredefinedType(kind))
|
|
{
|
|
if (IsPossibleLambdaExpression(precedence))
|
|
{
|
|
return ParseLambdaExpression();
|
|
}
|
|
PredefinedTypeSyntax predefinedTypeSyntax = _syntaxFactory.PredefinedType(EatToken());
|
|
if (base.CurrentToken.Kind != SyntaxKind.DotToken || kind == SyntaxKind.VoidKeyword)
|
|
{
|
|
predefinedTypeSyntax = AddError(predefinedTypeSyntax, ErrorCode.ERR_InvalidExprTerm, SyntaxFacts.GetText(kind));
|
|
}
|
|
return predefinedTypeSyntax;
|
|
}
|
|
IdentifierNameSyntax node = CreateMissingIdentifierName();
|
|
if (kind == SyntaxKind.EndOfFileToken)
|
|
{
|
|
return AddError(node, ErrorCode.ERR_ExpressionExpected);
|
|
}
|
|
return AddError(node, ErrorCode.ERR_InvalidExprTerm, SyntaxFacts.GetText(kind));
|
|
}
|
|
}
|
|
}
|
|
|
|
private ExpressionSyntax ParseBaseExpression()
|
|
{
|
|
return _syntaxFactory.BaseExpression(EatToken());
|
|
}
|
|
|
|
private bool IsPossibleDeconstructionLeft(Precedence precedence)
|
|
{
|
|
if (precedence != Precedence.Expression || (!base.CurrentToken.IsIdentifierVar() && !IsPredefinedType(base.CurrentToken.Kind)))
|
|
{
|
|
return false;
|
|
}
|
|
using (GetDisposableResetPoint(resetOnDispose: true))
|
|
{
|
|
EatToken();
|
|
return base.CurrentToken.Kind == SyntaxKind.OpenParenToken && ScanDesignator() && base.CurrentToken.Kind == SyntaxKind.EqualsToken;
|
|
}
|
|
}
|
|
|
|
private bool ScanDesignator()
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
if (kind != SyntaxKind.OpenParenToken)
|
|
{
|
|
if (kind == SyntaxKind.IdentifierToken && IsTrueIdentifier())
|
|
{
|
|
EatToken();
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
while (true)
|
|
{
|
|
EatToken();
|
|
if (!ScanDesignator())
|
|
{
|
|
break;
|
|
}
|
|
switch (base.CurrentToken.Kind)
|
|
{
|
|
case SyntaxKind.CommaToken:
|
|
break;
|
|
case SyntaxKind.CloseParenToken:
|
|
EatToken();
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private bool IsPossibleAnonymousMethodExpression()
|
|
{
|
|
int i;
|
|
for (i = 0; PeekToken(i).Kind == SyntaxKind.StaticKeyword || PeekToken(i).ContextualKind == SyntaxKind.AsyncKeyword; i++)
|
|
{
|
|
}
|
|
if (PeekToken(i).Kind == SyntaxKind.DelegateKeyword)
|
|
{
|
|
return PeekToken(i + 1).Kind != SyntaxKind.AsteriskToken;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private ExpressionSyntax ParsePostFixExpression(ExpressionSyntax expr)
|
|
{
|
|
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
|
|
while (true)
|
|
{
|
|
switch (base.CurrentToken.Kind)
|
|
{
|
|
case SyntaxKind.OpenParenToken:
|
|
expr = _syntaxFactory.InvocationExpression(expr, ParseParenthesizedArgumentList());
|
|
break;
|
|
case SyntaxKind.OpenBracketToken:
|
|
expr = _syntaxFactory.ElementAccessExpression(expr, ParseBracketedArgumentList());
|
|
break;
|
|
case SyntaxKind.MinusMinusToken:
|
|
case SyntaxKind.PlusPlusToken:
|
|
expr = _syntaxFactory.PostfixUnaryExpression(SyntaxFacts.GetPostfixUnaryExpression(base.CurrentToken.Kind), expr, EatToken());
|
|
break;
|
|
case SyntaxKind.ColonColonToken:
|
|
expr = ((PeekToken(1).Kind != SyntaxKind.IdentifierToken) ? AddTrailingSkippedSyntax(expr, (GreenNode)(object)EatTokenWithPrejudice(SyntaxKind.DotToken)) : _syntaxFactory.MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, expr, ConvertToMissingWithTrailingTrivia(AddError(EatToken(), ErrorCode.ERR_UnexpectedAliasedName), SyntaxKind.DotToken), ParseSimpleName(NameOptions.InExpression)));
|
|
break;
|
|
case SyntaxKind.MinusGreaterThanToken:
|
|
expr = _syntaxFactory.MemberAccessExpression(SyntaxKind.PointerMemberAccessExpression, expr, EatToken(), ParseSimpleName(NameOptions.InExpression));
|
|
break;
|
|
case SyntaxKind.DotToken:
|
|
if (base.CurrentToken.TrailingTrivia.Any(8539) && PeekToken(1).Kind == SyntaxKind.IdentifierToken && PeekToken(2).ContextualKind == SyntaxKind.IdentifierToken)
|
|
{
|
|
return _syntaxFactory.MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, expr, EatToken(), AddError(CreateMissingIdentifierName(), ErrorCode.ERR_IdentifierExpected));
|
|
}
|
|
expr = _syntaxFactory.MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, expr, EatToken(), ParseSimpleName(NameOptions.InExpression));
|
|
break;
|
|
case SyntaxKind.QuestionToken:
|
|
if (CanStartConsequenceExpression())
|
|
{
|
|
expr = _syntaxFactory.ConditionalAccessExpression(expr, EatToken(), ParseConsequenceSyntax());
|
|
break;
|
|
}
|
|
return expr;
|
|
case SyntaxKind.ExclamationToken:
|
|
expr = _syntaxFactory.PostfixUnaryExpression(SyntaxKind.SuppressNullableWarningExpression, expr, EatToken());
|
|
break;
|
|
default:
|
|
return expr;
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool CanStartConsequenceExpression()
|
|
{
|
|
switch (PeekToken(1).Kind)
|
|
{
|
|
case SyntaxKind.DotToken:
|
|
return true;
|
|
case SyntaxKind.OpenBracketToken:
|
|
if (ForceConditionalAccessExpression)
|
|
{
|
|
return true;
|
|
}
|
|
using (GetDisposableResetPoint(resetOnDispose: true))
|
|
{
|
|
EatToken();
|
|
ParsePossibleRefExpression();
|
|
return base.CurrentToken.Kind != SyntaxKind.ColonToken;
|
|
}
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
|
|
internal ExpressionSyntax ParseConsequenceSyntax()
|
|
{
|
|
ExpressionSyntax expressionSyntax = base.CurrentToken.Kind switch
|
|
{
|
|
SyntaxKind.DotToken => _syntaxFactory.MemberBindingExpression(EatToken(), ParseSimpleName(NameOptions.InExpression)),
|
|
SyntaxKind.OpenBracketToken => _syntaxFactory.ElementBindingExpression(ParseBracketedArgumentList()),
|
|
_ => throw ExceptionUtilities.Unreachable("/_/src/Compilers/CSharp/Portable/Parser/LanguageParser.cs", 11206),
|
|
};
|
|
while (true)
|
|
{
|
|
if (isOptionalExclamationsFollowedByConditionalOperation())
|
|
{
|
|
while (base.CurrentToken.Kind == SyntaxKind.ExclamationToken)
|
|
{
|
|
expressionSyntax = _syntaxFactory.PostfixUnaryExpression(SyntaxKind.SuppressNullableWarningExpression, expressionSyntax, EatToken());
|
|
}
|
|
}
|
|
switch (base.CurrentToken.Kind)
|
|
{
|
|
case SyntaxKind.OpenParenToken:
|
|
expressionSyntax = _syntaxFactory.InvocationExpression(expressionSyntax, ParseParenthesizedArgumentList());
|
|
break;
|
|
case SyntaxKind.OpenBracketToken:
|
|
expressionSyntax = _syntaxFactory.ElementAccessExpression(expressionSyntax, ParseBracketedArgumentList());
|
|
break;
|
|
case SyntaxKind.DotToken:
|
|
expressionSyntax = _syntaxFactory.MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, expressionSyntax, EatToken(), ParseSimpleName(NameOptions.InExpression));
|
|
break;
|
|
case SyntaxKind.QuestionToken:
|
|
if (CanStartConsequenceExpression())
|
|
{
|
|
return _syntaxFactory.ConditionalAccessExpression(expressionSyntax, EatToken(), ParseConsequenceSyntax());
|
|
}
|
|
return expressionSyntax;
|
|
default:
|
|
return expressionSyntax;
|
|
}
|
|
}
|
|
bool isOptionalExclamationsFollowedByConditionalOperation()
|
|
{
|
|
int i;
|
|
for (i = 0; PeekToken(i).Kind == SyntaxKind.ExclamationToken; i++)
|
|
{
|
|
}
|
|
SyntaxKind kind = PeekToken(i).Kind;
|
|
if (kind == SyntaxKind.OpenParenToken || kind == SyntaxKind.OpenBracketToken || kind - 8218 <= SyntaxKind.List)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
internal ArgumentListSyntax ParseParenthesizedArgumentList()
|
|
{
|
|
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
|
|
if (IsIncrementalAndFactoryContextMatches && base.CurrentNodeKind == SyntaxKind.ArgumentList)
|
|
{
|
|
return (ArgumentListSyntax)(object)EatNode();
|
|
}
|
|
ParseArgumentList(out var openToken, out var arguments, out var closeToken, SyntaxKind.OpenParenToken, SyntaxKind.CloseParenToken);
|
|
return _syntaxFactory.ArgumentList(openToken, arguments, closeToken);
|
|
}
|
|
|
|
internal BracketedArgumentListSyntax ParseBracketedArgumentList()
|
|
{
|
|
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
|
|
if (IsIncrementalAndFactoryContextMatches && base.CurrentNodeKind == SyntaxKind.BracketedArgumentList)
|
|
{
|
|
return (BracketedArgumentListSyntax)(object)EatNode();
|
|
}
|
|
ParseArgumentList(out var openToken, out var arguments, out var closeToken, SyntaxKind.OpenBracketToken, SyntaxKind.CloseBracketToken);
|
|
return _syntaxFactory.BracketedArgumentList(openToken, arguments, closeToken);
|
|
}
|
|
|
|
private void ParseArgumentList(out SyntaxToken openToken, out SeparatedSyntaxList<ArgumentSyntax> arguments, out SyntaxToken closeToken, SyntaxKind openKind, SyntaxKind closeKind)
|
|
{
|
|
//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
|
|
bool flag = openKind == SyntaxKind.OpenBracketToken;
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
bool flag2 = ((kind == SyntaxKind.OpenParenToken || kind == SyntaxKind.OpenBracketToken) ? true : false);
|
|
openToken = (flag2 ? EatTokenAsKind(openKind) : EatToken(openKind));
|
|
TerminatorState termState = _termState;
|
|
_termState |= TerminatorState.IsEndOfArgumentList;
|
|
if (base.CurrentToken.Kind != closeKind && base.CurrentToken.Kind != SyntaxKind.SemicolonToken)
|
|
{
|
|
if (flag)
|
|
{
|
|
arguments = ParseCommaSeparatedSyntaxList(ref openToken, SyntaxKind.CloseBracketToken, (LanguageParser @this) => @this.IsPossibleArgumentExpression(), (LanguageParser @this) => @this.ParseArgumentExpression(isIndexer: true), skipBadArgumentListTokens, allowTrailingSeparator: false, requireOneElement: false, allowSemicolonAsSeparator: false);
|
|
}
|
|
else
|
|
{
|
|
arguments = ParseCommaSeparatedSyntaxList(ref openToken, SyntaxKind.CloseParenToken, (LanguageParser @this) => @this.IsPossibleArgumentExpression(), (LanguageParser @this) => @this.ParseArgumentExpression(isIndexer: false), skipBadArgumentListTokens, allowTrailingSeparator: false, requireOneElement: false, allowSemicolonAsSeparator: false);
|
|
}
|
|
}
|
|
else if (flag && base.CurrentToken.Kind == closeKind)
|
|
{
|
|
SeparatedSyntaxListBuilder<ArgumentSyntax> val = _pool.AllocateSeparated<ArgumentSyntax>();
|
|
val.Add(ParseArgumentExpression(flag));
|
|
arguments = _pool.ToListAndFree<ArgumentSyntax>(ref val);
|
|
}
|
|
else
|
|
{
|
|
arguments = default(SeparatedSyntaxList<ArgumentSyntax>);
|
|
}
|
|
_termState = termState;
|
|
kind = base.CurrentToken.Kind;
|
|
flag2 = ((kind == SyntaxKind.CloseParenToken || kind == SyntaxKind.CloseBracketToken) ? true : false);
|
|
closeToken = (flag2 ? EatTokenAsKind(closeKind) : EatToken(closeKind));
|
|
static PostSkipAction skipBadArgumentListTokens(LanguageParser @this, ref SyntaxToken open, SeparatedSyntaxListBuilder<ArgumentSyntax> list, SyntaxKind expectedKind, SyntaxKind closeKind2)
|
|
{
|
|
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxKind kind2 = @this.CurrentToken.Kind;
|
|
if ((kind2 == SyntaxKind.CloseParenToken || kind2 == SyntaxKind.CloseBracketToken || kind2 == SyntaxKind.SemicolonToken) ? true : false)
|
|
{
|
|
return PostSkipAction.Abort;
|
|
}
|
|
return @this.SkipBadSeparatedListTokensWithExpectedKind<SyntaxToken, ArgumentSyntax>(ref open, list, (LanguageParser p) => p.CurrentToken.Kind != SyntaxKind.CommaToken && !p.IsPossibleArgumentExpression(), (LanguageParser p, SyntaxKind syntaxKind) => p.CurrentToken.Kind == syntaxKind || p.CurrentToken.Kind == SyntaxKind.SemicolonToken, expectedKind, closeKind2);
|
|
}
|
|
}
|
|
|
|
private bool IsEndOfArgumentList()
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
if (kind == SyntaxKind.CloseParenToken || kind == SyntaxKind.CloseBracketToken)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private bool IsPossibleArgumentExpression()
|
|
{
|
|
if (!IsValidArgumentRefKindKeyword(base.CurrentToken.Kind))
|
|
{
|
|
return IsPossibleExpression();
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private static bool IsValidArgumentRefKindKeyword(SyntaxKind kind)
|
|
{
|
|
if (kind - 8360 <= (SyntaxKind)2)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private ArgumentSyntax ParseArgumentExpression(bool isIndexer)
|
|
{
|
|
NameColonSyntax nameColon = ((base.CurrentToken.Kind == SyntaxKind.IdentifierToken && PeekToken(1).Kind == SyntaxKind.ColonToken) ? _syntaxFactory.NameColon(ParseIdentifierName(), EatToken(SyntaxKind.ColonToken)) : null);
|
|
SyntaxToken syntaxToken = null;
|
|
if (IsValidArgumentRefKindKeyword(base.CurrentToken.Kind) && (base.CurrentToken.Kind != SyntaxKind.RefKeyword || !IsPossibleLambdaExpression(Precedence.Expression)))
|
|
{
|
|
syntaxToken = EatToken();
|
|
}
|
|
bool flag = isIndexer;
|
|
if (flag)
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
bool flag2 = ((kind == SyntaxKind.CloseBracketToken || kind == SyntaxKind.CommaToken) ? true : false);
|
|
flag = flag2;
|
|
}
|
|
ExpressionSyntax expression = (flag ? ParseIdentifierName(ErrorCode.ERR_ValueExpected) : ((base.CurrentToken.Kind != SyntaxKind.CommaToken) ? ((syntaxToken != null && syntaxToken.Kind == SyntaxKind.OutKeyword) ? ParseExpressionOrDeclaration(ParseTypeMode.Normal, permitTupleDesignation: false) : ParseSubExpression(Precedence.Expression)) : ParseIdentifierName(ErrorCode.ERR_MissingArgument)));
|
|
return _syntaxFactory.Argument(nameColon, syntaxToken, expression);
|
|
}
|
|
|
|
private TypeOfExpressionSyntax ParseTypeOfExpression()
|
|
{
|
|
return _syntaxFactory.TypeOfExpression(EatToken(), EatToken(SyntaxKind.OpenParenToken), ParseTypeOrVoid(), EatToken(SyntaxKind.CloseParenToken));
|
|
}
|
|
|
|
private ExpressionSyntax ParseDefaultExpression()
|
|
{
|
|
SyntaxToken syntaxToken = EatToken();
|
|
if (base.CurrentToken.Kind == SyntaxKind.OpenParenToken)
|
|
{
|
|
return _syntaxFactory.DefaultExpression(syntaxToken, EatToken(SyntaxKind.OpenParenToken), ParseType(), EatToken(SyntaxKind.CloseParenToken));
|
|
}
|
|
return _syntaxFactory.LiteralExpression(SyntaxKind.DefaultLiteralExpression, syntaxToken);
|
|
}
|
|
|
|
private SizeOfExpressionSyntax ParseSizeOfExpression()
|
|
{
|
|
return _syntaxFactory.SizeOfExpression(EatToken(), EatToken(SyntaxKind.OpenParenToken), ParseType(), EatToken(SyntaxKind.CloseParenToken));
|
|
}
|
|
|
|
private MakeRefExpressionSyntax ParseMakeRefExpression()
|
|
{
|
|
return _syntaxFactory.MakeRefExpression(EatToken(), EatToken(SyntaxKind.OpenParenToken), ParseSubExpression(Precedence.Expression), EatToken(SyntaxKind.CloseParenToken));
|
|
}
|
|
|
|
private RefTypeExpressionSyntax ParseRefTypeExpression()
|
|
{
|
|
return _syntaxFactory.RefTypeExpression(EatToken(), EatToken(SyntaxKind.OpenParenToken), ParseSubExpression(Precedence.Expression), EatToken(SyntaxKind.CloseParenToken));
|
|
}
|
|
|
|
private CheckedExpressionSyntax ParseCheckedOrUncheckedExpression()
|
|
{
|
|
SyntaxToken syntaxToken = EatToken();
|
|
SyntaxKind kind = ((syntaxToken.Kind == SyntaxKind.CheckedKeyword) ? SyntaxKind.CheckedExpression : SyntaxKind.UncheckedExpression);
|
|
return _syntaxFactory.CheckedExpression(kind, syntaxToken, EatToken(SyntaxKind.OpenParenToken), ParseSubExpression(Precedence.Expression), EatToken(SyntaxKind.CloseParenToken));
|
|
}
|
|
|
|
private RefValueExpressionSyntax ParseRefValueExpression()
|
|
{
|
|
return _syntaxFactory.RefValueExpression(EatToken(SyntaxKind.RefValueKeyword), EatToken(SyntaxKind.OpenParenToken), ParseSubExpression(Precedence.Expression), EatToken(SyntaxKind.CommaToken), ParseType(), EatToken(SyntaxKind.CloseParenToken));
|
|
}
|
|
|
|
private bool ScanParenthesizedLambda(Precedence precedence)
|
|
{
|
|
if (!ScanParenthesizedImplicitlyTypedLambda(precedence))
|
|
{
|
|
return ScanExplicitlyTypedLambda(precedence);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private bool ScanParenthesizedImplicitlyTypedLambda(Precedence precedence)
|
|
{
|
|
if (precedence != Precedence.Expression)
|
|
{
|
|
return false;
|
|
}
|
|
if (isParenVarCommaSyntax())
|
|
{
|
|
int num = 3;
|
|
SyntaxToken syntaxToken;
|
|
SyntaxKind kind;
|
|
do
|
|
{
|
|
syntaxToken = PeekToken(num++);
|
|
kind = syntaxToken.Kind;
|
|
}
|
|
while (kind == SyntaxKind.IdentifierToken || kind == SyntaxKind.CommaToken || SyntaxFacts.IsPredefinedType(syntaxToken.Kind) || (!IsInQuery && IsTokenQueryContextualKeyword(syntaxToken)));
|
|
if (PeekToken(num - 1).Kind == SyntaxKind.CloseParenToken)
|
|
{
|
|
return PeekToken(num).Kind == SyntaxKind.EqualsGreaterThanToken;
|
|
}
|
|
return false;
|
|
}
|
|
if (IsTrueIdentifier(PeekToken(1)))
|
|
{
|
|
int num2 = 2;
|
|
if (PeekToken(num2).Kind == SyntaxKind.ExclamationToken && PeekToken(num2 + 1).Kind == SyntaxKind.ExclamationToken)
|
|
{
|
|
num2 += 2;
|
|
}
|
|
if (PeekToken(num2).Kind == SyntaxKind.CloseParenToken && PeekToken(num2 + 1).Kind == SyntaxKind.EqualsGreaterThanToken)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
if (PeekToken(1).Kind == SyntaxKind.CloseParenToken && PeekToken(2).Kind == SyntaxKind.EqualsGreaterThanToken)
|
|
{
|
|
return true;
|
|
}
|
|
if (PeekToken(1).Kind == SyntaxKind.ParamsKeyword)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
bool isParenVarCommaSyntax()
|
|
{
|
|
SyntaxToken syntaxToken2 = PeekToken(1);
|
|
if (syntaxToken2.Kind == SyntaxKind.IdentifierToken && (!IsInQuery || !IsTokenQueryContextualKeyword(syntaxToken2)))
|
|
{
|
|
SyntaxToken syntaxToken3 = PeekToken(2);
|
|
if (syntaxToken3.Kind == SyntaxKind.CommaToken)
|
|
{
|
|
return true;
|
|
}
|
|
SyntaxToken syntaxToken4 = PeekToken(3);
|
|
if (syntaxToken3.Kind == SyntaxKind.ExclamationToken && syntaxToken4.Kind == SyntaxKind.ExclamationToken && PeekToken(4).Kind == SyntaxKind.CommaToken)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
private bool ScanExplicitlyTypedLambda(Precedence precedence)
|
|
{
|
|
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
|
|
if (precedence != Precedence.Expression)
|
|
{
|
|
return false;
|
|
}
|
|
using (GetDisposableResetPoint(resetOnDispose: true))
|
|
{
|
|
while (true)
|
|
{
|
|
EatToken();
|
|
ParseAttributeDeclarations(inExpressionContext: true);
|
|
bool flag = false;
|
|
if (IsParameterModifierExcludingScoped(base.CurrentToken) || base.CurrentToken.ContextualKind == SyntaxKind.ScopedKeyword)
|
|
{
|
|
SyntaxListBuilder val = _pool.Allocate();
|
|
ParseParameterModifiers(val, isFunctionPointerParameter: false);
|
|
flag = val.Count != 0;
|
|
_pool.Free(val);
|
|
}
|
|
if ((flag || ShouldParseLambdaParameterType()) && ScanType() == ScanTypeFlags.NotType)
|
|
{
|
|
break;
|
|
}
|
|
SyntaxToken identifier = (IsTrueIdentifier() ? EatToken() : CreateMissingIdentifierToken());
|
|
ParseParameterNullCheck(ref identifier, out SyntaxToken equalsToken);
|
|
if (equalsToken == null)
|
|
{
|
|
equalsToken = TryEatToken(SyntaxKind.EqualsToken);
|
|
}
|
|
if (equalsToken != null)
|
|
{
|
|
ParseExpressionCore();
|
|
}
|
|
switch (base.CurrentToken.Kind)
|
|
{
|
|
case SyntaxKind.CommaToken:
|
|
break;
|
|
case SyntaxKind.CloseParenToken:
|
|
return PeekToken(1).Kind == SyntaxKind.EqualsGreaterThanToken;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
private ExpressionSyntax ParseCastOrParenExpressionOrTuple()
|
|
{
|
|
using DisposableResetPoint disposableResetPoint = GetDisposableResetPoint(resetOnDispose: false);
|
|
if (ScanCast() && !IsCurrentTokenQueryKeywordInQuery())
|
|
{
|
|
disposableResetPoint.Reset();
|
|
return _syntaxFactory.CastExpression(EatToken(SyntaxKind.OpenParenToken), ParseType(), EatToken(SyntaxKind.CloseParenToken), ParseSubExpression(Precedence.Cast));
|
|
}
|
|
disposableResetPoint.Reset();
|
|
SyntaxToken syntaxToken = EatToken(SyntaxKind.OpenParenToken);
|
|
ExpressionSyntax expressionSyntax = ParseExpressionOrDeclaration(ParseTypeMode.FirstElementOfPossibleTupleLiteral, permitTupleDesignation: true);
|
|
if (base.CurrentToken.Kind == SyntaxKind.CommaToken)
|
|
{
|
|
return ParseTupleExpressionTail(syntaxToken, _syntaxFactory.Argument(null, null, expressionSyntax));
|
|
}
|
|
if (expressionSyntax.Kind == SyntaxKind.IdentifierName && base.CurrentToken.Kind == SyntaxKind.ColonToken)
|
|
{
|
|
return ParseTupleExpressionTail(syntaxToken, _syntaxFactory.Argument(_syntaxFactory.NameColon((IdentifierNameSyntax)expressionSyntax, EatToken()), null, ParseExpressionOrDeclaration(ParseTypeMode.FirstElementOfPossibleTupleLiteral, permitTupleDesignation: true)));
|
|
}
|
|
return _syntaxFactory.ParenthesizedExpression(syntaxToken, expressionSyntax, EatToken(SyntaxKind.CloseParenToken));
|
|
}
|
|
|
|
private TupleExpressionSyntax ParseTupleExpressionTail(SyntaxToken openParen, ArgumentSyntax firstArg)
|
|
{
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
|
|
SeparatedSyntaxListBuilder<ArgumentSyntax> val = _pool.AllocateSeparated<ArgumentSyntax>();
|
|
val.Add(firstArg);
|
|
while (base.CurrentToken.Kind == SyntaxKind.CommaToken)
|
|
{
|
|
val.AddSeparator((GreenNode)(object)EatToken(SyntaxKind.CommaToken));
|
|
ExpressionSyntax expressionSyntax = ParseExpressionOrDeclaration(ParseTypeMode.AfterTupleComma, permitTupleDesignation: true);
|
|
ArgumentSyntax argumentSyntax = ((expressionSyntax.Kind != SyntaxKind.IdentifierName || base.CurrentToken.Kind != SyntaxKind.ColonToken) ? _syntaxFactory.Argument(null, null, expressionSyntax) : _syntaxFactory.Argument(_syntaxFactory.NameColon((IdentifierNameSyntax)expressionSyntax, EatToken()), null, ParseExpressionOrDeclaration(ParseTypeMode.AfterTupleComma, permitTupleDesignation: true)));
|
|
val.Add(argumentSyntax);
|
|
}
|
|
if (val.Count < 2)
|
|
{
|
|
val.AddSeparator((GreenNode)(object)SyntaxFactory.MissingToken(SyntaxKind.CommaToken));
|
|
val.Add(_syntaxFactory.Argument(null, null, AddError(CreateMissingIdentifierName(), ErrorCode.ERR_TupleTooFewElements)));
|
|
}
|
|
return _syntaxFactory.TupleExpression(openParen, _pool.ToListAndFree<ArgumentSyntax>(ref val), EatToken(SyntaxKind.CloseParenToken));
|
|
}
|
|
|
|
private bool ScanCast(bool forPattern = false)
|
|
{
|
|
if (base.CurrentToken.Kind != SyntaxKind.OpenParenToken)
|
|
{
|
|
return false;
|
|
}
|
|
EatToken();
|
|
ScanTypeFlags scanTypeFlags = ScanType(forPattern);
|
|
if (scanTypeFlags == ScanTypeFlags.NotType)
|
|
{
|
|
return false;
|
|
}
|
|
if (base.CurrentToken.Kind != SyntaxKind.CloseParenToken)
|
|
{
|
|
return false;
|
|
}
|
|
EatToken();
|
|
if (forPattern && base.CurrentToken.Kind == SyntaxKind.IdentifierToken)
|
|
{
|
|
return !isBinaryPattern();
|
|
}
|
|
switch (scanTypeFlags)
|
|
{
|
|
case ScanTypeFlags.MustBeType:
|
|
case ScanTypeFlags.AliasQualifiedName:
|
|
case ScanTypeFlags.NullableType:
|
|
case ScanTypeFlags.PointerOrMultiplication:
|
|
{
|
|
bool flag = !forPattern;
|
|
if (!flag)
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
bool flag2 = kind - 8198 <= SyntaxKind.List || kind - 8202 <= SyntaxKind.List || kind == SyntaxKind.DotDotToken || CanFollowCast(kind);
|
|
flag = flag2;
|
|
}
|
|
return flag;
|
|
}
|
|
case ScanTypeFlags.GenericTypeOrMethod:
|
|
case ScanTypeFlags.TupleType:
|
|
if (base.CurrentToken.Kind != SyntaxKind.OpenBracketToken)
|
|
{
|
|
return CanFollowCast(base.CurrentToken.Kind);
|
|
}
|
|
return true;
|
|
case ScanTypeFlags.GenericTypeOrExpression:
|
|
case ScanTypeFlags.NonGenericTypeOrExpression:
|
|
if (base.CurrentToken.Kind == SyntaxKind.OpenBracketToken && PeekToken(1).Kind == SyntaxKind.CloseBracketToken)
|
|
{
|
|
return true;
|
|
}
|
|
return CanFollowCast(base.CurrentToken.Kind);
|
|
default:
|
|
throw ExceptionUtilities.UnexpectedValue((object)scanTypeFlags);
|
|
}
|
|
bool isBinaryPattern()
|
|
{
|
|
if (!isBinaryPatternKeyword())
|
|
{
|
|
return false;
|
|
}
|
|
bool flag3 = true;
|
|
EatToken();
|
|
while (isBinaryPatternKeyword())
|
|
{
|
|
flag3 = !flag3;
|
|
EatToken();
|
|
}
|
|
return flag3 == IsPossibleSubpatternElement();
|
|
}
|
|
bool isBinaryPatternKeyword()
|
|
{
|
|
SyntaxKind contextualKind = base.CurrentToken.ContextualKind;
|
|
if (contextualKind - 8438 <= SyntaxKind.List)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
private bool IsPossibleLambdaExpression(Precedence precedence)
|
|
{
|
|
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
|
|
if (precedence != Precedence.Expression)
|
|
{
|
|
return false;
|
|
}
|
|
SyntaxToken syntaxToken = PeekToken(1);
|
|
if (syntaxToken.Kind == SyntaxKind.EqualsGreaterThanToken)
|
|
{
|
|
return true;
|
|
}
|
|
SyntaxToken syntaxToken2 = PeekToken(2);
|
|
SyntaxToken syntaxToken3 = PeekToken(3);
|
|
SyntaxKind kind = syntaxToken.Kind;
|
|
SyntaxKind kind2 = syntaxToken2.Kind;
|
|
SyntaxKind kind3 = syntaxToken3.Kind;
|
|
if (kind != SyntaxKind.ExclamationToken)
|
|
{
|
|
if (kind == SyntaxKind.ExclamationEqualsToken && kind2 == SyntaxKind.GreaterThanToken)
|
|
{
|
|
goto IL_008a;
|
|
}
|
|
}
|
|
else if (kind2 != SyntaxKind.ExclamationToken)
|
|
{
|
|
if (kind2 == SyntaxKind.ExclamationEqualsToken && kind3 == SyntaxKind.GreaterThanToken)
|
|
{
|
|
goto IL_008a;
|
|
}
|
|
}
|
|
else if (kind3 == SyntaxKind.EqualsGreaterThanToken)
|
|
{
|
|
goto IL_008a;
|
|
}
|
|
bool flag = false;
|
|
goto IL_0092;
|
|
IL_0092:
|
|
if (flag)
|
|
{
|
|
return true;
|
|
}
|
|
using (GetDisposableResetPoint(resetOnDispose: true))
|
|
{
|
|
if (base.CurrentToken.Kind != SyntaxKind.OpenBracketToken)
|
|
{
|
|
goto IL_00f8;
|
|
}
|
|
SyntaxList<AttributeListSyntax> val = ParseAttributeDeclarations(inExpressionContext: true);
|
|
int count = val.Count;
|
|
if (count < 1)
|
|
{
|
|
goto IL_00f8;
|
|
}
|
|
AttributeListSyntax attributeListSyntax = val[count - 1];
|
|
if (attributeListSyntax == null)
|
|
{
|
|
goto IL_00f8;
|
|
}
|
|
SyntaxToken closeBracketToken = attributeListSyntax.CloseBracketToken;
|
|
if (closeBracketToken == null || !((GreenNode)closeBracketToken).IsMissing)
|
|
{
|
|
goto IL_00f8;
|
|
}
|
|
flag = false;
|
|
goto end_IL_00a0;
|
|
IL_00f8:
|
|
bool flag2;
|
|
if (base.CurrentToken.Kind == SyntaxKind.StaticKeyword)
|
|
{
|
|
EatToken();
|
|
flag2 = true;
|
|
}
|
|
else if (base.CurrentToken.ContextualKind == SyntaxKind.AsyncKeyword && PeekToken(1).Kind == SyntaxKind.StaticKeyword)
|
|
{
|
|
EatToken();
|
|
EatToken();
|
|
flag2 = true;
|
|
}
|
|
else
|
|
{
|
|
flag2 = false;
|
|
}
|
|
if (!flag2)
|
|
{
|
|
goto IL_0185;
|
|
}
|
|
if (base.CurrentToken.Kind == SyntaxKind.EqualsGreaterThanToken)
|
|
{
|
|
flag = true;
|
|
}
|
|
else
|
|
{
|
|
if (base.CurrentToken.Kind != SyntaxKind.OpenParenToken)
|
|
{
|
|
goto IL_0185;
|
|
}
|
|
flag = true;
|
|
}
|
|
goto end_IL_00a0;
|
|
IL_0185:
|
|
if (base.CurrentToken.Kind == SyntaxKind.IdentifierToken && PeekToken(1).Kind == SyntaxKind.EqualsGreaterThanToken)
|
|
{
|
|
flag = true;
|
|
}
|
|
else
|
|
{
|
|
if (base.CurrentToken.ContextualKind == SyntaxKind.AsyncKeyword && IsAnonymousFunctionAsyncModifier())
|
|
{
|
|
EatToken();
|
|
}
|
|
using (DisposableResetPoint disposableResetPoint = GetDisposableResetPoint(resetOnDispose: false))
|
|
{
|
|
if (ScanType() == ScanTypeFlags.NotType || base.CurrentToken.Kind != SyntaxKind.OpenParenToken)
|
|
{
|
|
disposableResetPoint.Reset();
|
|
}
|
|
}
|
|
flag = (base.CurrentToken.Kind == SyntaxKind.IdentifierToken && PeekToken(1).Kind == SyntaxKind.EqualsGreaterThanToken) || (base.CurrentToken.Kind == SyntaxKind.OpenParenToken && ScanParenthesizedLambda(precedence));
|
|
}
|
|
end_IL_00a0:;
|
|
}
|
|
return flag;
|
|
IL_008a:
|
|
flag = true;
|
|
goto IL_0092;
|
|
}
|
|
|
|
private static bool CanFollowCast(SyntaxKind kind)
|
|
{
|
|
switch (kind)
|
|
{
|
|
case SyntaxKind.PercentToken:
|
|
case SyntaxKind.CaretToken:
|
|
case SyntaxKind.AmpersandToken:
|
|
case SyntaxKind.AsteriskToken:
|
|
case SyntaxKind.CloseParenToken:
|
|
case SyntaxKind.MinusToken:
|
|
case SyntaxKind.PlusToken:
|
|
case SyntaxKind.EqualsToken:
|
|
case SyntaxKind.OpenBraceToken:
|
|
case SyntaxKind.CloseBraceToken:
|
|
case SyntaxKind.OpenBracketToken:
|
|
case SyntaxKind.CloseBracketToken:
|
|
case SyntaxKind.BarToken:
|
|
case SyntaxKind.ColonToken:
|
|
case SyntaxKind.SemicolonToken:
|
|
case SyntaxKind.LessThanToken:
|
|
case SyntaxKind.CommaToken:
|
|
case SyntaxKind.GreaterThanToken:
|
|
case SyntaxKind.DotToken:
|
|
case SyntaxKind.QuestionToken:
|
|
case SyntaxKind.SlashToken:
|
|
case SyntaxKind.DotDotToken:
|
|
case SyntaxKind.BarBarToken:
|
|
case SyntaxKind.AmpersandAmpersandToken:
|
|
case SyntaxKind.MinusMinusToken:
|
|
case SyntaxKind.PlusPlusToken:
|
|
case SyntaxKind.QuestionQuestionToken:
|
|
case SyntaxKind.MinusGreaterThanToken:
|
|
case SyntaxKind.ExclamationEqualsToken:
|
|
case SyntaxKind.EqualsEqualsToken:
|
|
case SyntaxKind.EqualsGreaterThanToken:
|
|
case SyntaxKind.LessThanEqualsToken:
|
|
case SyntaxKind.LessThanLessThanToken:
|
|
case SyntaxKind.LessThanLessThanEqualsToken:
|
|
case SyntaxKind.GreaterThanEqualsToken:
|
|
case SyntaxKind.GreaterThanGreaterThanToken:
|
|
case SyntaxKind.GreaterThanGreaterThanEqualsToken:
|
|
case SyntaxKind.SlashEqualsToken:
|
|
case SyntaxKind.AsteriskEqualsToken:
|
|
case SyntaxKind.BarEqualsToken:
|
|
case SyntaxKind.AmpersandEqualsToken:
|
|
case SyntaxKind.PlusEqualsToken:
|
|
case SyntaxKind.MinusEqualsToken:
|
|
case SyntaxKind.CaretEqualsToken:
|
|
case SyntaxKind.PercentEqualsToken:
|
|
case SyntaxKind.QuestionQuestionEqualsToken:
|
|
case SyntaxKind.GreaterThanGreaterThanGreaterThanToken:
|
|
case SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken:
|
|
case SyntaxKind.SwitchKeyword:
|
|
case SyntaxKind.IsKeyword:
|
|
case SyntaxKind.AsKeyword:
|
|
case SyntaxKind.EndOfFileToken:
|
|
return false;
|
|
default:
|
|
return true;
|
|
}
|
|
}
|
|
|
|
private ExpressionSyntax ParseNewExpression()
|
|
{
|
|
if (IsAnonymousType())
|
|
{
|
|
return ParseAnonymousTypeExpression();
|
|
}
|
|
if (IsImplicitlyTypedArray())
|
|
{
|
|
return ParseImplicitlyTypedArrayCreation();
|
|
}
|
|
return ParseArrayOrObjectCreationExpression();
|
|
}
|
|
|
|
private CollectionExpressionSyntax ParseCollectionExpression()
|
|
{
|
|
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxToken openToken = EatToken(SyntaxKind.OpenBracketToken);
|
|
SeparatedSyntaxList<CollectionElementSyntax> elements = ParseCommaSeparatedSyntaxList(ref openToken, SyntaxKind.CloseBracketToken, (LanguageParser @this) => @this.IsPossibleCollectionElement(), (LanguageParser @this) => @this.ParseCollectionElement(), skipBadCollectionElementTokens, allowTrailingSeparator: true, requireOneElement: false, allowSemicolonAsSeparator: false);
|
|
return _syntaxFactory.CollectionExpression(openToken, elements, EatToken(SyntaxKind.CloseBracketToken));
|
|
static PostSkipAction skipBadCollectionElementTokens(LanguageParser @this, ref SyntaxToken openBracket, SeparatedSyntaxListBuilder<CollectionElementSyntax> list, SyntaxKind expectedKind, SyntaxKind closeKind)
|
|
{
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
|
return @this.SkipBadSeparatedListTokensWithExpectedKind<SyntaxToken, CollectionElementSyntax>(ref openBracket, list, (LanguageParser p) => p.CurrentToken.Kind != SyntaxKind.CommaToken && !p.IsPossibleCollectionElement(), (LanguageParser p, SyntaxKind syntaxKind) => p.CurrentToken.Kind == syntaxKind, expectedKind, closeKind);
|
|
}
|
|
}
|
|
|
|
private bool IsPossibleCollectionElement()
|
|
{
|
|
return IsPossibleExpression();
|
|
}
|
|
|
|
private CollectionElementSyntax ParseCollectionElement()
|
|
{
|
|
SyntaxToken syntaxToken = TryEatToken(SyntaxKind.DotDotToken);
|
|
if (syntaxToken != null)
|
|
{
|
|
return _syntaxFactory.SpreadElement(syntaxToken, ParseExpressionCore());
|
|
}
|
|
ExpressionSyntax expression = ParseExpressionCore();
|
|
return _syntaxFactory.ExpressionElement(expression);
|
|
}
|
|
|
|
private bool IsAnonymousType()
|
|
{
|
|
if (base.CurrentToken.Kind == SyntaxKind.NewKeyword)
|
|
{
|
|
return PeekToken(1).Kind == SyntaxKind.OpenBraceToken;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private AnonymousObjectCreationExpressionSyntax ParseAnonymousTypeExpression()
|
|
{
|
|
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxToken newKeyword = EatToken(SyntaxKind.NewKeyword);
|
|
SyntaxToken openToken = EatToken(SyntaxKind.OpenBraceToken);
|
|
SeparatedSyntaxList<AnonymousObjectMemberDeclaratorSyntax> initializers = ParseCommaSeparatedSyntaxList(ref openToken, SyntaxKind.CloseBraceToken, (LanguageParser @this) => @this.IsPossibleExpression(), (LanguageParser @this) => @this.ParseAnonymousTypeMemberInitializer(), SkipBadInitializerListTokens<AnonymousObjectMemberDeclaratorSyntax>, allowTrailingSeparator: true, requireOneElement: false, allowSemicolonAsSeparator: false);
|
|
return _syntaxFactory.AnonymousObjectCreationExpression(newKeyword, openToken, initializers, EatToken(SyntaxKind.CloseBraceToken));
|
|
}
|
|
|
|
private AnonymousObjectMemberDeclaratorSyntax ParseAnonymousTypeMemberInitializer()
|
|
{
|
|
return _syntaxFactory.AnonymousObjectMemberDeclarator(IsNamedAssignment() ? ParseNameEquals() : null, ParseExpressionCore());
|
|
}
|
|
|
|
private bool IsInitializerMember()
|
|
{
|
|
if (!IsComplexElementInitializer() && !IsNamedAssignment() && !IsDictionaryInitializer())
|
|
{
|
|
return IsPossibleExpression();
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private bool IsComplexElementInitializer()
|
|
{
|
|
return base.CurrentToken.Kind == SyntaxKind.OpenBraceToken;
|
|
}
|
|
|
|
private bool IsNamedAssignment()
|
|
{
|
|
if (IsTrueIdentifier())
|
|
{
|
|
return PeekToken(1).Kind == SyntaxKind.EqualsToken;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private bool IsDictionaryInitializer()
|
|
{
|
|
return base.CurrentToken.Kind == SyntaxKind.OpenBracketToken;
|
|
}
|
|
|
|
private ExpressionSyntax ParseArrayOrObjectCreationExpression()
|
|
{
|
|
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxToken newKeyword = EatToken(SyntaxKind.NewKeyword);
|
|
TypeSyntax typeSyntax = null;
|
|
InitializerExpressionSyntax initializerExpressionSyntax = null;
|
|
if (!IsImplicitObjectCreation())
|
|
{
|
|
typeSyntax = ParseType(ParseTypeMode.NewExpression);
|
|
if (typeSyntax.Kind == SyntaxKind.ArrayType)
|
|
{
|
|
if (base.CurrentToken.Kind == SyntaxKind.OpenBraceToken)
|
|
{
|
|
initializerExpressionSyntax = ParseArrayInitializer();
|
|
}
|
|
return _syntaxFactory.ArrayCreationExpression(newKeyword, (ArrayTypeSyntax)typeSyntax, initializerExpressionSyntax);
|
|
}
|
|
}
|
|
ArgumentListSyntax argumentListSyntax = null;
|
|
if (base.CurrentToken.Kind == SyntaxKind.OpenParenToken)
|
|
{
|
|
argumentListSyntax = ParseParenthesizedArgumentList();
|
|
}
|
|
if (base.CurrentToken.Kind == SyntaxKind.OpenBraceToken)
|
|
{
|
|
initializerExpressionSyntax = ParseObjectOrCollectionInitializer();
|
|
}
|
|
if (argumentListSyntax == null && initializerExpressionSyntax == null)
|
|
{
|
|
argumentListSyntax = _syntaxFactory.ArgumentList(EatToken(SyntaxKind.OpenParenToken, ErrorCode.ERR_BadNewExpr, typeSyntax != null && !((GreenNode)typeSyntax).ContainsDiagnostics), default(SeparatedSyntaxList<ArgumentSyntax>), SyntaxFactory.MissingToken(SyntaxKind.CloseParenToken));
|
|
}
|
|
if (typeSyntax != null)
|
|
{
|
|
return _syntaxFactory.ObjectCreationExpression(newKeyword, typeSyntax, argumentListSyntax, initializerExpressionSyntax);
|
|
}
|
|
return _syntaxFactory.ImplicitObjectCreationExpression(newKeyword, argumentListSyntax, initializerExpressionSyntax);
|
|
}
|
|
|
|
private bool IsImplicitObjectCreation()
|
|
{
|
|
if (base.CurrentToken.Kind != SyntaxKind.OpenParenToken)
|
|
{
|
|
return false;
|
|
}
|
|
using (GetDisposableResetPoint(resetOnDispose: true))
|
|
{
|
|
EatToken();
|
|
if (ScanTupleType(out var _) != ScanTypeFlags.NotType)
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
if (kind == SyntaxKind.OpenParenToken || kind == SyntaxKind.OpenBracketToken || kind == SyntaxKind.QuestionToken)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
|
|
private WithExpressionSyntax ParseWithExpression(ExpressionSyntax receiverExpression, SyntaxToken withKeyword)
|
|
{
|
|
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxToken openToken = EatToken(SyntaxKind.OpenBraceToken);
|
|
SeparatedSyntaxList<ExpressionSyntax> expressions = ParseCommaSeparatedSyntaxList(ref openToken, SyntaxKind.CloseBraceToken, (LanguageParser @this) => @this.IsPossibleExpression(), (LanguageParser @this) => @this.ParseExpressionCore(), SkipBadInitializerListTokens<ExpressionSyntax>, allowTrailingSeparator: true, requireOneElement: false, allowSemicolonAsSeparator: false);
|
|
return _syntaxFactory.WithExpression(receiverExpression, withKeyword, _syntaxFactory.InitializerExpression(SyntaxKind.WithInitializerExpression, openToken, expressions, EatToken(SyntaxKind.CloseBraceToken)));
|
|
}
|
|
|
|
private InitializerExpressionSyntax ParseObjectOrCollectionInitializer()
|
|
{
|
|
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxToken openToken = EatToken(SyntaxKind.OpenBraceToken);
|
|
SeparatedSyntaxList<ExpressionSyntax> val = ParseCommaSeparatedSyntaxList(ref openToken, SyntaxKind.CloseBraceToken, (LanguageParser @this) => @this.IsInitializerMember(), (LanguageParser @this) => @this.ParseObjectOrCollectionInitializerMember(), SkipBadInitializerListTokens<ExpressionSyntax>, allowTrailingSeparator: true, requireOneElement: false, allowSemicolonAsSeparator: false);
|
|
SyntaxKind kind = (isObjectInitializer(val) ? SyntaxKind.ObjectInitializerExpression : SyntaxKind.CollectionInitializerExpression);
|
|
return _syntaxFactory.InitializerExpression(kind, openToken, val, EatToken(SyntaxKind.CloseBraceToken));
|
|
static bool isObjectInitializer(SeparatedSyntaxList<ExpressionSyntax> initializers)
|
|
{
|
|
if (initializers.Count == 0)
|
|
{
|
|
return true;
|
|
}
|
|
int num = 0;
|
|
int count = initializers.Count;
|
|
while (num < count)
|
|
{
|
|
ExpressionSyntax expressionSyntax = initializers[num];
|
|
bool flag;
|
|
if (expressionSyntax is AssignmentExpressionSyntax assignmentExpressionSyntax && expressionSyntax.Kind == SyntaxKind.SimpleAssignmentExpression)
|
|
{
|
|
ExpressionSyntax left = assignmentExpressionSyntax.Left;
|
|
if (left != null)
|
|
{
|
|
SyntaxKind kind2 = left.Kind;
|
|
if (kind2 == SyntaxKind.IdentifierName || kind2 == SyntaxKind.ImplicitElementAccess)
|
|
{
|
|
flag = true;
|
|
goto IL_0066;
|
|
}
|
|
}
|
|
}
|
|
flag = false;
|
|
goto IL_0066;
|
|
IL_0066:
|
|
if (flag)
|
|
{
|
|
return true;
|
|
}
|
|
num++;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
private ExpressionSyntax ParseObjectOrCollectionInitializerMember()
|
|
{
|
|
if (IsComplexElementInitializer())
|
|
{
|
|
return ParseComplexElementInitializer();
|
|
}
|
|
if (IsDictionaryInitializer())
|
|
{
|
|
return ParseDictionaryInitializer();
|
|
}
|
|
if (IsNamedAssignment())
|
|
{
|
|
return ParseObjectInitializerNamedAssignment();
|
|
}
|
|
return ParsePossibleRefExpression();
|
|
}
|
|
|
|
private static PostSkipAction SkipBadInitializerListTokens<T>(LanguageParser @this, ref SyntaxToken startToken, SeparatedSyntaxListBuilder<T> list, SyntaxKind expectedKind, SyntaxKind closeKind) where T : CSharpSyntaxNode
|
|
{
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
|
return @this.SkipBadSeparatedListTokensWithExpectedKind<SyntaxToken, T>(ref startToken, list, (LanguageParser p) => p.CurrentToken.Kind != SyntaxKind.CommaToken && !p.IsPossibleExpression(), (LanguageParser p, SyntaxKind syntaxKind) => p.CurrentToken.Kind == syntaxKind, expectedKind, closeKind);
|
|
}
|
|
|
|
private AssignmentExpressionSyntax ParseObjectInitializerNamedAssignment()
|
|
{
|
|
return _syntaxFactory.AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, ParseIdentifierName(), EatToken(SyntaxKind.EqualsToken), (base.CurrentToken.Kind == SyntaxKind.OpenBraceToken) ? ParseObjectOrCollectionInitializer() : ParsePossibleRefExpression());
|
|
}
|
|
|
|
private AssignmentExpressionSyntax ParseDictionaryInitializer()
|
|
{
|
|
return _syntaxFactory.AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, _syntaxFactory.ImplicitElementAccess(ParseBracketedArgumentList()), EatToken(SyntaxKind.EqualsToken), (base.CurrentToken.Kind == SyntaxKind.OpenBraceToken) ? ParseObjectOrCollectionInitializer() : ParsePossibleRefExpression());
|
|
}
|
|
|
|
private InitializerExpressionSyntax ParseComplexElementInitializer()
|
|
{
|
|
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxToken openToken = EatToken(SyntaxKind.OpenBraceToken);
|
|
SeparatedSyntaxList<ExpressionSyntax> expressions = ParseCommaSeparatedSyntaxList(ref openToken, SyntaxKind.CloseBraceToken, (LanguageParser @this) => @this.IsPossibleExpression(), (LanguageParser @this) => @this.ParseExpressionCore(), SkipBadInitializerListTokens<ExpressionSyntax>, allowTrailingSeparator: false, requireOneElement: false, allowSemicolonAsSeparator: false);
|
|
return _syntaxFactory.InitializerExpression(SyntaxKind.ComplexElementInitializerExpression, openToken, expressions, EatToken(SyntaxKind.CloseBraceToken));
|
|
}
|
|
|
|
private bool IsImplicitlyTypedArray()
|
|
{
|
|
return PeekToken(1).Kind == SyntaxKind.OpenBracketToken;
|
|
}
|
|
|
|
private ImplicitArrayCreationExpressionSyntax ParseImplicitlyTypedArrayCreation()
|
|
{
|
|
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxToken newKeyword = EatToken(SyntaxKind.NewKeyword);
|
|
SyntaxToken syntaxToken = EatToken(SyntaxKind.OpenBracketToken);
|
|
SyntaxListBuilder val = _pool.Allocate();
|
|
int lastTokenPosition = -1;
|
|
while (IsMakingProgress(ref lastTokenPosition))
|
|
{
|
|
if (IsPossibleExpression())
|
|
{
|
|
ExpressionSyntax skippedSyntax = AddError(ParseExpressionCore(), ErrorCode.ERR_InvalidArray);
|
|
if (val.Count == 0)
|
|
{
|
|
syntaxToken = AddTrailingSkippedSyntax(syntaxToken, (GreenNode)(object)skippedSyntax);
|
|
}
|
|
else
|
|
{
|
|
AddTrailingSkippedSyntax(val, (GreenNode)(object)skippedSyntax);
|
|
}
|
|
}
|
|
if (base.CurrentToken.Kind != SyntaxKind.CommaToken)
|
|
{
|
|
break;
|
|
}
|
|
val.Add((GreenNode)(object)EatToken());
|
|
}
|
|
return _syntaxFactory.ImplicitArrayCreationExpression(newKeyword, syntaxToken, _pool.ToTokenListAndFree(val), EatToken(SyntaxKind.CloseBracketToken), ParseArrayInitializer());
|
|
}
|
|
|
|
private InitializerExpressionSyntax ParseArrayInitializer()
|
|
{
|
|
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxToken openToken = EatToken(SyntaxKind.OpenBraceToken);
|
|
SeparatedSyntaxList<ExpressionSyntax> expressions = ParseCommaSeparatedSyntaxList(ref openToken, SyntaxKind.CloseBraceToken, (LanguageParser @this) => @this.IsPossibleVariableInitializer(), (LanguageParser @this) => @this.ParseVariableInitializer(), skipBadArrayInitializerTokens, allowTrailingSeparator: true, requireOneElement: false, allowSemicolonAsSeparator: false);
|
|
return _syntaxFactory.InitializerExpression(SyntaxKind.ArrayInitializerExpression, openToken, expressions, EatToken(SyntaxKind.CloseBraceToken));
|
|
static PostSkipAction skipBadArrayInitializerTokens(LanguageParser @this, ref SyntaxToken openBrace, SeparatedSyntaxListBuilder<ExpressionSyntax> list, SyntaxKind expectedKind, SyntaxKind closeKind)
|
|
{
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
|
return @this.SkipBadSeparatedListTokensWithExpectedKind<SyntaxToken, ExpressionSyntax>(ref openBrace, list, (LanguageParser p) => p.CurrentToken.Kind != SyntaxKind.CommaToken && !p.IsPossibleVariableInitializer(), (LanguageParser p, SyntaxKind syntaxKind) => p.CurrentToken.Kind == syntaxKind, expectedKind, closeKind);
|
|
}
|
|
}
|
|
|
|
private ExpressionSyntax ParseStackAllocExpression()
|
|
{
|
|
if (!IsImplicitlyTypedArray())
|
|
{
|
|
return ParseRegularStackAllocExpression();
|
|
}
|
|
return ParseImplicitlyTypedStackAllocExpression();
|
|
}
|
|
|
|
private ExpressionSyntax ParseImplicitlyTypedStackAllocExpression()
|
|
{
|
|
SyntaxToken stackAllocKeyword = EatToken(SyntaxKind.StackAllocKeyword);
|
|
SyntaxToken syntaxToken = EatToken(SyntaxKind.OpenBracketToken);
|
|
int lastTokenPosition = -1;
|
|
while (IsMakingProgress(ref lastTokenPosition))
|
|
{
|
|
if (IsPossibleExpression())
|
|
{
|
|
ExpressionSyntax skippedSyntax = AddError(ParseExpressionCore(), ErrorCode.ERR_InvalidStackAllocArray);
|
|
syntaxToken = AddTrailingSkippedSyntax(syntaxToken, (GreenNode)(object)skippedSyntax);
|
|
}
|
|
if (base.CurrentToken.Kind != SyntaxKind.CommaToken)
|
|
{
|
|
break;
|
|
}
|
|
SyntaxToken skippedSyntax2 = AddError(EatToken(), ErrorCode.ERR_InvalidStackAllocArray);
|
|
syntaxToken = AddTrailingSkippedSyntax(syntaxToken, (GreenNode)(object)skippedSyntax2);
|
|
}
|
|
return _syntaxFactory.ImplicitStackAllocArrayCreationExpression(stackAllocKeyword, syntaxToken, EatToken(SyntaxKind.CloseBracketToken), ParseArrayInitializer());
|
|
}
|
|
|
|
private ExpressionSyntax ParseRegularStackAllocExpression()
|
|
{
|
|
return _syntaxFactory.StackAllocArrayCreationExpression(EatToken(SyntaxKind.StackAllocKeyword), ParseType(), (base.CurrentToken.Kind == SyntaxKind.OpenBraceToken) ? ParseArrayInitializer() : null);
|
|
}
|
|
|
|
private AnonymousMethodExpressionSyntax ParseAnonymousMethodExpression()
|
|
{
|
|
bool isInAsync = IsInAsync;
|
|
bool forceConditionalAccessExpression = ForceConditionalAccessExpression;
|
|
ForceConditionalAccessExpression = false;
|
|
AnonymousMethodExpressionSyntax result = parseAnonymousMethodExpressionWorker();
|
|
ForceConditionalAccessExpression = forceConditionalAccessExpression;
|
|
IsInAsync = isInAsync;
|
|
return result;
|
|
AnonymousMethodExpressionSyntax parseAnonymousMethodExpressionWorker()
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxList<SyntaxToken> modifiers = ParseAnonymousFunctionModifiers();
|
|
if (modifiers.Any(8435))
|
|
{
|
|
IsInAsync = true;
|
|
}
|
|
SyntaxToken delegateKeyword = EatToken(SyntaxKind.DelegateKeyword);
|
|
ParameterListSyntax parameterList = null;
|
|
if (base.CurrentToken.Kind == SyntaxKind.OpenParenToken)
|
|
{
|
|
parameterList = ParseParenthesizedParameterList();
|
|
}
|
|
if (base.CurrentToken.Kind != SyntaxKind.OpenBraceToken)
|
|
{
|
|
SyntaxToken openBraceToken = EatToken(SyntaxKind.OpenBraceToken);
|
|
return _syntaxFactory.AnonymousMethodExpression(modifiers, delegateKeyword, parameterList, _syntaxFactory.Block(default(SyntaxList<AttributeListSyntax>), openBraceToken, default(SyntaxList<StatementSyntax>), SyntaxFactory.MissingToken(SyntaxKind.CloseBraceToken)), null);
|
|
}
|
|
return _syntaxFactory.AnonymousMethodExpression(modifiers, delegateKeyword, parameterList, ParseBlock(default(SyntaxList<AttributeListSyntax>)), null);
|
|
}
|
|
}
|
|
|
|
private SyntaxList<SyntaxToken> ParseAnonymousFunctionModifiers()
|
|
{
|
|
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxListBuilder val = _pool.Allocate();
|
|
while (true)
|
|
{
|
|
if (base.CurrentToken.Kind == SyntaxKind.StaticKeyword)
|
|
{
|
|
val.Add((GreenNode)(object)EatToken(SyntaxKind.StaticKeyword));
|
|
continue;
|
|
}
|
|
if (base.CurrentToken.ContextualKind != SyntaxKind.AsyncKeyword || !IsAnonymousFunctionAsyncModifier())
|
|
{
|
|
break;
|
|
}
|
|
val.Add((GreenNode)(object)EatContextualToken(SyntaxKind.AsyncKeyword));
|
|
}
|
|
return _pool.ToTokenListAndFree(val);
|
|
}
|
|
|
|
private bool IsAnonymousFunctionAsyncModifier()
|
|
{
|
|
SyntaxKind kind = PeekToken(1).Kind;
|
|
switch (kind)
|
|
{
|
|
case SyntaxKind.OpenParenToken:
|
|
case SyntaxKind.StaticKeyword:
|
|
case SyntaxKind.RefKeyword:
|
|
case SyntaxKind.DelegateKeyword:
|
|
case SyntaxKind.IdentifierToken:
|
|
return true;
|
|
default:
|
|
return IsPredefinedType(kind);
|
|
}
|
|
}
|
|
|
|
private LambdaExpressionSyntax TryParseLambdaExpression()
|
|
{
|
|
using DisposableResetPoint disposableResetPoint = GetDisposableResetPoint(resetOnDispose: false);
|
|
LambdaExpressionSyntax lambdaExpressionSyntax = ParseLambdaExpression();
|
|
if (base.CurrentToken.Kind == SyntaxKind.ColonToken && lambdaExpressionSyntax is ParenthesizedLambdaExpressionSyntax parenthesizedLambdaExpressionSyntax && parenthesizedLambdaExpressionSyntax.ReturnType is NullableTypeSyntax)
|
|
{
|
|
disposableResetPoint.Reset();
|
|
return null;
|
|
}
|
|
return lambdaExpressionSyntax;
|
|
}
|
|
|
|
private LambdaExpressionSyntax ParseLambdaExpression()
|
|
{
|
|
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxList<AttributeListSyntax> attributes = ParseAttributeDeclarations(inExpressionContext: true);
|
|
bool isInAsync = IsInAsync;
|
|
bool forceConditionalAccessExpression = ForceConditionalAccessExpression;
|
|
ForceConditionalAccessExpression = false;
|
|
LambdaExpressionSyntax result = parseLambdaExpressionWorker();
|
|
ForceConditionalAccessExpression = forceConditionalAccessExpression;
|
|
IsInAsync = isInAsync;
|
|
return result;
|
|
LambdaExpressionSyntax parseLambdaExpressionWorker()
|
|
{
|
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxList<SyntaxToken> modifiers = ParseAnonymousFunctionModifiers();
|
|
if (modifiers.Any(8435))
|
|
{
|
|
IsInAsync = true;
|
|
}
|
|
TypeSyntax returnType;
|
|
using (DisposableResetPoint disposableResetPoint = GetDisposableResetPoint(resetOnDispose: false))
|
|
{
|
|
returnType = ParseReturnType();
|
|
if (base.CurrentToken.Kind != SyntaxKind.OpenParenToken)
|
|
{
|
|
disposableResetPoint.Reset();
|
|
returnType = null;
|
|
}
|
|
}
|
|
if (base.CurrentToken.Kind == SyntaxKind.OpenParenToken)
|
|
{
|
|
ParameterListSyntax parameterList = ParseLambdaParameterList();
|
|
SyntaxToken arrowToken = EatToken(SyntaxKind.EqualsGreaterThanToken);
|
|
var (block, expressionBody) = ParseLambdaBody();
|
|
return _syntaxFactory.ParenthesizedLambdaExpression(attributes, modifiers, returnType, parameterList, arrowToken, block, expressionBody);
|
|
}
|
|
SyntaxToken identifier = ((base.CurrentToken.Kind != SyntaxKind.IdentifierToken && PeekToken(1).Kind == SyntaxKind.EqualsGreaterThanToken) ? EatTokenAsKind(SyntaxKind.IdentifierToken) : ParseIdentifierToken());
|
|
ParseParameterNullCheck(ref identifier, out SyntaxToken equalsToken);
|
|
SyntaxToken arrowToken2;
|
|
if (equalsToken != null)
|
|
{
|
|
SyntaxToken t = EatToken();
|
|
arrowToken2 = MergeAdjacent(equalsToken, t, SyntaxKind.EqualsGreaterThanToken);
|
|
}
|
|
else
|
|
{
|
|
arrowToken2 = EatToken(SyntaxKind.EqualsGreaterThanToken);
|
|
}
|
|
ParameterSyntax parameter = _syntaxFactory.Parameter(default(SyntaxList<AttributeListSyntax>), default(SyntaxList<SyntaxToken>), null, identifier, null);
|
|
var (block2, expressionBody2) = ParseLambdaBody();
|
|
return _syntaxFactory.SimpleLambdaExpression(attributes, modifiers, parameter, arrowToken2, block2, expressionBody2);
|
|
}
|
|
}
|
|
|
|
private (BlockSyntax, ExpressionSyntax) ParseLambdaBody()
|
|
{
|
|
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
|
|
if (base.CurrentToken.Kind != SyntaxKind.OpenBraceToken)
|
|
{
|
|
return (null, ParsePossibleRefExpression());
|
|
}
|
|
return (ParseBlock(default(SyntaxList<AttributeListSyntax>)), null);
|
|
}
|
|
|
|
private ParameterListSyntax ParseLambdaParameterList()
|
|
{
|
|
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxToken openToken = EatToken(SyntaxKind.OpenParenToken);
|
|
TerminatorState termState = _termState;
|
|
_termState |= TerminatorState.IsEndOfParameterList;
|
|
SeparatedSyntaxList<ParameterSyntax> parameters = ParseCommaSeparatedSyntaxList(ref openToken, SyntaxKind.CloseParenToken, (LanguageParser @this) => @this.IsPossibleLambdaParameter(), (LanguageParser @this) => @this.ParseLambdaParameter(), skipBadLambdaParameterListTokens, allowTrailingSeparator: false, requireOneElement: false, allowSemicolonAsSeparator: false);
|
|
_termState = termState;
|
|
return _syntaxFactory.ParameterList(openToken, parameters, EatToken(SyntaxKind.CloseParenToken));
|
|
static PostSkipAction skipBadLambdaParameterListTokens(LanguageParser @this, ref SyntaxToken openParen, SeparatedSyntaxListBuilder<ParameterSyntax> list, SyntaxKind expectedKind, SyntaxKind closeKind)
|
|
{
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
|
return @this.SkipBadSeparatedListTokensWithExpectedKind<SyntaxToken, ParameterSyntax>(ref openParen, list, (LanguageParser p) => p.CurrentToken.Kind != SyntaxKind.CommaToken && !p.IsPossibleLambdaParameter(), (LanguageParser p, SyntaxKind syntaxKind) => p.CurrentToken.Kind == syntaxKind, expectedKind, closeKind);
|
|
}
|
|
}
|
|
|
|
private bool IsPossibleLambdaParameter()
|
|
{
|
|
switch (base.CurrentToken.Kind)
|
|
{
|
|
case SyntaxKind.OpenParenToken:
|
|
case SyntaxKind.OpenBracketToken:
|
|
case SyntaxKind.ReadOnlyKeyword:
|
|
case SyntaxKind.RefKeyword:
|
|
case SyntaxKind.OutKeyword:
|
|
case SyntaxKind.InKeyword:
|
|
case SyntaxKind.ParamsKeyword:
|
|
return true;
|
|
case SyntaxKind.IdentifierToken:
|
|
return IsTrueIdentifier();
|
|
case SyntaxKind.DelegateKeyword:
|
|
return IsFunctionPointerStart();
|
|
default:
|
|
return IsPredefinedType(base.CurrentToken.Kind);
|
|
}
|
|
}
|
|
|
|
private ParameterSyntax ParseLambdaParameter()
|
|
{
|
|
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxList<AttributeListSyntax> attributeLists = ParseAttributeDeclarations(inExpressionContext: false);
|
|
SyntaxListBuilder val = _pool.Allocate();
|
|
if (IsParameterModifierExcludingScoped(base.CurrentToken) || base.CurrentToken.ContextualKind == SyntaxKind.ScopedKeyword)
|
|
{
|
|
ParseParameterModifiers(val, isFunctionPointerParameter: false);
|
|
}
|
|
TypeSyntax type = ((val.Count != 0 || ShouldParseLambdaParameterType()) ? ParseType(ParseTypeMode.Parameter) : null);
|
|
SyntaxToken identifier = ParseIdentifierToken();
|
|
ParseParameterNullCheck(ref identifier, out SyntaxToken equalsToken);
|
|
if (equalsToken == null)
|
|
{
|
|
equalsToken = TryEatToken(SyntaxKind.EqualsToken);
|
|
}
|
|
return _syntaxFactory.Parameter(attributeLists, _pool.ToTokenListAndFree(val), type, identifier, (equalsToken != null) ? _syntaxFactory.EqualsValueClause(equalsToken, ParseExpressionCore()) : null);
|
|
}
|
|
|
|
private bool ShouldParseLambdaParameterType()
|
|
{
|
|
if (IsPredefinedType(base.CurrentToken.Kind))
|
|
{
|
|
return true;
|
|
}
|
|
if (base.CurrentToken.Kind == SyntaxKind.OpenParenToken)
|
|
{
|
|
return true;
|
|
}
|
|
if (IsFunctionPointerStart())
|
|
{
|
|
return true;
|
|
}
|
|
if (IsTrueIdentifier(base.CurrentToken))
|
|
{
|
|
SyntaxToken syntaxToken = PeekToken(1);
|
|
if (syntaxToken.Kind != SyntaxKind.CommaToken && syntaxToken.Kind != SyntaxKind.CloseParenToken && syntaxToken.Kind != SyntaxKind.EqualsGreaterThanToken && syntaxToken.Kind != SyntaxKind.OpenBraceToken && syntaxToken.Kind != SyntaxKind.ExclamationToken && syntaxToken.Kind != SyntaxKind.EqualsToken)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private static bool IsTokenQueryContextualKeyword(SyntaxToken token)
|
|
{
|
|
if (IsTokenStartOfNewQueryClause(token))
|
|
{
|
|
return true;
|
|
}
|
|
SyntaxKind contextualKind = token.ContextualKind;
|
|
if (contextualKind == SyntaxKind.ByKeyword || contextualKind - 8430 <= (SyntaxKind)3)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private static bool IsTokenStartOfNewQueryClause(SyntaxToken token)
|
|
{
|
|
SyntaxKind contextualKind = token.ContextualKind;
|
|
if (contextualKind - 8421 <= (SyntaxKind)5 || contextualKind - 8428 <= SyntaxKind.List)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private bool IsQueryExpression(bool mayBeVariableDeclaration, bool mayBeMemberDeclaration)
|
|
{
|
|
if (base.CurrentToken.ContextualKind == SyntaxKind.FromKeyword)
|
|
{
|
|
return IsQueryExpressionAfterFrom(mayBeVariableDeclaration, mayBeMemberDeclaration);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private bool IsQueryExpressionAfterFrom(bool mayBeVariableDeclaration, bool mayBeMemberDeclaration)
|
|
{
|
|
SyntaxKind kind = PeekToken(1).Kind;
|
|
if (IsPredefinedType(kind))
|
|
{
|
|
return true;
|
|
}
|
|
if (kind == SyntaxKind.IdentifierToken)
|
|
{
|
|
SyntaxKind kind2 = PeekToken(2).Kind;
|
|
if (kind2 == SyntaxKind.InKeyword)
|
|
{
|
|
return true;
|
|
}
|
|
if (mayBeVariableDeclaration && ((kind2 == SyntaxKind.EqualsToken || kind2 == SyntaxKind.SemicolonToken || kind2 == SyntaxKind.CommaToken) ? true : false))
|
|
{
|
|
return false;
|
|
}
|
|
if (!mayBeMemberDeclaration)
|
|
{
|
|
return true;
|
|
}
|
|
if ((kind2 == SyntaxKind.OpenParenToken || kind2 == SyntaxKind.OpenBraceToken) ? true : false)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
using (GetDisposableResetPoint(resetOnDispose: true))
|
|
{
|
|
EatToken();
|
|
bool flag = ScanType() != ScanTypeFlags.NotType;
|
|
if (flag)
|
|
{
|
|
SyntaxKind kind3 = base.CurrentToken.Kind;
|
|
bool flag2 = ((kind3 == SyntaxKind.InKeyword || kind3 == SyntaxKind.IdentifierToken) ? true : false);
|
|
flag = flag2;
|
|
}
|
|
return flag;
|
|
}
|
|
}
|
|
|
|
private QueryExpressionSyntax ParseQueryExpression(Precedence precedence)
|
|
{
|
|
bool isInQuery = IsInQuery;
|
|
IsInQuery = true;
|
|
FromClauseSyntax fromClauseSyntax = ParseFromClause();
|
|
if (precedence != Precedence.Expression)
|
|
{
|
|
fromClauseSyntax = AddError(fromClauseSyntax, ErrorCode.WRN_PrecedenceInversion, SyntaxFacts.GetText(SyntaxKind.FromKeyword));
|
|
}
|
|
QueryBodySyntax body = ParseQueryBody();
|
|
IsInQuery = isInQuery;
|
|
return _syntaxFactory.QueryExpression(fromClauseSyntax, body);
|
|
}
|
|
|
|
private QueryBodySyntax ParseQueryBody()
|
|
{
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxListBuilder<QueryClauseSyntax> val = _pool.Allocate<QueryClauseSyntax>();
|
|
while (true)
|
|
{
|
|
switch (base.CurrentToken.ContextualKind)
|
|
{
|
|
case SyntaxKind.FromKeyword:
|
|
{
|
|
FromClauseSyntax fromClauseSyntax = ParseFromClause();
|
|
val.Add((QueryClauseSyntax)fromClauseSyntax);
|
|
break;
|
|
}
|
|
case SyntaxKind.JoinKeyword:
|
|
val.Add((QueryClauseSyntax)ParseJoinClause());
|
|
break;
|
|
case SyntaxKind.LetKeyword:
|
|
val.Add((QueryClauseSyntax)ParseLetClause());
|
|
break;
|
|
case SyntaxKind.WhereKeyword:
|
|
val.Add((QueryClauseSyntax)ParseWhereClause());
|
|
break;
|
|
case SyntaxKind.OrderByKeyword:
|
|
val.Add((QueryClauseSyntax)ParseOrderByClause());
|
|
break;
|
|
default:
|
|
{
|
|
SelectOrGroupClauseSyntax selectOrGroup = base.CurrentToken.ContextualKind switch
|
|
{
|
|
SyntaxKind.SelectKeyword => ParseSelectClause(),
|
|
SyntaxKind.GroupKeyword => ParseGroupClause(),
|
|
_ => _syntaxFactory.SelectClause(EatToken(SyntaxKind.SelectKeyword, ErrorCode.ERR_ExpectedSelectOrGroup), CreateMissingIdentifierName()),
|
|
};
|
|
return _syntaxFactory.QueryBody(_pool.ToListAndFree<QueryClauseSyntax>(val), selectOrGroup, (base.CurrentToken.ContextualKind == SyntaxKind.IntoKeyword) ? ParseQueryContinuation() : null);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private FromClauseSyntax ParseFromClause()
|
|
{
|
|
SyntaxToken fromKeyword = EatContextualToken(SyntaxKind.FromKeyword);
|
|
TypeSyntax type = ((PeekToken(1).Kind != SyntaxKind.InKeyword) ? ParseType() : null);
|
|
SyntaxToken syntaxToken;
|
|
if (PeekToken(1).ContextualKind == SyntaxKind.InKeyword && (base.CurrentToken.Kind != SyntaxKind.IdentifierToken || SyntaxFacts.IsQueryContextualKeyword(base.CurrentToken.ContextualKind)))
|
|
{
|
|
syntaxToken = EatToken();
|
|
syntaxToken = WithAdditionalDiagnostics(syntaxToken, GetExpectedTokenError(SyntaxKind.IdentifierToken, syntaxToken.ContextualKind, ((GreenNode)syntaxToken).GetLeadingTriviaWidth(), ((GreenNode)syntaxToken).Width));
|
|
syntaxToken = ConvertToMissingWithTrailingTrivia(syntaxToken, SyntaxKind.IdentifierToken);
|
|
}
|
|
else
|
|
{
|
|
syntaxToken = ParseIdentifierToken();
|
|
}
|
|
return _syntaxFactory.FromClause(fromKeyword, type, syntaxToken, EatToken(SyntaxKind.InKeyword), ParseExpressionCore());
|
|
}
|
|
|
|
private JoinClauseSyntax ParseJoinClause()
|
|
{
|
|
return _syntaxFactory.JoinClause(EatContextualToken(SyntaxKind.JoinKeyword), (PeekToken(1).Kind != SyntaxKind.InKeyword) ? ParseType() : null, ParseIdentifierToken(), EatToken(SyntaxKind.InKeyword), ParseExpressionCore(), EatContextualToken(SyntaxKind.OnKeyword, ErrorCode.ERR_ExpectedContextualKeywordOn), ParseExpressionCore(), EatContextualToken(SyntaxKind.EqualsKeyword, ErrorCode.ERR_ExpectedContextualKeywordEquals), ParseExpressionCore(), (base.CurrentToken.ContextualKind == SyntaxKind.IntoKeyword) ? _syntaxFactory.JoinIntoClause(SyntaxParser.ConvertToKeyword(EatToken()), ParseIdentifierToken()) : null);
|
|
}
|
|
|
|
private LetClauseSyntax ParseLetClause()
|
|
{
|
|
return _syntaxFactory.LetClause(EatContextualToken(SyntaxKind.LetKeyword), ParseIdentifierToken(), EatToken(SyntaxKind.EqualsToken), ParseExpressionCore());
|
|
}
|
|
|
|
private WhereClauseSyntax ParseWhereClause()
|
|
{
|
|
return _syntaxFactory.WhereClause(EatContextualToken(SyntaxKind.WhereKeyword), ParseExpressionCore());
|
|
}
|
|
|
|
private OrderByClauseSyntax ParseOrderByClause()
|
|
{
|
|
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxToken orderByKeyword = EatContextualToken(SyntaxKind.OrderByKeyword);
|
|
SeparatedSyntaxListBuilder<OrderingSyntax> list = _pool.AllocateSeparated<OrderingSyntax>();
|
|
list.Add(ParseOrdering());
|
|
while (base.CurrentToken.Kind == SyntaxKind.CommaToken)
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
if ((kind == SyntaxKind.CloseParenToken || kind == SyntaxKind.SemicolonToken) ? true : false)
|
|
{
|
|
break;
|
|
}
|
|
if (base.CurrentToken.Kind == SyntaxKind.CommaToken)
|
|
{
|
|
list.AddSeparator((GreenNode)(object)EatToken(SyntaxKind.CommaToken));
|
|
list.Add(ParseOrdering());
|
|
}
|
|
else if (skipBadOrderingListTokens(list, SyntaxKind.CommaToken) == PostSkipAction.Abort)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
return _syntaxFactory.OrderByClause(orderByKeyword, _pool.ToListAndFree<OrderingSyntax>(ref list));
|
|
PostSkipAction skipBadOrderingListTokens(SeparatedSyntaxListBuilder<OrderingSyntax> list2, SyntaxKind expected)
|
|
{
|
|
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
|
|
CSharpSyntaxNode startToken = null;
|
|
return SkipBadSeparatedListTokensWithExpectedKind<CSharpSyntaxNode, OrderingSyntax>(ref startToken, list2, (LanguageParser p) => p.CurrentToken.Kind != SyntaxKind.CommaToken, (LanguageParser p, SyntaxKind _) => p.CurrentToken.Kind == SyntaxKind.CloseParenToken || p.CurrentToken.Kind == SyntaxKind.SemicolonToken || p.IsCurrentTokenQueryContextualKeyword, expected);
|
|
}
|
|
}
|
|
|
|
private OrderingSyntax ParseOrdering()
|
|
{
|
|
ExpressionSyntax expression = ParseExpressionCore();
|
|
SyntaxToken syntaxToken = null;
|
|
SyntaxKind kind = SyntaxKind.AscendingOrdering;
|
|
SyntaxKind contextualKind = base.CurrentToken.ContextualKind;
|
|
if (contextualKind - 8432 <= SyntaxKind.List)
|
|
{
|
|
syntaxToken = SyntaxParser.ConvertToKeyword(EatToken());
|
|
if (syntaxToken.Kind == SyntaxKind.DescendingKeyword)
|
|
{
|
|
kind = SyntaxKind.DescendingOrdering;
|
|
}
|
|
}
|
|
return _syntaxFactory.Ordering(kind, expression, syntaxToken);
|
|
}
|
|
|
|
private SelectClauseSyntax ParseSelectClause()
|
|
{
|
|
return _syntaxFactory.SelectClause(EatContextualToken(SyntaxKind.SelectKeyword), ParseExpressionCore());
|
|
}
|
|
|
|
private GroupClauseSyntax ParseGroupClause()
|
|
{
|
|
return _syntaxFactory.GroupClause(EatContextualToken(SyntaxKind.GroupKeyword), ParseExpressionCore(), EatContextualToken(SyntaxKind.ByKeyword, ErrorCode.ERR_ExpectedContextualKeywordBy), ParseExpressionCore());
|
|
}
|
|
|
|
private QueryContinuationSyntax ParseQueryContinuation()
|
|
{
|
|
return _syntaxFactory.QueryContinuation(EatContextualToken(SyntaxKind.IntoKeyword), ParseIdentifierToken(), ParseQueryBody());
|
|
}
|
|
|
|
internal static bool MatchesFactoryContext(GreenNode green, SyntaxFactoryContext context)
|
|
{
|
|
if (context.IsInAsync == green.ParsedInAsync)
|
|
{
|
|
return context.IsInQuery == green.ParsedInQuery;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private SeparatedSyntaxList<TNode> ParseCommaSeparatedSyntaxList<TNode>(ref SyntaxToken openToken, SyntaxKind closeTokenKind, Func<LanguageParser, bool> isPossibleElement, Func<LanguageParser, TNode> parseElement, SkipBadTokens<TNode> skipBadTokens, bool allowTrailingSeparator, bool requireOneElement, bool allowSemicolonAsSeparator) where TNode : GreenNode
|
|
{
|
|
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxKind separatorTokenKind = SyntaxKind.CommaToken;
|
|
SeparatedSyntaxListBuilder<TNode> builder = _pool.AllocateSeparated<TNode>();
|
|
while (requireOneElement || base.CurrentToken.Kind != closeTokenKind)
|
|
{
|
|
if (requireOneElement || shouldParseSeparatorOrElement())
|
|
{
|
|
builder.Add(parseElement(this));
|
|
requireOneElement = false;
|
|
int lastTokenPosition = -1;
|
|
while (IsMakingProgress(ref lastTokenPosition) && base.CurrentToken.Kind != closeTokenKind)
|
|
{
|
|
if (shouldParseSeparatorOrElement())
|
|
{
|
|
builder.AddSeparator((GreenNode)(object)((base.CurrentToken.Kind == SyntaxKind.SemicolonToken) ? EatTokenWithPrejudice(separatorTokenKind) : EatToken(separatorTokenKind)));
|
|
if (allowTrailingSeparator)
|
|
{
|
|
if (base.CurrentToken.Kind == closeTokenKind)
|
|
{
|
|
break;
|
|
}
|
|
if (!isPossibleElement(this))
|
|
{
|
|
goto IL_0031;
|
|
}
|
|
}
|
|
builder.Add(parseElement(this));
|
|
}
|
|
else if (skipBadTokens(this, ref openToken, builder, separatorTokenKind, closeTokenKind) == PostSkipAction.Abort)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
if (skipBadTokens(this, ref openToken, builder, SyntaxKind.IdentifierToken, closeTokenKind) != PostSkipAction.Continue)
|
|
{
|
|
break;
|
|
}
|
|
IL_0031:;
|
|
}
|
|
return _pool.ToListAndFree<TNode>(ref builder);
|
|
bool shouldParseSeparatorOrElement()
|
|
{
|
|
if (base.CurrentToken.Kind == separatorTokenKind)
|
|
{
|
|
return true;
|
|
}
|
|
if (allowSemicolonAsSeparator && base.CurrentToken.Kind == SyntaxKind.SemicolonToken)
|
|
{
|
|
return true;
|
|
}
|
|
if (isPossibleElement(this))
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
private DisposableResetPoint GetDisposableResetPoint(bool resetOnDispose)
|
|
{
|
|
return new DisposableResetPoint(this, resetOnDispose, GetResetPoint());
|
|
}
|
|
|
|
private new ResetPoint GetResetPoint()
|
|
{
|
|
return new ResetPoint(base.GetResetPoint(), _termState, IsInAsync, IsInQuery);
|
|
}
|
|
|
|
private void Reset(ref ResetPoint state)
|
|
{
|
|
_termState = state.TerminatorState;
|
|
IsInAsync = state.IsInAsync;
|
|
IsInQuery = state.IsInQuery;
|
|
Reset(ref state.BaseResetPoint);
|
|
}
|
|
|
|
private void Release(ref ResetPoint state)
|
|
{
|
|
Release(ref state.BaseResetPoint);
|
|
}
|
|
|
|
internal TNode ConsumeUnexpectedTokens<TNode>(TNode node) where TNode : CSharpSyntaxNode
|
|
{
|
|
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
|
|
if (base.CurrentToken.Kind == SyntaxKind.EndOfFileToken)
|
|
{
|
|
return node;
|
|
}
|
|
SyntaxListBuilder<SyntaxToken> val = _pool.Allocate<SyntaxToken>();
|
|
while (base.CurrentToken.Kind != SyntaxKind.EndOfFileToken)
|
|
{
|
|
val.Add(EatToken());
|
|
}
|
|
SyntaxList<SyntaxToken> val2 = val.ToList();
|
|
_pool.Free(SyntaxListBuilder<SyntaxToken>.op_Implicit(val));
|
|
node = AddError(node, ErrorCode.ERR_UnexpectedToken, ((object)val2[0]).ToString());
|
|
node = AddTrailingSkippedSyntax(node, val2.Node);
|
|
return node;
|
|
}
|
|
|
|
private static bool ContainsErrorDiagnostic(GreenNode node)
|
|
{
|
|
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_003d: Invalid comparison between Unknown and I4
|
|
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
|
|
if (node.ContainsDiagnostics)
|
|
{
|
|
ArrayBuilder<GreenNode> instance = ArrayBuilder<GreenNode>.GetInstance();
|
|
try
|
|
{
|
|
ArrayBuilderExtensions.Push<GreenNode>(instance, node);
|
|
while (instance.Count > 0)
|
|
{
|
|
GreenNode val = ArrayBuilderExtensions.Pop<GreenNode>(instance);
|
|
if (!val.ContainsDiagnostics)
|
|
{
|
|
continue;
|
|
}
|
|
DiagnosticInfo[] diagnostics = val.GetDiagnostics();
|
|
for (int i = 0; i < diagnostics.Length; i++)
|
|
{
|
|
if ((int)diagnostics[i].Severity == 3)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
ChildSyntaxList val2 = val.ChildNodesAndTokens();
|
|
Enumerator enumerator = ((ChildSyntaxList)(ref val2)).GetEnumerator();
|
|
while (((Enumerator)(ref enumerator)).MoveNext())
|
|
{
|
|
GreenNode current = ((Enumerator)(ref enumerator)).Current;
|
|
ArrayBuilderExtensions.Push<GreenNode>(instance, current);
|
|
}
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
instance.Free();
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private ExpressionSyntax ParseInterpolatedStringToken()
|
|
{
|
|
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxToken originalToken = EatToken();
|
|
string originalText = originalToken.ValueText;
|
|
ReadOnlySpan<char> originalTextSpan = originalText.AsSpan();
|
|
ArrayBuilder<Lexer.Interpolation> interpolations = ArrayBuilder<Lexer.Interpolation>.GetInstance();
|
|
rescanInterpolation(out var kind, out var error, out var openQuoteRange, interpolations, out var closeQuoteRange);
|
|
bool needsDedentation = kind == Lexer.InterpolatedStringKind.MultiLineRaw && error == null;
|
|
InterpolatedStringExpressionSyntax interpolatedStringExpressionSyntax = SyntaxFactory.InterpolatedStringExpression(getOpenQuote(), getContent(originalTextSpan), getCloseQuote());
|
|
interpolations.Free();
|
|
if (error != null)
|
|
{
|
|
InterpolatedStringExpressionSyntax interpolatedStringExpressionSyntax2 = interpolatedStringExpressionSyntax;
|
|
DiagnosticInfo[] infos = (DiagnosticInfo[])(object)new SyntaxDiagnosticInfo[1] { error };
|
|
GreenNode leadingTrivia = originalToken.GetLeadingTrivia();
|
|
interpolatedStringExpressionSyntax = GreenNodeExtensions.WithDiagnosticsGreen<InterpolatedStringExpressionSyntax>(interpolatedStringExpressionSyntax2, MoveDiagnostics(infos, (leadingTrivia != null) ? leadingTrivia.FullWidth : 0));
|
|
}
|
|
return interpolatedStringExpressionSyntax;
|
|
SyntaxToken getCloseQuote()
|
|
{
|
|
int kind2 = kind switch
|
|
{
|
|
Lexer.InterpolatedStringKind.Normal => 8483,
|
|
Lexer.InterpolatedStringKind.Verbatim => 8483,
|
|
Lexer.InterpolatedStringKind.SingleLineRaw => 9074,
|
|
Lexer.InterpolatedStringKind.MultiLineRaw => 9074,
|
|
_ => throw ExceptionUtilities.UnexpectedValue((object)kind),
|
|
};
|
|
string text = originalText;
|
|
Range range = closeQuoteRange;
|
|
return TokenOrMissingToken(null, (SyntaxKind)kind2, text[range.Start..range.End], originalToken.GetTrailingTrivia());
|
|
}
|
|
SyntaxList<InterpolatedStringContentSyntax> getContent(ReadOnlySpan<char> originalTextSpan2)
|
|
{
|
|
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0182: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
|
|
PooledStringBuilder instance = PooledStringBuilder.GetInstance();
|
|
SyntaxListBuilder<InterpolatedStringContentSyntax> val = _pool.Allocate<InterpolatedStringContentSyntax>();
|
|
ReadOnlySpan<char> indentationWhitespace = (needsDedentation ? getIndentationWhitespace(originalTextSpan2) : default(ReadOnlySpan<char>));
|
|
Index end = openQuoteRange.End;
|
|
Index start;
|
|
Index index;
|
|
int offset;
|
|
int length;
|
|
for (int i = 0; i < interpolations.Count; i++)
|
|
{
|
|
Lexer.Interpolation interpolation = interpolations[i];
|
|
StringBuilder content = PooledStringBuilder.op_Implicit(instance);
|
|
bool isFirst = i == 0;
|
|
index = end;
|
|
start = interpolation.OpenBraceRange.Start;
|
|
length = originalTextSpan2.Length;
|
|
offset = index.GetOffset(length);
|
|
val.Add(makeContent(indentationWhitespace, content, isFirst, isLast: false, originalTextSpan2.Slice(offset, start.GetOffset(length) - offset)));
|
|
InterpolationSyntax interpolationSyntax = ParseInterpolation(base.Options, originalText, interpolation, kind);
|
|
SyntaxDiagnosticInfo syntaxDiagnosticInfo = getInterpolationIndentationError(indentationWhitespace, interpolation);
|
|
if (syntaxDiagnosticInfo != null)
|
|
{
|
|
InterpolationSyntax interpolationSyntax2 = interpolationSyntax;
|
|
DiagnosticInfo[] array = (DiagnosticInfo[])(object)new SyntaxDiagnosticInfo[1] { syntaxDiagnosticInfo };
|
|
interpolationSyntax = GreenNodeExtensions.WithDiagnosticsGreen<InterpolationSyntax>(interpolationSyntax2, array);
|
|
}
|
|
val.Add((InterpolatedStringContentSyntax)interpolationSyntax);
|
|
end = interpolation.CloseBraceRange.End;
|
|
}
|
|
StringBuilder content2 = PooledStringBuilder.op_Implicit(instance);
|
|
bool isFirst2 = interpolations.Count == 0;
|
|
start = end;
|
|
index = closeQuoteRange.Start;
|
|
offset = originalTextSpan2.Length;
|
|
length = start.GetOffset(offset);
|
|
val.Add(makeContent(indentationWhitespace, content2, isFirst2, isLast: true, originalTextSpan2.Slice(length, index.GetOffset(offset) - length)));
|
|
SyntaxList<InterpolatedStringContentSyntax> result = SyntaxListBuilder<InterpolatedStringContentSyntax>.op_Implicit(val);
|
|
_pool.Free(SyntaxListBuilder<InterpolatedStringContentSyntax>.op_Implicit(val));
|
|
instance.Free();
|
|
return result;
|
|
}
|
|
ReadOnlySpan<char> getIndentationWhitespace(ReadOnlySpan<char> readOnlySpan)
|
|
{
|
|
Range range = closeQuoteRange;
|
|
ReadOnlySpan<char> text = readOnlySpan[range.Start..range.End];
|
|
int newLineWidth = SlidingTextWindow.GetNewLineWidth(text[0], text[1]);
|
|
int num = SkipWhitespace(text, newLineWidth);
|
|
int num2 = newLineWidth;
|
|
return text.Slice(num2, num - num2);
|
|
}
|
|
SyntaxDiagnosticInfo? getInterpolationIndentationError(ReadOnlySpan<char> indentationWhitespace, Lexer.Interpolation interpolation)
|
|
{
|
|
if (needsDedentation && !indentationWhitespace.IsEmpty)
|
|
{
|
|
int value = interpolation.OpenBraceRange.Start.Value;
|
|
if (value > 0 && SyntaxFacts.IsNewLine(originalText[value - 1]))
|
|
{
|
|
return SyntaxParser.MakeError(0, 1, ErrorCode.ERR_LineDoesNotStartWithSameWhitespace);
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
SyntaxToken getOpenQuote()
|
|
{
|
|
GreenNode leadingTrivia2 = originalToken.GetLeadingTrivia();
|
|
int kind2 = kind switch
|
|
{
|
|
Lexer.InterpolatedStringKind.Normal => 8482,
|
|
Lexer.InterpolatedStringKind.Verbatim => 8484,
|
|
Lexer.InterpolatedStringKind.SingleLineRaw => 9072,
|
|
Lexer.InterpolatedStringKind.MultiLineRaw => 9073,
|
|
_ => throw ExceptionUtilities.UnexpectedValue((object)kind),
|
|
};
|
|
string text = originalText;
|
|
Range range = openQuoteRange;
|
|
return SyntaxFactory.Token(leadingTrivia2, (SyntaxKind)kind2, text[range.Start..range.End], null);
|
|
}
|
|
InterpolatedStringContentSyntax? makeContent(ReadOnlySpan<char> indentationWhitespace, StringBuilder content, bool isFirst, bool isLast, ReadOnlySpan<char> text)
|
|
{
|
|
if (text.Length == 0)
|
|
{
|
|
return null;
|
|
}
|
|
if (!needsDedentation || indentationWhitespace.IsEmpty)
|
|
{
|
|
return SyntaxFactory.InterpolatedStringText(MakeInterpolatedStringTextToken(kind, text.ToString()));
|
|
}
|
|
content.Clear();
|
|
int num = 0;
|
|
if (!isFirst)
|
|
{
|
|
num = ConsumeRemainingContentThroughNewLine(content, text, num);
|
|
}
|
|
SyntaxDiagnosticInfo syntaxDiagnosticInfo = null;
|
|
while (num < text.Length)
|
|
{
|
|
int num2 = num;
|
|
if (syntaxDiagnosticInfo == null)
|
|
{
|
|
num = SkipWhitespace(text, num);
|
|
int num3 = num2;
|
|
ReadOnlySpan<char> readOnlySpan = text.Slice(num3, num - num3);
|
|
if (!readOnlySpan.StartsWith(indentationWhitespace) && ((!(num == text.Length && isLast) && (num >= text.Length || !SyntaxFacts.IsNewLine(text[num]))) || !indentationWhitespace.StartsWith(readOnlySpan)))
|
|
{
|
|
if (CheckForSpaceDifference(readOnlySpan, indentationWhitespace, out string currentLineMessage, out string indentationLineMessage))
|
|
{
|
|
if (syntaxDiagnosticInfo == null)
|
|
{
|
|
syntaxDiagnosticInfo = SyntaxParser.MakeError(num2, num - num2, ErrorCode.ERR_LineContainsDifferentWhitespace, currentLineMessage, indentationLineMessage);
|
|
}
|
|
}
|
|
else if (syntaxDiagnosticInfo == null)
|
|
{
|
|
syntaxDiagnosticInfo = SyntaxParser.MakeError(num2, num - num2, ErrorCode.ERR_LineDoesNotStartWithSameWhitespace);
|
|
}
|
|
}
|
|
}
|
|
num = Math.Min(num, num2 + indentationWhitespace.Length);
|
|
num = ConsumeRemainingContentThroughNewLine(content, text, num);
|
|
}
|
|
string text2 = text.ToString();
|
|
string value = ((syntaxDiagnosticInfo != null) ? text2 : content.ToString());
|
|
InterpolatedStringTextSyntax interpolatedStringTextSyntax = SyntaxFactory.InterpolatedStringText(SyntaxFactory.Literal(null, text2, SyntaxKind.InterpolatedStringTextToken, value, null));
|
|
if (syntaxDiagnosticInfo == null)
|
|
{
|
|
return interpolatedStringTextSyntax;
|
|
}
|
|
DiagnosticInfo[] array = (DiagnosticInfo[])(object)new SyntaxDiagnosticInfo[1] { syntaxDiagnosticInfo };
|
|
return GreenNodeExtensions.WithDiagnosticsGreen<InterpolatedStringTextSyntax>(interpolatedStringTextSyntax, array);
|
|
}
|
|
void rescanInterpolation(out Lexer.InterpolatedStringKind kind2, out SyntaxDiagnosticInfo? error2, out Range openQuoteRange2, ArrayBuilder<Lexer.Interpolation> interpolations2, out Range closeQuoteRange2)
|
|
{
|
|
using Lexer lexer = new Lexer(SourceText.From(originalText, (Encoding)null, (SourceHashAlgorithm)1), base.Options, allowPreprocessorDirectives: false);
|
|
Lexer.TokenInfo info = default(Lexer.TokenInfo);
|
|
lexer.ScanInterpolatedStringLiteralTop(ref info, out error2, out kind2, out openQuoteRange2, interpolations2, out closeQuoteRange2);
|
|
}
|
|
}
|
|
|
|
private static bool CheckForSpaceDifference(ReadOnlySpan<char> currentLineWhitespace, ReadOnlySpan<char> indentationLineWhitespace, [NotNullWhen(true)] out string? currentLineMessage, [NotNullWhen(true)] out string? indentationLineMessage)
|
|
{
|
|
int i = 0;
|
|
for (int num = Math.Min(currentLineWhitespace.Length, indentationLineWhitespace.Length); i < num; i++)
|
|
{
|
|
char c = currentLineWhitespace[i];
|
|
char c2 = indentationLineWhitespace[i];
|
|
if (c != c2 && SyntaxFacts.IsWhitespace(c) && SyntaxFacts.IsWhitespace(c2))
|
|
{
|
|
currentLineMessage = Lexer.CharToString(c);
|
|
indentationLineMessage = Lexer.CharToString(c2);
|
|
return true;
|
|
}
|
|
}
|
|
currentLineMessage = null;
|
|
indentationLineMessage = null;
|
|
return false;
|
|
}
|
|
|
|
private static SyntaxToken TokenOrMissingToken(GreenNode? leading, SyntaxKind kind, string text, GreenNode? trailing)
|
|
{
|
|
if (!(text == ""))
|
|
{
|
|
return SyntaxFactory.Token(leading, kind, text, trailing);
|
|
}
|
|
return SyntaxFactory.MissingToken(leading, kind, trailing);
|
|
}
|
|
|
|
private static int SkipWhitespace(ReadOnlySpan<char> text, int currentIndex)
|
|
{
|
|
while (currentIndex < text.Length && SyntaxFacts.IsWhitespace(text[currentIndex]))
|
|
{
|
|
currentIndex++;
|
|
}
|
|
return currentIndex;
|
|
}
|
|
|
|
private unsafe static int ConsumeRemainingContentThroughNewLine(StringBuilder content, ReadOnlySpan<char> text, int currentIndex)
|
|
{
|
|
int num = currentIndex;
|
|
while (currentIndex < text.Length)
|
|
{
|
|
char c = text[currentIndex];
|
|
if (!SyntaxFacts.IsNewLine(c))
|
|
{
|
|
currentIndex++;
|
|
continue;
|
|
}
|
|
currentIndex += SlidingTextWindow.GetNewLineWidth(c, (currentIndex + 1 < text.Length) ? text[currentIndex + 1] : '\0');
|
|
break;
|
|
}
|
|
int num2 = num;
|
|
ReadOnlySpan<char> readOnlySpan = text.Slice(num2, currentIndex - num2);
|
|
fixed (char* value = readOnlySpan)
|
|
{
|
|
content.Append(value, readOnlySpan.Length);
|
|
}
|
|
return currentIndex;
|
|
}
|
|
|
|
private static InterpolationSyntax ParseInterpolation(CSharpParseOptions options, string text, Lexer.Interpolation interpolation, Lexer.InterpolatedStringKind kind)
|
|
{
|
|
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
|
|
Range range = (interpolation.HasColon ? interpolation.ColonRange : interpolation.CloseBraceRange);
|
|
Index end = interpolation.OpenBraceRange.End;
|
|
Index start = range.Start;
|
|
int length = text.Length;
|
|
int offset = end.GetOffset(length);
|
|
using Lexer lexer = new Lexer(SourceText.From(text.Substring(offset, start.GetOffset(length) - offset), (Encoding)null, (SourceHashAlgorithm)1), options, allowPreprocessorDirectives: false, interpolation.HasColon);
|
|
SyntaxTriviaList val = lexer.LexSyntaxTrailingTrivia();
|
|
GreenNode node = ((SyntaxTriviaList)(ref val)).Node;
|
|
using LanguageParser languageParser = new LanguageParser(lexer, null, null);
|
|
Lexer.Interpolation interpolation2 = interpolation;
|
|
Range openBraceRange = interpolation.OpenBraceRange;
|
|
return languageParser.ParseInterpolation(text, interpolation2, kind, SyntaxFactory.Token(null, SyntaxKind.OpenBraceToken, text[openBraceRange.Start..openBraceRange.End], node));
|
|
}
|
|
|
|
private InterpolationSyntax ParseInterpolation(string text, Lexer.Interpolation interpolation, Lexer.InterpolatedStringKind kind, SyntaxToken openBraceToken)
|
|
{
|
|
var (expression, alignmentClause) = getExpressionAndAlignment();
|
|
var (formatClause, closeBraceToken) = getFormatAndCloseBrace();
|
|
return SyntaxFactory.Interpolation(openBraceToken, expression, alignmentClause, formatClause, closeBraceToken);
|
|
(ExpressionSyntax expression, InterpolationAlignmentClauseSyntax? alignment) getExpressionAndAlignment()
|
|
{
|
|
ExpressionSyntax expressionSyntax = ParseExpressionCore();
|
|
if (base.CurrentToken.Kind != SyntaxKind.CommaToken)
|
|
{
|
|
return (expression: ConsumeUnexpectedTokens(expressionSyntax), alignment: null);
|
|
}
|
|
InterpolationAlignmentClauseSyntax item = SyntaxFactory.InterpolationAlignmentClause(EatToken(SyntaxKind.CommaToken), ConsumeUnexpectedTokens(ParseExpressionCore()));
|
|
return (expression: expressionSyntax, alignment: item);
|
|
}
|
|
(InterpolationFormatClauseSyntax? format, SyntaxToken closeBraceToken) getFormatAndCloseBrace()
|
|
{
|
|
GreenNode leadingTrivia = base.CurrentToken.GetLeadingTrivia();
|
|
if (interpolation.HasColon)
|
|
{
|
|
string text2 = text;
|
|
Range colonRange = interpolation.ColonRange;
|
|
SyntaxToken colonToken = SyntaxFactory.Token(leadingTrivia, SyntaxKind.ColonToken, text2[colonRange.Start..colonRange.End], null);
|
|
Lexer.InterpolatedStringKind kind2 = kind;
|
|
string text3 = text;
|
|
Index end = interpolation.ColonRange.End;
|
|
Index start = interpolation.CloseBraceRange.Start;
|
|
int length = text3.Length;
|
|
int offset = end.GetOffset(length);
|
|
return (format: SyntaxFactory.InterpolationFormatClause(colonToken, MakeInterpolatedStringTextToken(kind2, text3.Substring(offset, start.GetOffset(length) - offset))), closeBraceToken: getInterpolationCloseToken(null));
|
|
}
|
|
return (format: null, closeBraceToken: getInterpolationCloseToken(leadingTrivia));
|
|
}
|
|
SyntaxToken getInterpolationCloseToken(GreenNode? leading)
|
|
{
|
|
string text2 = text;
|
|
Range closeBraceRange = interpolation.CloseBraceRange;
|
|
return TokenOrMissingToken(leading, SyntaxKind.CloseBraceToken, text2[closeBraceRange.Start..closeBraceRange.End], null);
|
|
}
|
|
}
|
|
|
|
private SyntaxToken MakeInterpolatedStringTextToken(Lexer.InterpolatedStringKind kind, string text)
|
|
{
|
|
if ((uint)(kind - 2) <= 1u)
|
|
{
|
|
return SyntaxFactory.Literal(null, text, SyntaxKind.InterpolatedStringTextToken, text, null);
|
|
}
|
|
string text2 = ((kind == Lexer.InterpolatedStringKind.Verbatim) ? "@\"" : "\"");
|
|
using Lexer lexer = new Lexer(SourceText.From(text2 + text + "\"", (Encoding)null, (SourceHashAlgorithm)1), base.Options, allowPreprocessorDirectives: false);
|
|
LexerMode mode = LexerMode.Syntax;
|
|
SyntaxToken syntaxToken = lexer.Lex(ref mode);
|
|
SyntaxToken syntaxToken2 = SyntaxFactory.Literal(null, text, SyntaxKind.InterpolatedStringTextToken, syntaxToken.ValueText, null);
|
|
if (((GreenNode)syntaxToken).ContainsDiagnostics)
|
|
{
|
|
syntaxToken2 = GreenNodeExtensions.WithDiagnosticsGreen<SyntaxToken>(syntaxToken2, MoveDiagnostics(((GreenNode)syntaxToken).GetDiagnostics(), -text2.Length));
|
|
}
|
|
return syntaxToken2;
|
|
}
|
|
|
|
private static DiagnosticInfo[] MoveDiagnostics(DiagnosticInfo[] infos, int offset)
|
|
{
|
|
ArrayBuilder<DiagnosticInfo> instance = ArrayBuilder<DiagnosticInfo>.GetInstance(infos.Length);
|
|
for (int i = 0; i < infos.Length; i++)
|
|
{
|
|
SyntaxDiagnosticInfo syntaxDiagnosticInfo = (SyntaxDiagnosticInfo)(object)infos[i];
|
|
instance.Add((DiagnosticInfo)(object)syntaxDiagnosticInfo.WithOffset(syntaxDiagnosticInfo.Offset + offset));
|
|
}
|
|
return instance.ToArrayAndFree();
|
|
}
|
|
|
|
private CSharpSyntaxNode ParseTypeOrPatternForIsOperator()
|
|
{
|
|
PatternSyntax patternSyntax = ParsePattern(GetPrecedence(SyntaxKind.IsPatternExpression), afterIs: true);
|
|
if (!(patternSyntax is ConstantPatternSyntax constantPatternSyntax))
|
|
{
|
|
if (patternSyntax is TypePatternSyntax typePatternSyntax)
|
|
{
|
|
return typePatternSyntax.Type;
|
|
}
|
|
if (patternSyntax is DiscardPatternSyntax discardPatternSyntax)
|
|
{
|
|
DiscardPatternSyntax discardPatternSyntax2 = discardPatternSyntax;
|
|
return _syntaxFactory.IdentifierName(SyntaxParser.ConvertToIdentifier(discardPatternSyntax2.UnderscoreToken));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ConstantPatternSyntax constantPatternSyntax2 = constantPatternSyntax;
|
|
if (ConvertExpressionToType(constantPatternSyntax2.Expression, out NameSyntax type))
|
|
{
|
|
return type;
|
|
}
|
|
}
|
|
return patternSyntax;
|
|
}
|
|
|
|
private bool ConvertExpressionToType(ExpressionSyntax expression, [NotNullWhen(true)] out NameSyntax? type)
|
|
{
|
|
if (!(expression is SimpleNameSyntax simpleNameSyntax))
|
|
{
|
|
if (expression is MemberAccessExpressionSyntax memberAccessExpressionSyntax)
|
|
{
|
|
ExpressionSyntax expression2 = memberAccessExpressionSyntax.Expression;
|
|
SyntaxToken operatorToken = memberAccessExpressionSyntax.OperatorToken;
|
|
if (operatorToken != null && operatorToken.Kind == SyntaxKind.DotToken)
|
|
{
|
|
SimpleNameSyntax name = memberAccessExpressionSyntax.Name;
|
|
ExpressionSyntax expression3 = expression2;
|
|
SyntaxToken dotToken = operatorToken;
|
|
SimpleNameSyntax right = name;
|
|
if (ConvertExpressionToType(expression3, out NameSyntax type2))
|
|
{
|
|
type = _syntaxFactory.QualifiedName(type2, dotToken, right);
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
else if (expression is AliasQualifiedNameSyntax aliasQualifiedNameSyntax)
|
|
{
|
|
AliasQualifiedNameSyntax aliasQualifiedNameSyntax2 = aliasQualifiedNameSyntax;
|
|
type = aliasQualifiedNameSyntax2;
|
|
return true;
|
|
}
|
|
type = null;
|
|
return false;
|
|
}
|
|
SimpleNameSyntax simpleNameSyntax2 = simpleNameSyntax;
|
|
type = simpleNameSyntax2;
|
|
return true;
|
|
}
|
|
|
|
private PatternSyntax ParsePattern(Precedence precedence, bool afterIs = false, bool whenIsKeyword = false)
|
|
{
|
|
return ParseDisjunctivePattern(precedence, afterIs, whenIsKeyword);
|
|
}
|
|
|
|
private PatternSyntax ParseDisjunctivePattern(Precedence precedence, bool afterIs, bool whenIsKeyword)
|
|
{
|
|
PatternSyntax patternSyntax = ParseConjunctivePattern(precedence, afterIs, whenIsKeyword);
|
|
while (base.CurrentToken.ContextualKind == SyntaxKind.OrKeyword)
|
|
{
|
|
patternSyntax = _syntaxFactory.BinaryPattern(SyntaxKind.OrPattern, patternSyntax, SyntaxParser.ConvertToKeyword(EatToken()), ParseConjunctivePattern(precedence, afterIs, whenIsKeyword));
|
|
}
|
|
return patternSyntax;
|
|
}
|
|
|
|
private bool LooksLikeTypeOfPattern()
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
if (SyntaxFacts.IsPredefinedType(kind))
|
|
{
|
|
return true;
|
|
}
|
|
if (kind == SyntaxKind.IdentifierToken && base.CurrentToken.ContextualKind != SyntaxKind.UnderscoreToken && (base.CurrentToken.ContextualKind != SyntaxKind.NameOfKeyword || PeekToken(1).Kind != SyntaxKind.OpenParenToken))
|
|
{
|
|
return true;
|
|
}
|
|
if (LooksLikeTupleArrayType())
|
|
{
|
|
return true;
|
|
}
|
|
if (IsFunctionPointerStart())
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private PatternSyntax ParseConjunctivePattern(Precedence precedence, bool afterIs, bool whenIsKeyword)
|
|
{
|
|
PatternSyntax patternSyntax = ParseNegatedPattern(precedence, afterIs, whenIsKeyword);
|
|
while (base.CurrentToken.ContextualKind == SyntaxKind.AndKeyword)
|
|
{
|
|
patternSyntax = _syntaxFactory.BinaryPattern(SyntaxKind.AndPattern, patternSyntax, SyntaxParser.ConvertToKeyword(EatToken()), ParseNegatedPattern(precedence, afterIs, whenIsKeyword));
|
|
}
|
|
return patternSyntax;
|
|
}
|
|
|
|
private bool ScanDesignation(bool permitTuple)
|
|
{
|
|
switch (base.CurrentToken.Kind)
|
|
{
|
|
default:
|
|
return false;
|
|
case SyntaxKind.IdentifierToken:
|
|
{
|
|
bool result2 = IsTrueIdentifier();
|
|
EatToken();
|
|
return result2;
|
|
}
|
|
case SyntaxKind.OpenParenToken:
|
|
{
|
|
if (!permitTuple)
|
|
{
|
|
return false;
|
|
}
|
|
bool result = false;
|
|
while (true)
|
|
{
|
|
EatToken();
|
|
if (!ScanDesignation(permitTuple: true))
|
|
{
|
|
break;
|
|
}
|
|
switch (base.CurrentToken.Kind)
|
|
{
|
|
case SyntaxKind.CloseParenToken:
|
|
EatToken();
|
|
return result;
|
|
case SyntaxKind.CommaToken:
|
|
break;
|
|
default:
|
|
return false;
|
|
}
|
|
result = true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
private PatternSyntax ParseNegatedPattern(Precedence precedence, bool afterIs, bool whenIsKeyword)
|
|
{
|
|
if (base.CurrentToken.ContextualKind == SyntaxKind.NotKeyword)
|
|
{
|
|
return _syntaxFactory.UnaryPattern(SyntaxParser.ConvertToKeyword(EatToken()), ParseNegatedPattern(precedence, afterIs, whenIsKeyword));
|
|
}
|
|
return ParsePrimaryPattern(precedence, afterIs, whenIsKeyword);
|
|
}
|
|
|
|
private PatternSyntax ParsePrimaryPattern(Precedence precedence, bool afterIs, bool whenIsKeyword)
|
|
{
|
|
switch (base.CurrentToken.Kind)
|
|
{
|
|
case SyntaxKind.CloseParenToken:
|
|
case SyntaxKind.CloseBraceToken:
|
|
case SyntaxKind.CloseBracketToken:
|
|
case SyntaxKind.SemicolonToken:
|
|
case SyntaxKind.CommaToken:
|
|
case SyntaxKind.EqualsGreaterThanToken:
|
|
return _syntaxFactory.ConstantPattern(ParseIdentifierName(ErrorCode.ERR_MissingPattern));
|
|
default:
|
|
if (base.CurrentToken.ContextualKind == SyntaxKind.UnderscoreToken)
|
|
{
|
|
return _syntaxFactory.DiscardPattern(EatContextualToken(SyntaxKind.UnderscoreToken));
|
|
}
|
|
switch (base.CurrentToken.Kind)
|
|
{
|
|
case SyntaxKind.OpenBracketToken:
|
|
return ParseListPattern(whenIsKeyword);
|
|
case SyntaxKind.DotDotToken:
|
|
return _syntaxFactory.SlicePattern(EatToken(), IsPossibleSubpatternElement() ? ParsePattern(precedence, afterIs: false, whenIsKeyword) : null);
|
|
case SyntaxKind.LessThanToken:
|
|
case SyntaxKind.GreaterThanToken:
|
|
case SyntaxKind.ExclamationEqualsToken:
|
|
case SyntaxKind.EqualsEqualsToken:
|
|
case SyntaxKind.LessThanEqualsToken:
|
|
case SyntaxKind.GreaterThanEqualsToken:
|
|
return _syntaxFactory.RelationalPattern(EatToken(), ParseSubExpression(Precedence.Relational));
|
|
default:
|
|
{
|
|
using DisposableResetPoint disposableResetPoint = GetDisposableResetPoint(resetOnDispose: false);
|
|
TypeSyntax typeSyntax = null;
|
|
if (LooksLikeTypeOfPattern())
|
|
{
|
|
typeSyntax = ParseType(afterIs ? ParseTypeMode.AfterIs : ParseTypeMode.DefinitePattern);
|
|
if (((GreenNode)typeSyntax).IsMissing || !CanTokenFollowTypeInPattern(precedence))
|
|
{
|
|
disposableResetPoint.Reset();
|
|
typeSyntax = null;
|
|
}
|
|
}
|
|
PatternSyntax patternSyntax = ParsePatternContinued(typeSyntax, precedence, whenIsKeyword);
|
|
if (patternSyntax != null)
|
|
{
|
|
return patternSyntax;
|
|
}
|
|
disposableResetPoint.Reset();
|
|
ExpressionSyntax expression = ParseSubExpression(precedence);
|
|
return _syntaxFactory.ConstantPattern(expression);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool CanTokenFollowTypeInPattern(Precedence precedence)
|
|
{
|
|
SyntaxKind kind = base.CurrentToken.Kind;
|
|
switch (kind)
|
|
{
|
|
case SyntaxKind.OpenParenToken:
|
|
case SyntaxKind.CloseParenToken:
|
|
case SyntaxKind.OpenBraceToken:
|
|
case SyntaxKind.CloseBraceToken:
|
|
case SyntaxKind.CloseBracketToken:
|
|
case SyntaxKind.SemicolonToken:
|
|
case SyntaxKind.CommaToken:
|
|
case SyntaxKind.IdentifierToken:
|
|
return true;
|
|
case SyntaxKind.DotToken:
|
|
return false;
|
|
case SyntaxKind.ExclamationToken:
|
|
case SyntaxKind.MinusGreaterThanToken:
|
|
return false;
|
|
default:
|
|
if (SyntaxFacts.IsBinaryExpressionOperatorToken(kind))
|
|
{
|
|
return GetPrecedence(SyntaxFacts.GetBinaryExpression(kind)) <= precedence;
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
|
|
private PatternSyntax? ParsePatternContinued(TypeSyntax? type, Precedence precedence, bool whenIsKeyword)
|
|
{
|
|
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
|
|
if (type != null && type.Kind == SyntaxKind.IdentifierName)
|
|
{
|
|
SyntaxToken identifier = ((IdentifierNameSyntax)type).Identifier;
|
|
if (identifier.ContextualKind == SyntaxKind.VarKeyword && (base.CurrentToken.Kind == SyntaxKind.OpenParenToken || IsValidPatternDesignation(whenIsKeyword)))
|
|
{
|
|
SyntaxToken varKeyword = SyntaxParser.ConvertToKeyword(identifier);
|
|
VariableDesignationSyntax designation = ParseDesignation(forPattern: true);
|
|
return _syntaxFactory.VarPattern(varKeyword, designation);
|
|
}
|
|
}
|
|
if (base.CurrentToken.Kind == SyntaxKind.OpenParenToken && (type != null || !looksLikeCast()))
|
|
{
|
|
SyntaxToken openToken = EatToken(SyntaxKind.OpenParenToken);
|
|
SeparatedSyntaxList<SubpatternSyntax> subpatterns = ParseCommaSeparatedSyntaxList(ref openToken, SyntaxKind.CloseParenToken, (LanguageParser @this) => @this.IsPossibleSubpatternElement(), (LanguageParser @this) => @this.ParseSubpatternElement(), SkipBadPatternListTokens<SubpatternSyntax>, allowTrailingSeparator: false, requireOneElement: false, allowSemicolonAsSeparator: false);
|
|
SyntaxToken closeParenToken = EatToken(SyntaxKind.CloseParenToken);
|
|
parsePropertyPatternClause(out var propertyPatternClauseResult);
|
|
VariableDesignationSyntax variableDesignationSyntax = TryParseSimpleDesignation(whenIsKeyword);
|
|
if (type == null && propertyPatternClauseResult == null && variableDesignationSyntax == null && subpatterns.Count == 1 && subpatterns.SeparatorCount == 0)
|
|
{
|
|
SubpatternSyntax subpatternSyntax = subpatterns[0];
|
|
if (subpatternSyntax.ExpressionColon == null)
|
|
{
|
|
PatternSyntax pattern = subpatternSyntax.Pattern;
|
|
if (pattern is ConstantPatternSyntax constantPatternSyntax)
|
|
{
|
|
ExpressionSyntax leftOperand = _syntaxFactory.ParenthesizedExpression(openToken, constantPatternSyntax.Expression, closeParenToken);
|
|
leftOperand = ParseExpressionContinued(leftOperand, precedence);
|
|
return _syntaxFactory.ConstantPattern(leftOperand);
|
|
}
|
|
return _syntaxFactory.ParenthesizedPattern(openToken, pattern, closeParenToken);
|
|
}
|
|
}
|
|
PositionalPatternClauseSyntax positionalPatternClause = _syntaxFactory.PositionalPatternClause(openToken, subpatterns, closeParenToken);
|
|
return _syntaxFactory.RecursivePattern(type, positionalPatternClause, propertyPatternClauseResult, variableDesignationSyntax);
|
|
}
|
|
if (parsePropertyPatternClause(out var propertyPatternClauseResult2))
|
|
{
|
|
return _syntaxFactory.RecursivePattern(type, null, propertyPatternClauseResult2, TryParseSimpleDesignation(whenIsKeyword));
|
|
}
|
|
if (type != null)
|
|
{
|
|
VariableDesignationSyntax variableDesignationSyntax2 = TryParseSimpleDesignation(whenIsKeyword);
|
|
if (variableDesignationSyntax2 != null)
|
|
{
|
|
return _syntaxFactory.DeclarationPattern(type, variableDesignationSyntax2);
|
|
}
|
|
if (!ConvertTypeToExpression(type, out ExpressionSyntax expr))
|
|
{
|
|
return _syntaxFactory.TypePattern(type);
|
|
}
|
|
return _syntaxFactory.ConstantPattern(ParseExpressionContinued(expr, precedence));
|
|
}
|
|
return null;
|
|
bool looksLikeCast()
|
|
{
|
|
using (GetDisposableResetPoint(resetOnDispose: true))
|
|
{
|
|
return ScanCast(forPattern: true);
|
|
}
|
|
}
|
|
bool parsePropertyPatternClause([NotNullWhen(true)] out PropertyPatternClauseSyntax? reference)
|
|
{
|
|
if (base.CurrentToken.Kind == SyntaxKind.OpenBraceToken)
|
|
{
|
|
reference = ParsePropertyPatternClause();
|
|
return true;
|
|
}
|
|
reference = null;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
private VariableDesignationSyntax? TryParseSimpleDesignation(bool whenIsKeyword)
|
|
{
|
|
if (!IsTrueIdentifier() || !IsValidPatternDesignation(whenIsKeyword))
|
|
{
|
|
return null;
|
|
}
|
|
return ParseSimpleDesignation();
|
|
}
|
|
|
|
private bool IsValidPatternDesignation(bool whenIsKeyword)
|
|
{
|
|
if (base.CurrentToken.Kind == SyntaxKind.IdentifierToken)
|
|
{
|
|
switch (base.CurrentToken.ContextualKind)
|
|
{
|
|
case SyntaxKind.WhenKeyword:
|
|
return !whenIsKeyword;
|
|
case SyntaxKind.OrKeyword:
|
|
case SyntaxKind.AndKeyword:
|
|
{
|
|
SyntaxKind kind = PeekToken(1).Kind;
|
|
switch (kind)
|
|
{
|
|
case SyntaxKind.CloseParenToken:
|
|
case SyntaxKind.CloseBraceToken:
|
|
case SyntaxKind.CloseBracketToken:
|
|
case SyntaxKind.ColonToken:
|
|
case SyntaxKind.SemicolonToken:
|
|
case SyntaxKind.CommaToken:
|
|
case SyntaxKind.QuestionToken:
|
|
return true;
|
|
case SyntaxKind.OpenParenToken:
|
|
case SyntaxKind.OpenBraceToken:
|
|
case SyntaxKind.OpenBracketToken:
|
|
case SyntaxKind.LessThanToken:
|
|
case SyntaxKind.GreaterThanToken:
|
|
case SyntaxKind.LessThanEqualsToken:
|
|
case SyntaxKind.GreaterThanEqualsToken:
|
|
case SyntaxKind.IdentifierToken:
|
|
return false;
|
|
default:
|
|
if (SyntaxFacts.IsBinaryExpression(kind))
|
|
{
|
|
return true;
|
|
}
|
|
using (GetDisposableResetPoint(resetOnDispose: true))
|
|
{
|
|
EatToken();
|
|
return !CanStartExpression();
|
|
}
|
|
}
|
|
}
|
|
default:
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private CSharpSyntaxNode ParseExpressionOrPatternForSwitchStatement()
|
|
{
|
|
TerminatorState termState = _termState;
|
|
_termState |= TerminatorState.IsExpressionOrPatternInCaseLabelOfSwitchStatement;
|
|
PatternSyntax pattern = ParsePattern(Precedence.Conditional, afterIs: false, whenIsKeyword: true);
|
|
_termState = termState;
|
|
return ConvertPatternToExpressionIfPossible(pattern);
|
|
}
|
|
|
|
private CSharpSyntaxNode ConvertPatternToExpressionIfPossible(PatternSyntax pattern, bool permitTypeArguments = false)
|
|
{
|
|
if (!(pattern is ConstantPatternSyntax constantPatternSyntax))
|
|
{
|
|
if (!(pattern is TypePatternSyntax typePatternSyntax))
|
|
{
|
|
if (pattern is DiscardPatternSyntax discardPatternSyntax)
|
|
{
|
|
DiscardPatternSyntax discardPatternSyntax2 = discardPatternSyntax;
|
|
return _syntaxFactory.IdentifierName(SyntaxParser.ConvertToIdentifier(discardPatternSyntax2.UnderscoreToken));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
TypePatternSyntax typePatternSyntax2 = typePatternSyntax;
|
|
if (ConvertTypeToExpression(typePatternSyntax2.Type, out ExpressionSyntax expr, permitTypeArguments))
|
|
{
|
|
return expr;
|
|
}
|
|
}
|
|
return pattern;
|
|
}
|
|
return constantPatternSyntax.Expression;
|
|
}
|
|
|
|
private bool ConvertTypeToExpression(TypeSyntax type, [NotNullWhen(true)] out ExpressionSyntax? expr, bool permitTypeArguments = false)
|
|
{
|
|
if (!(type is GenericNameSyntax genericNameSyntax))
|
|
{
|
|
if (!(type is SimpleNameSyntax simpleNameSyntax))
|
|
{
|
|
if (type is QualifiedNameSyntax qualifiedNameSyntax)
|
|
{
|
|
NameSyntax left = qualifiedNameSyntax.Left;
|
|
SyntaxToken dotToken = qualifiedNameSyntax.dotToken;
|
|
SimpleNameSyntax right = qualifiedNameSyntax.Right;
|
|
if (permitTypeArguments || !(right is GenericNameSyntax))
|
|
{
|
|
ExpressionSyntax expr2;
|
|
ExpressionSyntax expression = (ConvertTypeToExpression(left, out expr2, permitTypeArguments: true) ? expr2 : left);
|
|
expr = _syntaxFactory.MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, expression, dotToken, right);
|
|
return true;
|
|
}
|
|
}
|
|
expr = null;
|
|
return false;
|
|
}
|
|
expr = simpleNameSyntax;
|
|
return true;
|
|
}
|
|
expr = genericNameSyntax;
|
|
return permitTypeArguments;
|
|
}
|
|
|
|
private bool LooksLikeTupleArrayType()
|
|
{
|
|
if (base.CurrentToken.Kind != SyntaxKind.OpenParenToken)
|
|
{
|
|
return false;
|
|
}
|
|
using (GetDisposableResetPoint(resetOnDispose: true))
|
|
{
|
|
return ScanType(forPattern: true) != ScanTypeFlags.NotType;
|
|
}
|
|
}
|
|
|
|
private PropertyPatternClauseSyntax ParsePropertyPatternClause()
|
|
{
|
|
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxToken openToken = EatToken(SyntaxKind.OpenBraceToken);
|
|
SeparatedSyntaxList<SubpatternSyntax> subpatterns = ParseCommaSeparatedSyntaxList(ref openToken, SyntaxKind.CloseBraceToken, (LanguageParser @this) => @this.IsPossibleSubpatternElement(), (LanguageParser @this) => @this.ParseSubpatternElement(), SkipBadPatternListTokens<SubpatternSyntax>, allowTrailingSeparator: true, requireOneElement: false, allowSemicolonAsSeparator: false);
|
|
return _syntaxFactory.PropertyPatternClause(openToken, subpatterns, EatToken(SyntaxKind.CloseBraceToken));
|
|
}
|
|
|
|
private SubpatternSyntax ParseSubpatternElement()
|
|
{
|
|
BaseExpressionColonSyntax expressionColon = null;
|
|
PatternSyntax pattern = ParsePattern(Precedence.Conditional);
|
|
if (base.CurrentToken.Kind == SyntaxKind.ColonToken && ConvertPatternToExpressionIfPossible(pattern, permitTypeArguments: true) is ExpressionSyntax expressionSyntax)
|
|
{
|
|
SyntaxToken colonToken = EatToken();
|
|
expressionColon = ((expressionSyntax is IdentifierNameSyntax name) ? ((BaseExpressionColonSyntax)_syntaxFactory.NameColon(name, colonToken)) : ((BaseExpressionColonSyntax)_syntaxFactory.ExpressionColon(expressionSyntax, colonToken)));
|
|
pattern = ParsePattern(Precedence.Conditional);
|
|
}
|
|
return _syntaxFactory.Subpattern(expressionColon, pattern);
|
|
}
|
|
|
|
private bool IsPossibleSubpatternElement()
|
|
{
|
|
bool flag = CanStartExpression();
|
|
if (!flag)
|
|
{
|
|
bool flag2;
|
|
switch (base.CurrentToken.Kind)
|
|
{
|
|
case SyntaxKind.OpenBraceToken:
|
|
case SyntaxKind.OpenBracketToken:
|
|
case SyntaxKind.LessThanToken:
|
|
case SyntaxKind.GreaterThanToken:
|
|
case SyntaxKind.LessThanEqualsToken:
|
|
case SyntaxKind.GreaterThanEqualsToken:
|
|
flag2 = true;
|
|
break;
|
|
default:
|
|
flag2 = false;
|
|
break;
|
|
}
|
|
flag = flag2;
|
|
}
|
|
return flag;
|
|
}
|
|
|
|
private static PostSkipAction SkipBadPatternListTokens<T>(LanguageParser @this, ref SyntaxToken open, SeparatedSyntaxListBuilder<T> list, SyntaxKind expectedKind, SyntaxKind closeKind) where T : CSharpSyntaxNode
|
|
{
|
|
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
|
|
bool flag;
|
|
switch (@this.CurrentToken.Kind)
|
|
{
|
|
case SyntaxKind.CloseParenToken:
|
|
case SyntaxKind.CloseBraceToken:
|
|
case SyntaxKind.CloseBracketToken:
|
|
case SyntaxKind.SemicolonToken:
|
|
flag = true;
|
|
break;
|
|
default:
|
|
flag = false;
|
|
break;
|
|
}
|
|
if (flag)
|
|
{
|
|
return PostSkipAction.Abort;
|
|
}
|
|
if (@this._termState.HasFlag(TerminatorState.IsExpressionOrPatternInCaseLabelOfSwitchStatement) && @this.CurrentToken.Kind == SyntaxKind.ColonToken)
|
|
{
|
|
return PostSkipAction.Abort;
|
|
}
|
|
flag = @this._termState.HasFlag(TerminatorState.IsPatternInSwitchExpressionArm);
|
|
if (flag)
|
|
{
|
|
SyntaxKind kind = @this.CurrentToken.Kind;
|
|
bool flag2 = ((kind == SyntaxKind.ColonToken || kind == SyntaxKind.EqualsGreaterThanToken) ? true : false);
|
|
flag = flag2;
|
|
}
|
|
if (flag)
|
|
{
|
|
return PostSkipAction.Abort;
|
|
}
|
|
return @this.SkipBadSeparatedListTokensWithExpectedKind<SyntaxToken, T>(ref open, list, (LanguageParser p) => p.CurrentToken.Kind != SyntaxKind.CommaToken && !p.IsPossibleSubpatternElement(), (LanguageParser p, SyntaxKind syntaxKind) => p.CurrentToken.Kind == syntaxKind || p.CurrentToken.Kind == SyntaxKind.SemicolonToken, expectedKind, closeKind);
|
|
}
|
|
|
|
private SwitchExpressionSyntax ParseSwitchExpression(ExpressionSyntax governingExpression, SyntaxToken switchKeyword)
|
|
{
|
|
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
|
|
return _syntaxFactory.SwitchExpression(governingExpression, switchKeyword, EatToken(SyntaxKind.OpenBraceToken), ParseSwitchExpressionArms(), EatToken(SyntaxKind.CloseBraceToken));
|
|
}
|
|
|
|
private SeparatedSyntaxList<SwitchExpressionArmSyntax> ParseSwitchExpressionArms()
|
|
{
|
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
|
|
SeparatedSyntaxListBuilder<SwitchExpressionArmSyntax> val = _pool.AllocateSeparated<SwitchExpressionArmSyntax>();
|
|
while (base.CurrentToken.Kind != SyntaxKind.CloseBraceToken)
|
|
{
|
|
SyntaxToken syntaxToken = ((base.CurrentToken.Kind == SyntaxKind.CaseKeyword) ? AddError(EatToken(), ErrorCode.ERR_BadCaseInSwitchArm) : null);
|
|
TerminatorState termState = _termState;
|
|
_termState |= TerminatorState.IsPatternInSwitchExpressionArm;
|
|
PatternSyntax patternSyntax = ParsePattern(Precedence.Coalescing, afterIs: false, whenIsKeyword: true);
|
|
_termState = termState;
|
|
if (syntaxToken != null)
|
|
{
|
|
patternSyntax = AddLeadingSkippedSyntax(patternSyntax, (GreenNode)(object)syntaxToken);
|
|
}
|
|
SwitchExpressionArmSyntax switchExpressionArmSyntax = _syntaxFactory.SwitchExpressionArm(patternSyntax, ParseWhenClause(Precedence.Coalescing), (base.CurrentToken.Kind == SyntaxKind.ColonToken) ? EatTokenAsKind(SyntaxKind.EqualsGreaterThanToken) : EatToken(SyntaxKind.EqualsGreaterThanToken), ParseExpressionCore());
|
|
if (((GreenNode)switchExpressionArmSyntax).Width == 0 && base.CurrentToken.Kind != SyntaxKind.CommaToken)
|
|
{
|
|
break;
|
|
}
|
|
val.Add(switchExpressionArmSyntax);
|
|
if (base.CurrentToken.Kind != SyntaxKind.CloseBraceToken)
|
|
{
|
|
SyntaxToken syntaxToken2 = ((base.CurrentToken.Kind == SyntaxKind.SemicolonToken) ? EatTokenAsKind(SyntaxKind.CommaToken) : EatToken(SyntaxKind.CommaToken));
|
|
val.AddSeparator((GreenNode)(object)syntaxToken2);
|
|
}
|
|
}
|
|
return _pool.ToListAndFree<SwitchExpressionArmSyntax>(ref val);
|
|
}
|
|
|
|
private ListPatternSyntax ParseListPattern(bool whenIsKeyword)
|
|
{
|
|
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
|
|
SyntaxToken openToken = EatToken(SyntaxKind.OpenBracketToken);
|
|
SeparatedSyntaxList<PatternSyntax> patterns = ParseCommaSeparatedSyntaxList(ref openToken, SyntaxKind.CloseBracketToken, (LanguageParser @this) => @this.IsPossibleSubpatternElement(), (LanguageParser @this) => @this.ParsePattern(Precedence.Conditional), SkipBadPatternListTokens<PatternSyntax>, allowTrailingSeparator: true, requireOneElement: false, allowSemicolonAsSeparator: false);
|
|
return _syntaxFactory.ListPattern(openToken, patterns, EatToken(SyntaxKind.CloseBracketToken), TryParseSimpleDesignation(whenIsKeyword));
|
|
}
|
|
}
|