ShaderTools.Hlsl.Parser.HlslParser.ParseSwitchSection C# (CSharp) Method

ParseSwitchSection() private method

private ParseSwitchSection ( ) : SwitchSectionSyntax
return SwitchSectionSyntax
        private SwitchSectionSyntax ParseSwitchSection()
        {
            // First, parse case label(s)
            var labels = new List<SwitchLabelSyntax>();
            var statements = new List<StatementSyntax>();
            do
            {
                SyntaxToken specifier;
                SwitchLabelSyntax label;
                SyntaxToken colon;
                if (Current.Kind == SyntaxKind.CaseKeyword)
                {
                    ExpressionSyntax expression;
                    specifier = NextToken();
                    if (Current.Kind == SyntaxKind.ColonToken)
                    {
                        expression = CreateMissingIdentifierName();
                        expression = WithDiagnostic(expression, DiagnosticId.ConstantExpected);
                    }
                    else
                    {
                        expression = ParseExpression();
                    }
                    colon = Match(SyntaxKind.ColonToken);
                    label = new CaseSwitchLabelSyntax(specifier, expression, colon);
                }
                else
                {
                    Debug.Assert(Current.Kind == SyntaxKind.DefaultKeyword);
                    specifier = Match(SyntaxKind.DefaultKeyword);
                    colon = Match(SyntaxKind.ColonToken);
                    label = new DefaultSwitchLabelSyntax(specifier, colon);
                }

                labels.Add(label);
            }
            while (IsPossibleSwitchSection());

            // Next, parse statement list stopping for new sections
            ParseStatements(statements, true);

            return new SwitchSectionSyntax(labels, statements);
        }
HlslParser