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


C# SourceUnit类代码示例

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


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

示例1: GeneratorTest

        public void GeneratorTest(SourceUnit sourceUnit, bool useLua52)
        {
            var options = new LuaCompilerOptions()
            {
                SkipFirstLine = true,
                UseLua52Features = useLua52,
            };

            var reader = TestUtils.OpenReaderOrIgnoreTest(sourceUnit.GetReader);

            TestUtils.AssertSyntaxError(() =>
            {
                var tokenizer = new Tokenizer(ErrorSink.Default, options);
                tokenizer.Initialize(null, reader, sourceUnit, SourceLocation.MinValue);
                var parser = new Parser(tokenizer, tokenizer.ErrorSink, options);
                var ast = parser.Parse();
                Assert.That(ast, Is.Not.Null);

                var codeContext = new CodeContext((LuaContext)sourceUnit.LanguageContext);

                var gen = new Generator(codeContext);
                var expr = gen.Compile(ast, sourceUnit);
                Assert.That(expr, Is.Not.Null);
            });
        }
开发者ID:SPARTAN563,项目名称:IronLua,代码行数:25,代码来源:GeneratorTests.cs

示例2: OptimizedScriptCode

        public OptimizedScriptCode(Scope optimizedScope, DlrMainCallTarget optimizedTarget, SourceUnit sourceUnit)
            : base(sourceUnit) {
            ContractUtils.RequiresNotNull(optimizedScope, "optimizedScope");

            _optimizedScope = optimizedScope;
            _optimizedTarget = optimizedTarget;
        }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:7,代码来源:OptimizedScriptCode.cs

示例3: SourceUnitReader

        internal SourceUnitReader(SourceUnit sourceUnit, TextReader textReader)
        {
            Assert.NotNull(sourceUnit, textReader);

            _textReader = textReader;
            _sourceUnit = sourceUnit;
        }
开发者ID:robertlj,项目名称:IronScheme,代码行数:7,代码来源:SourceUnitReader.cs

示例4: Lexer

        internal Lexer(SourceUnit unit, HappyLanguageContext languageContext)
        {
            _reader = new InputReader(unit);
            _errorCollector = new ErrorCollector(languageContext.ErrorSink);
            PushState(LexerMode.LexingStatement);

            _keywords["if"] = HappyTokenKind.KeywordIf;
            _keywords["else"] = HappyTokenKind.KeywordElse;
            _keywords["while"] = HappyTokenKind.KeywordWhile;
            _keywords["for"] = HappyTokenKind.KeywordFor;
            _keywords["in"] = HappyTokenKind.KeywordIn;
            _keywords["between"] = HappyTokenKind.KeywordBetween;
            _keywords["where"] = HappyTokenKind.KeywordWhere;
            _keywords["lookup"] = HappyTokenKind.KeywordLookup;
            _keywords["default"] = HappyTokenKind.KeywordDefault;
            _keywords["true"] = HappyTokenKind.LiteralBool;
            _keywords["false"] = HappyTokenKind.LiteralBool;
            _keywords["return"] = HappyTokenKind.KeywordReturn;
            _keywords["def"] = HappyTokenKind.KeywordDef;
            _keywords["null"] = HappyTokenKind.LiteralNull;
            _keywords["load"] = HappyTokenKind.KeywordLoad;
            _keywords["use"] = HappyTokenKind.KeywordUse;
            _keywords["new"] = HappyTokenKind.KeywordNew;
            _keywords["function"] = HappyTokenKind.KeywordFunction;
            _keywords["break"] = HappyTokenKind.KeywordBreak;
            _keywords["continue"] = HappyTokenKind.KeywordContinue;
            _keywords["switch"] = HappyTokenKind.KeywordSwitch;
            _keywords["case"] = HappyTokenKind.KeywordCase;
        }
开发者ID:dlurton,项目名称:Happy,代码行数:29,代码来源:Lexer.cs

