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

IsPossibleDeclarationStatement() private method

private IsPossibleDeclarationStatement ( ) : bool
return bool
        private bool IsPossibleDeclarationStatement()
        {
            var tk = Current.Kind;

            // Although "<identifier> <literal>" is invalid, it's common enough that we try to parse it anyway, and report on the error.
            if (tk == SyntaxKind.IdentifierToken && (Lookahead.Kind == SyntaxKind.IdentifierToken || Lookahead.Kind.IsLiteral()))
                return true;

            switch (Current.Kind)
            {
                case SyntaxKind.ClassKeyword:
                case SyntaxKind.StructKeyword:
                case SyntaxKind.InterfaceKeyword:
                case SyntaxKind.TypedefKeyword:
                    return true;
            }

            var resetPoint = GetResetPoint();
            try
            {
                var modifiers = new List<SyntaxToken>();
                ParseDeclarationModifiers(modifiers);

                var st = ScanType();

                if (st == ScanTypeFlags.NotType)
                    return false;

                // Although "<type> <literal>" is invalid, it's common enough that we try to parse it anyway, and report on the error.
                if (Current.Kind != SyntaxKind.IdentifierToken && Current.Kind != SyntaxKind.SemiToken && !Current.Kind.IsLiteral())
                    return false;

                if (Lookahead.Kind == SyntaxKind.OpenParenToken)
                    return false;

                return true;
            }
            finally
            {
                Reset(ref resetPoint);
            }
        }
HlslParser