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


C# Ast.Expression类代码示例

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


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


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