コード例 #1
0
 private LambdaExpression ParseActionExpression(Rule_actionContext context, IEnumerable <ParameterExpression> parameters)
 {
     using (_parserContext.PushScope())
     {
         var expressionParser = new ExpressionParser(_parserContext);
         var block            = expressionParser.Visit(context.statement_list());
         var lambda           = Expression.Lambda(block, parameters);
         return(lambda);
     }
 }
コード例 #2
0
        public override void EnterRule_action(Rule_actionContext context)
        {
            var contextParameter = Expression.Parameter(typeof(IContext), "context");
            var parameters       = new List <ParameterExpression> {
                contextParameter
            };

            parameters.AddRange(_parserContext.Scope.Values);

            using (_parserContext.PushScope())
            {
                var expressionParser = new ExpressionParser(_parserContext);
                var block            = expressionParser.Visit(context.statement_list());
                var lambda           = Expression.Lambda(block, parameters);
                _actionGroupBuilder.DslAction(_actionGroupBuilder.Declarations, lambda);
            }
        }