• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Ast.Expression类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: AndExpression

 public AndExpression(Expression left, Expression right)
 {
     this.left = left;
     this.right = right;
     this.Start = left.Start;
     this.End = right.End;
 }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:7,代码来源:Expressions.cs


示例2: GetTypeName

		/// <summary>
		/// Gets the fully qualified name of the type from the expression.
		/// </summary>
		/// <remarks>
		/// The expression is the first target of a call expression.
		/// 
		/// A call expression is a method or constructor call (right hand side of expression below):
		/// 
		/// a = Root.Test.Class1()
		/// 
		/// So the expression passed to this method will be a field expression in the
		/// above example which refers to Class1. The next target will be a field
		/// expression referring to Test. The The last target will be a name expression
		/// referring to Root.
		/// 
		/// If we have 
		/// 
		/// a = Class1()
		/// 
		/// then the expression will be a name expression referring to Class1.
		/// </remarks>
		string GetTypeName(Expression expression)
		{
			NameExpression nameExpression = expression as NameExpression;
			if (nameExpression != null) {
				return nameExpression.Name;
			}
			return PythonControlFieldExpression.GetMemberName(expression as MemberExpression);
		}
开发者ID:hpsa,项目名称:SharpDevelop,代码行数:29,代码来源:PythonLocalVariableAssignment.cs


示例3: AddBaseType

		void AddBaseType(Expression baseTypeExpression)
		{
			NameExpression nameExpression = baseTypeExpression as NameExpression;
			MemberExpression memberExpression = baseTypeExpression as MemberExpression;
			if (nameExpression != null) {
				AddBaseType(nameExpression.Name);
			} else if (memberExpression != null) {
				AddBaseType(memberExpression);
			}
		}
开发者ID:Rpinski,项目名称:SharpDevelop,代码行数:10,代码来源:PythonClass.cs


示例4: FinishCallExpr

        private CallExpression FinishCallExpr(Expression target, params Arg[] args) {
            bool hasArgsTuple = false;
            bool hasKeywordDict = false;
            int keywordCount = 0;
            int extraArgs = 0;

            foreach (Arg arg in args) {
                if (arg.Name == null) {
                    if (hasArgsTuple || hasKeywordDict || keywordCount > 0) {
                        ReportSyntaxError(IronPython.Resources.NonKeywordAfterKeywordArg);
                    }
                } else if (arg.Name == "*") {
                    if (hasArgsTuple || hasKeywordDict) {
                        ReportSyntaxError(IronPython.Resources.OneListArgOnly);
                    }
                    hasArgsTuple = true; extraArgs++;
                } else if (arg.Name == "**") {
                    if (hasKeywordDict) {
                        ReportSyntaxError(IronPython.Resources.OneKeywordArgOnly);
                    }
                    hasKeywordDict = true; extraArgs++;
                } else {
                    if (hasKeywordDict) {
                        ReportSyntaxError(IronPython.Resources.KeywordOutOfSequence);
                    }
                    keywordCount++;
                }
            }

            return new CallExpression(target, args);
        }
开发者ID:bdoot,项目名称:IronLanguages,代码行数:31,代码来源:Parser.cs


示例5: FinishDictComp

        // comp_iter '}'
        private DictionaryComprehension FinishDictComp(Expression key, Expression value, int oStart, int oEnd) {
            ComprehensionIterator[] iters = ParseCompIter();
            Eat(TokenKind.RightBrace);

            var cStart = GetStart();
            var cEnd = GetEnd();
            
            if (_sink != null) {
                _sink.MatchPair(
                    new SourceSpan(_tokenizer.IndexToLocation(oStart), _tokenizer.IndexToLocation(oEnd)),
                    new SourceSpan(_tokenizer.IndexToLocation(cStart), _tokenizer.IndexToLocation(cEnd)),
                    1
                );
            }
            var ret = new DictionaryComprehension(key, value, iters);
            ret.SetLoc(_globalParent, oStart, cEnd);
            return ret;
        }
