Example #1
0
 public WhileNode(GenKeeper keeper, ITerminalNode terminal, IExprNode condition, IExprNode prog, IExprNode elseProg)
     : base(keeper, terminal)
 {
     _condition = condition;
     _prog      = prog;
     _elseProg  = elseProg;
 }
Example #2
0
        private IExprNode VisitConditional(IExprNode parent, Expression expr)
        {
            var type = expr.NodeType;
            if (type == ExpressionType.AndAlso)
            {
                var condition = (BinaryExpression)expr;
                var result = new And();
                result.Left = VisitBoolean(result, condition.Left);
                result.Right = VisitBoolean(result, condition.Right);

                return result;
            }

            if (type == ExpressionType.OrElse)
            {
                var condition = (BinaryExpression)expr;
                var result = new Or();
                result.Left = VisitBoolean(result, condition.Left);
                result.Right = VisitBoolean(result, condition.Right);

                return result;
            }

            if (type == ExpressionType.Not)
            {
                var condition = (UnaryExpression)expr;
                var result = new Not();
                result.Expr = VisitBoolean(result, condition.Operand);

                return result;
            }

            return null;
        }
Example #3
0
        public VarSetNode(GenKeeper keeper, ITerminalNode terminal, IExprNode nodeMean)
            : base(keeper, terminal)
        {
            var name = terminal.Symbol.Text;

            _var      = keeper.Vars.Add(name, new Var(name));
            _nodeMean = nodeMean;
        }
Example #4
0
 public NodeRTabl(GenKeeper keeper, ITerminalNode terminal, IExprNode condition)
     : base(keeper, terminal)
 {
     if (terminal != null)
     {
         _tablName = terminal.Symbol.Text;
     }
     _condition = condition;
 }
Example #5
0
 //Получить список MetProps от вершины
 public SetS GetMetProps(IExprNode node)
 {
     if (node is VarNode)
     {
         return(((VarNode)node).Var.MetProps);
     }
     if (node.Type is TablikCalcParam)
     {
         return(((TablikCalcParam)node.Type).MetProps);
     }
     return(null);
 }
Example #6
0
 public IfNode(TablikKeeper keeper, ITerminalNode terminal, IEnumerable <IExprNode> conditions, IEnumerable <IExprNode> variants)
     : base(keeper, terminal)
 {
     _conditions = conditions.ToList();
     _variants   = variants.ToList();
     Args        = new IExprNode[_conditions.Count + _variants.Count];
     for (int i = 0; i < _conditions.Count; i++)
     {
         Args[2 * i]     = _conditions[i];
         Args[2 * i + 1] = _variants[i];
     }
     if (_variants.Count > _conditions.Count)
     {
         Args[Args.Length - 1] = _variants[_variants.Count - 1];
     }
 }
Example #7
0
        //Проверка корректности выражений генерации
        public DataType Check(ITablStruct tabl)
        {
            var child = tabl.Child;

            if (child == null)
            {
                AddError("Недопустимый переход к подтаблице");
                return(DataType.Error);
            }
            if (_pars.Length > 1 && _pars[0].Check(child) == DataType.Boolean)
            {
                _condition = _pars[0];
                _expr      = _pars[1];
                if (_pars.Length == 3)
                {
                    _separator = _pars[2];
                }
            }
            else
            {
                _expr = _pars[0];
                if (_pars.Length == 2)
                {
                    _separator = _pars[1];
                }
                if (_pars.Length == 3)
                {
                    AddError("Недопустимый тип данных условия");
                }
            }

            _expr.Check(child);
            if (_separator != null)
            {
                _separator.Check(child);
            }
            return(DataType.String);
        }
Example #8
0
 public SubNodeR(GenKeeper keeper, ITerminalNode terminal, IExprNode condition)
     : base(keeper, terminal)
 {
     Condition = condition;
 }
Example #9
0
 public IType Check(IExprNode expr)
 {
     return CheckExpr(expr);
 }
Example #10
0
 public NodeValueProg(NodeVoidProg voidProg, IExprNode expr)
 {
     _voidProg = voidProg;
     _expr     = expr;
 }
Example #11
0
        private IExprNode VisitMemberPath(IExprNode parent, Expression expr)
        {
            if (expr.NodeType != ExpressionType.MemberAccess)
                return null;

            var path = ExpressionHelper.GetPropertyPath(expr);

            BracketedName alias;
            PropertyMap map;
            _select.VisitPath(_context, path, out alias, out map);

            return new PropertyAccess
            {
                Alias = alias,
                PropertyMap = map,
                Parent = parent
            };
        }
Example #12
0
 public OverNode(GenKeeper keeper, ITerminalNode terminal, IExprNode expr)
     : base(keeper, terminal)
 {
     _expr = expr;
 }
Example #13
0
        private IExprNode VisitParameter(IExprNode parent, Expression expr)
        {
            if (expr.NodeType != ExpressionType.Parameter)
                return null;

            return new Parameter(new ParameterProvider(_context, (ParameterExpression)expr));
        }