示例5: HappySourceLocation

 HappySourceLocation(SourceUnit unit, SourceSpan span)
 {
     //ContractUtils.RequiresNotNull(unit, "unit");
     ContractUtils.RequiresNotNull(span, "span");
     this.Unit = unit;
     this.Span = span;
 }
开发者ID:dlurton,项目名称:Happy,代码行数:7,代码来源:HappySourceLocation.cs

示例6: Initialize

		public override void Initialize(object state, TextReader textreader, SourceUnit sourceUnit, SS.SourceLocation initialLocation)
		{
			tokenizer = new Tokenizer (textreader.ReadToEnd ().ToCharArray (), new IdentifierTable ());
			tokenizer.Position = ConvertToMJCSrcLocation(initialLocation);
			this.sourceUnit = sourceUnit;
			this.state = state;
		}
开发者ID:alesliehughes,项目名称:olive,代码行数:7,代码来源:JSTokenizerService.cs

示例7: LambdaFunctionExpr

        public LambdaFunctionExpr(SourceUnit/*!*/ sourceUnit,
            Position position, Position entireDeclarationPosition, ShortPosition headingEndPosition, ShortPosition declarationBodyPosition,
            Scope scope, NamespaceDecl ns,
            bool aliasReturn, List<FormalParam>/*!*/ formalParams, List<FormalParam> useParams,
            List<Statement>/*!*/ body)
            : base(position)
        {
            Debug.Assert(formalParams != null && body != null);

            // inject use parameters at the begining of formal parameters
            if (useParams != null && useParams.Count > 0)
            {
                if (formalParams.Count == 0)
                    formalParams = useParams;   // also we don't want to modify Parser.emptyFormalParamListIndex singleton.
                else
                    formalParams.InsertRange(0, useParams);
            }
            
            //this.ns = ns;
            this.signature = new Signature(aliasReturn, formalParams);
            this.useParams = useParams;
            //this.typeSignature = new TypeSignature(genericParams);
            //this.attributes = new CustomAttributes(attributes);
            this.body = body;
            this.entireDeclarationPosition = entireDeclarationPosition;
            this.headingEndPosition = headingEndPosition;
            this.declarationBodyPosition = declarationBodyPosition;

            //QualifiedName qn = (ns != null) ? new QualifiedName(this.name, ns.QualifiedName) : new QualifiedName(this.name);
            //function = new PhpFunction(qn, memberAttributes, signature, typeSignature, isConditional, scope, sourceUnit, position);
            function = new PhpLambdaFunction(this.signature, sourceUnit, position);
            function.WriteUp(new TypeSignature(FormalTypeParam.EmptyList).ToPhpRoutineSignature(function));
        }
开发者ID:Ashod,项目名称:Phalanger,代码行数:33,代码来源:LambdaFunctionExpr.cs

示例8: Add

            public override void Add(SourceUnit sourceUnit, string message, SourceSpan span, int errorCode, Severity severity)
            {
                base.Add(sourceUnit, message, span, errorCode, severity);

                Console.Error.WriteLine("{0}({1}:{2}): {3}: RB{4}: {5}", sourceUnit.Name, span.Start.Line, span.Start.Column,
                    severity, errorCode, message);
            }
开发者ID:TerabyteX,项目名称:main,代码行数:7,代码来源:Program.cs

示例9: Add

 public override void Add(SourceUnit sourceUnit, string message, SourceSpan span, int errorCode, Severity severity) {
     if (severity == Severity.Warning) {
         PythonOps.SyntaxWarning(message, sourceUnit, span, errorCode);
     } else {
         throw PythonOps.SyntaxError(message, sourceUnit, span, errorCode);
     }
 }
开发者ID:rchandrashekara,项目名称:main,代码行数:7,代码来源:_ast.cs

示例10: EvaluatePriorAnalysis

		internal override Evaluation EvaluatePriorAnalysis(SourceUnit/*!*/ sourceUnit)
		{
			Evaluation left_eval = leftExpr.EvaluatePriorAnalysis(sourceUnit);
			Evaluation right_eval = leftExpr.EvaluatePriorAnalysis(sourceUnit);

			return Evaluation.ReadOnlyEvaluate(this, left_eval, right_eval);
		}
开发者ID:Ashod,项目名称:Phalanger,代码行数:7,代码来源:BinaryEx.cs

示例11: LuaScriptCode

 public LuaScriptCode(CodeContext context, SourceUnit sourceUnit, Expression<Func<IDynamicMetaObjectProvider, dynamic>> chunk)
     : base(sourceUnit)
 {
     Contract.Requires(chunk != null);
     Context = context;
     _exprLambda = chunk;
 }
开发者ID:SPARTAN563,项目名称:IronLua,代码行数:7,代码来源:LuaScriptCode.cs

示例12: CompileSourceCode

        public override ScriptCode CompileSourceCode(SourceUnit sourceUnit, CompilerOptions options, ErrorSink errorSink)
        {
            try
            {
                switch (sourceUnit.Kind)
                {
                    case SourceCodeKind.SingleStatement:
                    case SourceCodeKind.Expression:
                    case SourceCodeKind.AutoDetect:
                    case SourceCodeKind.InteractiveCode:
                        return new TotemScriptCode(
                            engine, engine.ParseExprToLambda(sourceUnit),
                            sourceUnit);

                    //case SourceCodeKind.Statements:
                    //case SourceCodeKind.File:
                    //    return new TotemScriptCode(
                    //        engine, engine.ParseFileToLambda(sourceUnit.Path, sourceUnit.GetCode()),
                    //        sourceUnit);

                    default:
                        throw Assert.Unreachable;
                }
            }
            catch (Exception e)
            {
                // Real language implementation would have a specific type
                // of exception.  Also, they would pass errorSink down into
                // the parser and add messages while doing tighter error
                // recovery and continuing to parse.
                errorSink.Add(sourceUnit, e.Message, SourceSpan.None, 0,
                              Severity.FatalError);
                return null;
            }
        }
开发者ID:Alxandr,项目名称:Totem-2.0,代码行数:35,代码来源:TotemContext.cs

示例13: Add

        public override void Add(SourceUnit sourceUnit, string message, SourceSpan span, int errorCode, Severity severity) {
            if (severity == Severity.Warning && !ReportWarning(_context.Verbose, errorCode)) {
                return;
            }

            CountError(severity);

            string path;
            string codeLine;
            int line = span.Start.Line;
            if (sourceUnit != null) {
                path = sourceUnit.Path;
                codeLine = (line > 0) ? sourceUnit.GetCodeLine(line) : null;
            } else {
                path = null;
                codeLine = null;
            }

            if (severity == Severity.Error || severity == Severity.FatalError) {
                throw new SyntaxError(message, path, line, span.Start.Column, codeLine);
            } else {

                if (_WriteSite == null) {
                    Interlocked.CompareExchange(
                        ref _WriteSite,
                        CallSite<Func<CallSite, object, object, object>>.Create(RubyCallAction.Make(_context, "write", 1)),
                        null
                    );
                }

                message = RubyContext.FormatErrorMessage(message, "warning", path, line, span.Start.Column, null);

                _WriteSite.Target(_WriteSite, _context.StandardErrorOutput, MutableString.CreateMutable(message));
            }
        }
开发者ID:jcteague,项目名称:ironruby,代码行数:35,代码来源:RuntimeErrorSink.cs

示例14: ExecutionContextExpression

 /// <summary>
 /// Creates a wrapper around a function which represents entry into a chunk of code
 /// </summary>
 public ExecutionContextExpression(CodeContext context, Expression scopeVariable, SourceUnit source, Expression body)
 {
     _context = context;
     _body = body;
     _scope = scopeVariable;
     _source = source;
 }
开发者ID:SPARTAN563,项目名称:IronLua,代码行数:10,代码来源:ExecutionContextExpression.cs

示例15: 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


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