当前位置: 首页>>代码示例>>C#>>正文


C# SourceUnit.GetCode方法代码示例

本文整理汇总了C#中SourceUnit.GetCode方法的典型用法代码示例。如果您正苦于以下问题:C# SourceUnit.GetCode方法的具体用法?C# SourceUnit.GetCode怎么用?C# SourceUnit.GetCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SourceUnit的用法示例。


在下文中一共展示了SourceUnit.GetCode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Parse

        private SourceUnitTree Parse(SourceUnit sourceUnit, bool allowSingle, out bool isExpression)
        {
            isExpression = false;
            IronyParser parser = new IronyParser(allowSingle ? singleStatement : fullGrammar);
            parser.Context.Mode = ParseMode.CommandLine;

            scopes = new Stack<LexicalScopeBuilder>();
            EnterTopLevelScope();
            try
            {
                var parsedScript = parser.Parse(sourceUnit.GetCode());
                if (parsedScript.HasErrors())
                {
                    sourceUnit.CodeProperties = ScriptCodeParseResult.Invalid;
                    return null;
                }

                if (sourceUnit.Kind == SourceCodeKind.InteractiveCode && parser.Context.Status == ParserStatus.AcceptedPartial)
                {
                    sourceUnit.CodeProperties = ScriptCodeParseResult.IncompleteStatement;
                    return null;
                }

                sourceUnit.CodeProperties = ScriptCodeParseResult.Complete;
                return BuildSourceTree(parsedScript.Root, sourceUnit, allowSingle, out isExpression);
            }
            catch (Exception e)
            {
                throw;
            }
            finally
            {
                LeaveScope();
            }
        }
开发者ID:Alxandr,项目名称:Totem-2.0,代码行数:35,代码来源:Parser.cs

示例2: SyntaxErrorException

        public SyntaxErrorException(string message, SourceUnit sourceUnit, SourceSpan span, int errorCode, Severity severity)
            : base(message) {
            ContractUtils.RequiresNotNull(message, "message");

            _span = span;
            _severity = severity;
            _errorCode = errorCode;
            if (sourceUnit != null) {
                _sourcePath = sourceUnit.Path;
                try {
                    _sourceCode = sourceUnit.GetCode();
                    _sourceLine = sourceUnit.GetCodeLine(Line);
                } catch (System.IO.IOException) {
                    // could not get source code.
                }
            }
        }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:17,代码来源:SyntaxErrorException.cs

示例3: CompileSourceCode

        public override ScriptCode CompileSourceCode(SourceUnit sourceUnit, CompilerOptions options, ErrorSink errorSink)
        {
            SilverLexer lexer = new SilverLexer("source", sourceUnit.GetCode());
            CommonTokenStream stream = new CommonTokenStream(lexer.Queue);
            SilverParser parser = new SilverParser(stream);
            lexer.SetLines (parser);
            parser.SourceUnit = sourceUnit;

            var res = parser.program();

            if (res != null) {
                Expression mainBlock = AstExpression.Block (res);
                return new SilverScriptCode(mainBlock, sourceUnit);
            } else {
                throw new SyntaxErrorException("Syntax error", sourceUnit, SourceSpan.None, 0, Severity.Error);
            }
        }
开发者ID:shadowphoenix,项目名称:IronSilver,代码行数:17,代码来源:SilverContext.cs

示例4: ClojureParser

 public ClojureParser(SourceUnit src)
 {
     _source = src;
     _text = src.GetCode();
 }
开发者ID:kmartin,项目名称:clojure-contrib,代码行数:5,代码来源:ClojureParser.cs

示例5: CompileSourceCode

        public ScriptCode CompileSourceCode(SourceUnit sourceUnit, CompilerOptions options, ErrorSink errorSink)
        {
            Contract.RequiresNotNull(sourceUnit, "sourceUnit");

            if (options == null) options = GetCompilerOptions();
            if (errorSink == null) errorSink = Engine.GetCompilerErrorSink();

            CompilerContext context = new CompilerContext(sourceUnit, options, errorSink);

            CodeBlock block = ParseSourceCode(context);

            if (block == null) {
                throw new SyntaxErrorException("invalid syntax|" + sourceUnit.GetCode().Trim());
            }

            //DumpBlock(block, sourceUnit.Id);

            AnalyzeBlock(block);

            DumpBlock(block, sourceUnit.Id);

            // TODO: ParseSourceCode can update CompilerContext.Options
            return new ScriptCode(block, Engine.GetLanguageContext(context.Options), context);
        }
开发者ID:robertlj,项目名称:IronScheme,代码行数:24,代码来源:LanguageContext.cs


注:本文中的SourceUnit.GetCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。