开发者ID:bdoot,项目名称:IronLanguages,代码行数:19,代码来源:Parser.cs


示例6: FinishExpressionListAsExpr

        private Expression FinishExpressionListAsExpr(Expression expr) {
            var start = GetStart();
            bool trailingComma = true;
            List<Expression> l = new List<Expression>();
            l.Add(expr);

            while (true) {
                if (NeverTestToken(PeekToken())) break;
                expr = ParseExpression();
                l.Add(expr);
                if (!MaybeEat(TokenKind.Comma)) {
                    trailingComma = false;
                    break;
                }
                trailingComma = true;
            }

            Expression ret = MakeTupleOrExpr(l, trailingComma);
            ret.SetLoc(_globalParent, start, GetEnd());
            return ret;
        }
开发者ID:bdoot,项目名称:IronLanguages,代码行数:21,代码来源:Parser.cs


示例7: FinishKeywordArgument

 private Arg FinishKeywordArgument(Expression t) {
     NameExpression n = t as NameExpression;
     if (n == null) {
         ReportSyntaxError(IronPython.Resources.ExpectedName);
         Arg arg = new Arg(null, t);
         arg.SetLoc(_globalParent, t.StartIndex, t.EndIndex);
         return arg;
     } else {
         Expression val = ParseExpression();
         Arg arg = new Arg(n.Name, val);
         arg.SetLoc(_globalParent, n.StartIndex, val.EndIndex);
         return arg;
     }
 }
开发者ID:bdoot,项目名称:IronLanguages,代码行数:14,代码来源:Parser.cs


示例8: AddTrailers

        // trailer: '(' [ arglist_genexpr ] ')' | '[' subscriptlist ']' | '.' NAME
        private Expression AddTrailers(Expression ret, bool allowGeneratorExpression) {
            bool prevAllow = _allowIncomplete;
            try {
                _allowIncomplete = true;
                while (true) {
                    switch (PeekToken().Kind) {
                        case TokenKind.LeftParenthesis:
                            if (!allowGeneratorExpression) return ret;

                            NextToken();
                            Arg[] args = FinishArgListOrGenExpr();
                            CallExpression call;
                            if (args != null) {
                                call = FinishCallExpr(ret, args);
                            } else {
                                call = new CallExpression(ret, new Arg[0]);
                            }

                            call.SetLoc(_globalParent, ret.StartIndex, GetEnd());
                            ret = call;
                            break;
                        case TokenKind.LeftBracket:
                            NextToken();
                            Expression index = ParseSubscriptList();
                            IndexExpression ie = new IndexExpression(ret, index);
                            ie.SetLoc(_globalParent, ret.StartIndex, GetEnd());
                            ret = ie;
                            break;
                        case TokenKind.Dot:
                            NextToken();
                            string name = ReadNameMaybeNone();
                            MemberExpression fe = new MemberExpression(ret, name);
                            fe.SetLoc(_globalParent, ret.StartIndex, GetEnd());
                            ret = fe;
                            break;
                        case TokenKind.Constant:
                            // abc.1, abc"", abc 1L, abc 0j
                            ReportSyntaxError("invalid syntax");
                            return Error();
                        default:
                            return ret;
                    }
                }
            } finally {
                _allowIncomplete = prevAllow;
            }
        }
开发者ID:bdoot,项目名称:IronLanguages,代码行数:48,代码来源:Parser.cs


示例9: ParseConditionalTest

 private Expression ParseConditionalTest(Expression trueExpr) {
     Expression expr = ParseOrTest();
     Eat(TokenKind.KeywordElse);
     Expression falseExpr = ParseExpression();
     return new ConditionalExpression(expr, trueExpr, falseExpr);
 }
开发者ID:bdoot,项目名称:IronLanguages,代码行数:6,代码来源:Parser.cs


示例10: ExecStatement

 public ExecStatement(Expression code, Expression locals, Expression globals)
 {
     this.code = code;
     this.locals = locals;
     this.globals = globals;
 }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:6,代码来源:Statements.cs


