コード例 #1
0
        private DirectiveTriviaSyntax ParseReferenceDirective(
            SyntaxToken hash,
            SyntaxToken keyword,
            bool isActive,
            bool isFollowingToken
            )
        {
            if (isActive)
            {
                if (Options.Kind == SourceCodeKind.Regular)
                {
                    keyword = this.AddError(
                        keyword,
                        ErrorCode.ERR_ReferenceDirectiveOnlyAllowedInScripts
                        );
                }
                else if (isFollowingToken)
                {
                    keyword = this.AddError(keyword, ErrorCode.ERR_PPReferenceFollowsToken);
                }
            }

            SyntaxToken file = this.EatToken(
                SyntaxKind.StringLiteralToken,
                ErrorCode.ERR_ExpectedPPFile,
                reportError: isActive
                );

            var end = this.ParseEndOfDirective(ignoreErrors: file.IsMissing || !isActive);

            return(SyntaxFactory.ReferenceDirectiveTrivia(hash, keyword, file, end, isActive));
        }
コード例 #2
0
ファイル: DirectiveParser.cs プロジェクト: peg4d/bench
        private DirectiveTriviaSyntax ParseReferenceDirective(SyntaxToken hash, SyntaxToken keyword, bool isActive, bool isFollowingToken)
        {
            if (isActive && isFollowingToken)
            {
                keyword = this.AddError(keyword, ErrorCode.ERR_PPReferenceFollowsToken);
            }

            SyntaxToken file = this.EatToken(SyntaxKind.StringLiteralToken, ErrorCode.ERR_ExpectedPPFile, reportError: isActive);

            var end = this.ParseEndOfDirective(ignoreErrors: file.IsMissing || !isActive, afterPragma: false, afterLineNumber: false, afterReference: true);

            return(SyntaxFactory.ReferenceDirectiveTrivia(hash, keyword, file, end, isActive));
        }