Example #14
0
 public ObjectPropNode(TablikKeeper keeper, IExprNode parent, ITerminalNode terminal, ITerminalNode prop)
     : base(keeper, terminal)
 {
     Parent = parent;
     Prop   = prop.Symbol;
 }
Example #15
0
        private IExprNode VisitVariable(IExprNode parent, Expression expr)
        {
            if (expr.NodeType != ExpressionType.MemberAccess)
                return null;

            return new Parameter(new ConstantProvider(_context, (MemberExpression)expr));
        }
Example #16
0
 public Where(IExprNode expr)
 {
     this.expr = expr;
 }
Example #17
0
        private IExprNode VisitRelational(IExprNode parent, Expression expr)
        {
            var condition = expr as BinaryExpression;
            if (condition == null)
                return null;

            var result = Relational.CreateFrom(expr.NodeType);
            if (result == null)
                return null;

            result.Left = VisitMemberPath(result, condition.Left);
            result.Right = VisitConstant(result, condition.Right)
                        ?? VisitVariable(result, condition.Right)
                        ?? VisitMemberPath(result, condition.Right)
                        ?? VisitParameter(result, condition.Right);

            return result;
        }
Example #18
0
 public MetNode(TablikKeeper keeper, ITerminalNode terminal, IExprNode parent, params IExprNode[] args)
     : base(keeper, terminal, args)
 {
     Parent = parent;
     IsMet  = true;
 }
Example #19
0
        private IExprNode VisitStringLike(IExprNode parent, Expression expr)
        {
            if (expr.NodeType != ExpressionType.Call)
                return null;

            var method = (MethodCallExpression)expr;

            int index = StringMethods.IndexOf(method.Method) + 1;
            if (index <= 0)
                return null;

            var arg = method.Arguments[0];

            var result = new StringLike
            {
                Context = _context,
                PartialPrefix = (index & 1) == 1,
                PartialPostfix = (index & 2) == 2,
            };

            var property = VisitMemberPath(result, method.Object);
            var parameter = VisitConstant(result, arg)
                         ?? VisitVariable(result, arg)
                         ?? VisitParameter(result, arg);

            result.PropertyAccess = property;
            result.Parameter = (Parameter)parameter;

            return result;
        }
Example #20
0
        private IExprNode VisitConstant(IExprNode parent, Expression expr)
        {
            if (expr.NodeType != ExpressionType.Constant)
                return null;

            var constant = (ConstantExpression)expr;

            if (constant.Value == null)
                return Null.Instance;

            return new Parameter(new ConstantProvider(_context, constant));
        }
Example #21
0
 protected virtual IType CheckExpr(IExprNode expr)
 {
     return CheckExpr((dynamic)expr);
 }
Example #22
0
 public SubParamsNode(TablikKeeper keeper, ITerminalNode terminal, IExprNode expr)
     : base(keeper, terminal, expr)
 {
 }
Example #23
0
 protected override IType CheckExpr(IExprNode expr)
 {
     return CheckExpr((dynamic)expr);
 }
Example #24
0
 private IExprNode VisitBoolean(IExprNode parent, Expression expr)
 {
     return VisitRelational(parent, expr) ?? VisitConditional(parent, expr) ?? VisitStringLike(parent, expr) ?? VisitMemberPath(parent, expr);
 }
Example #25
0
 public NodeWhileVoid(GenKeeper keeper, ITerminalNode terminal, IExprNode condition, IVoidNode prog)
     : base(keeper, terminal)
 {
     _condition = condition;
     _prog      = prog;
 }
Example #26
0
 public WhileNode(TablikKeeper keeper, ITerminalNode terminal, IExprNode condition, IExprNode prog)
     : base(keeper, terminal, condition, prog)
 {
 }
Example #27
0
 public MetSignalNode(TablikKeeper keeper, ITerminalNode terminal, IExprNode parent)
     : base(keeper, terminal, parent)
 {
     Parent = parent;
 }
Example #28
0
 public BinaryExprNode(int type, IExprNode left, IExprNode right)
 {
     Type = type;
     Left = left;
     Right = right;
 }
Example #29
0
        public AssignNode(TablikKeeper keeper, ITerminalNode assign, ITerminalNode v, IExprNode expr, IExprNode type = null)
            : base(keeper, assign, expr)
        {
            var vcode = v.Symbol.Text;
            var vars  = Keeper.Param.Vars;

            if (vars.ContainsKey(vcode))
            {
                Var = vars[vcode];
            }
            else
            {
                vars.Add(vcode, Var = new TablikVar(vcode, type == null ? null : type.Type));
            }
            if (Keeper.Param.Inputs.ContainsKey(vcode))
            {
                AddError("Нельзя присваивать значение входу");
            }
        }
Example #30
0
 public ForNode(TablikKeeper keeper, ITerminalNode terminal, TablikVar v, IExprNode array, IExprNode prog)
     : base(keeper, terminal, array, prog)
 {
     Var = v;
 }