示例11: DelStatement

 public DelStatement(Expression[] expressions)
 {
     this.exprs = expressions;
 }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:4,代码来源:Statements.cs


示例12: YieldStatement

 public YieldStatement(Expression expression, int index)
 {
     this.expr = expression;
     this.index = index;
 }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:5,代码来源:Statements.cs


示例13: WithStatement

        private List<YieldTarget> yieldTargets; // = new List<YieldTarget>();

        #endregion Fields

        #region Constructors

        public WithStatement(Expression contextManager, Expression var, Statement body)
        {
            this.contextManager = contextManager;
            this.var = var;
            this.body = body;
        }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:12,代码来源:Statements.cs


示例14: WhileStatement

 public WhileStatement(Expression test, Statement body, Statement else_)
 {
     this.test = test; this.body = body; this.elseStmt = else_;
 }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:4,代码来源:Statements.cs


示例15: TryStatementHandler

 public TryStatementHandler(Expression test, Expression target, Statement body)
 {
     this.test = test; this.target = target; this.body = body;
 }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:4,代码来源:Statements.cs


示例16: ParseLambdaHelperEnd

        private Expression ParseLambdaHelperEnd(FunctionDefinition func, Expression expr) {
            // Pep 342 in Python 2.5 allows Yield Expressions, which can occur inside a Lambda body. 
            // In this case, the lambda is a generator and will yield it's final result instead of just return it.
            Statement body;
            if (func.IsGenerator) {
                YieldExpression y = new YieldExpression(expr);
                y.SetLoc(_globalParent, expr.IndexSpan);
                body = new ExpressionStatement(y);
            } else {
                body = new ReturnStatement(expr);
            }
            body.SetLoc(_globalParent, expr.StartIndex, expr.EndIndex);

            FunctionDefinition func2 = PopFunction();
            System.Diagnostics.Debug.Assert(func == func2);

            func.Body = body;
            func.EndIndex = GetEnd();

            LambdaExpression ret = new LambdaExpression(func);
            func.SetLoc(_globalParent, func.IndexSpan);
            ret.SetLoc(_globalParent, func.IndexSpan);
            return ret;
        }
开发者ID:bdoot,项目名称:IronLanguages,代码行数:24,代码来源:Parser.cs


示例17: WithItem

 public WithItem(int start, Expression contextManager, Expression variable) {
     Start = start;
     ContextManager = contextManager;
     Variable = variable;
 }
开发者ID:bdoot,项目名称:IronLanguages,代码行数:5,代码来源:Parser.cs


示例18: AssertStatement

 public AssertStatement(Expression test, Expression message)
 {
     this.test = test;
     this.message = message;
 }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:5,代码来源:Statements.cs


示例19: ExpressionStatement

 public ExpressionStatement(Expression expression)
 {
     this.expr = expression;
 }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:4,代码来源:Statements.cs


示例20: FinishSlice

        private Expression FinishSlice(Expression e0, int start) {
            Expression e1 = null;
            Expression e2 = null;
            bool stepProvided = false;

            switch (PeekToken().Kind) {
                case TokenKind.Comma:
                case TokenKind.RightBracket:
                    break;
                case TokenKind.Colon:
                    // x[?::?]
                    stepProvided = true;
                    NextToken();
                    e2 = ParseSliceEnd();
                    break;
                default:
                    // x[?:val:?]
                    e1 = ParseExpression();
                    if (MaybeEat(TokenKind.Colon)) {
                        stepProvided = true;
                        e2 = ParseSliceEnd();
                    }
                    break;
            }
            SliceExpression ret = new SliceExpression(e0, e1, e2, stepProvided);
            ret.SetLoc(_globalParent, start, GetEnd());
            return ret;
        }
开发者ID:bdoot,项目名称:IronLanguages,代码行数:28,代码来源:Parser.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Ast.FunctionDefinition类代码示例发布时间:2022-05-26
下一篇:
C# Ast.AstGenerator类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap