public const_node create_double_const(string text, SourceContext sc)
        {
            const_node cn = null;

            try
            {
                System.Globalization.NumberFormatInfo sgnfi = new System.Globalization.NumberFormatInfo();
                sgnfi.NumberDecimalSeparator = ".";
                double val = double.Parse(text, sgnfi);
                cn = new double_const(val);
                cn.source_context = sc;
            }
            catch (Exception)
            {
                errors.Add(new BadFloat(CurrentFileName, sc, null));
            }
            return(cn);
        }
예제 #2
0
        public virtual const_node create_double_const(string text, LexLocation loc)
        {
            const_node cn = null;

            try
            {
                System.Globalization.NumberFormatInfo sgnfi = new System.Globalization.NumberFormatInfo();
                sgnfi.NumberDecimalSeparator = ".";
                double val = double.Parse(text, sgnfi);
                cn = new double_const(val);
                cn.source_context = GetTokenSourceContext(loc);
            }
            catch (Exception)
            {
                PascalABCCompiler.PythonABCParser.Errors.UnexpectedToken ut = new PascalABCCompiler.PythonABCParser.Errors.UnexpectedToken(GPPGParser.current_file_name, GetTokenSourceContext(loc), new syntax_tree_node());
                GPPGParser.errors.Add(ut);
            }
            return(cn);
        }
예제 #3
0
 public override void visit(double_const _double_const)
 {
     text = "Value: " + _double_const.val.ToString();
 }
예제 #4
0
 public virtual void visit(double_const _double_const)
 {
     DefaultVisit(_double_const);
 }
예제 #5
0
		public virtual void post_do_visit(double_const _double_const)
		{
		}
예제 #6
0
		public override void visit(double_const _double_const)
		{
			DefaultVisit(_double_const);
			pre_do_visit(_double_const);
			post_do_visit(_double_const);
		}
        public override void Exit(syntax_tree_node st)
        {
            bracket_expr bre = st as bracket_expr;

            if (bre != null)
            {
                if (bre.expr is int32_const)
                {
                    Replace(st, bre.expr);
                }
            }

            bin_expr vs = st as bin_expr;

            if (vs != null)
            {
                if (vs.left is int32_const && vs.right is int32_const)
                {
                    var a  = vs.left as int32_const;
                    var b  = vs.right as int32_const;
                    var op = vs.operation_type;

                    syntax_tree_node res;
                    switch (op)
                    {
                    case Operators.Plus:
                        res = new int32_const(a.val + b.val);
                        break;

                    case Operators.Minus:
                        res = new int32_const(a.val - b.val);
                        break;

                    case Operators.Multiplication:
                        res = new int32_const(a.val * b.val);
                        break;

                    case Operators.Division:
                        res = new double_const((double)a.val / b.val);
                        break;

                    case Operators.Greater:
                        res = new bool_const(a.val > b.val);
                        break;

                    case Operators.Less:
                        res = new bool_const(a.val < b.val);
                        break;

                    case Operators.GreaterEqual:
                        res = new bool_const(a.val >= b.val);
                        break;

                    case Operators.LessEqual:
                        res = new bool_const(a.val <= b.val);
                        break;

                    default:
                        res = vs;
                        break;
                    }

                    Replace(vs, res);
                }
                if (vs.left is int32_const && vs.right is double_const || vs.right is int32_const && vs.left is double_const || vs.left is double_const && vs.right is double_const)
                {
                    double x, y;
                    if (vs.left is int32_const)
                    {
                        x = (vs.left as int32_const).val;
                    }
                    else
                    {
                        x = (vs.left as double_const).val;
                    }
                    if (vs.right is int32_const)
                    {
                        y = (vs.right as int32_const).val;
                    }
                    else
                    {
                        y = (vs.right as double_const).val;
                    }

                    var op = vs.operation_type;

                    syntax_tree_node res;
                    switch (op)
                    {
                    case Operators.Plus:
                        res = new double_const(x + y);
                        break;

                    case Operators.Minus:
                        res = new double_const(x - y);
                        break;

                    case Operators.Multiplication:
                        res = new double_const(x * y);
                        break;

                    case Operators.Division:
                        res = new double_const(x / y);
                        break;

                    case Operators.Greater:
                        res = new bool_const(x > y);
                        break;

                    case Operators.Less:
                        res = new bool_const(x < y);
                        break;

                    case Operators.GreaterEqual:
                        res = new bool_const(x >= y);
                        break;

                    case Operators.LessEqual:
                        res = new bool_const(x <= y);
                        break;

                    default:
                        res = vs;
                        break;
                    }

                    Replace(vs, res);
                }
            }

            base.Exit(st); // это обязательно!
        }
예제 #8
0
 public virtual void visit(double_const _double_const)
 {
 }
예제 #9
0
 public override void visit(double_const _double_const)
 {
     AddPossibleComments(_double_const, true, true);
 }
		public virtual void visit(double_const _double_const)
		{
			DefaultVisit(_double_const);
		}
예제 #11
0
 public override void visit(double_const _double_const)
 {
 }
예제 #12
0
		public override void visit(double_const _double_const)
		{
			executer.visit(_double_const);
			if (_double_const.attributes != null)
				this.visit((dynamic)_double_const.attributes);
		}