コード例 #1
0
 public override void visit(double_const _double_const)
 {
     //throw new NotImplementedException();
 }
コード例 #2
0
        public virtual const_node create_double_const(GPBParser parser)
		{
			const_node cn=null;
            SourceContext sc = GetTokenSourceContext(parser.LRParser);
			try
			{
				System.Globalization.NumberFormatInfo sgnfi=new System.Globalization.NumberFormatInfo();
				sgnfi.NumberDecimalSeparator=".";
				double val=double.Parse(parser.LRParser.TokenString,sgnfi);
				cn=new double_const(val);
				cn.source_context=sc;
			}
			catch(Exception)
			{
				parser.errors.Add(new BadFloat(parser.current_file_name,sc,(syntax_tree_node)parser.prev_node));
			}
			return cn;
		}
コード例 #3
0
 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;
 }
コード例 #4
0
 public override void visit(double_const _double_const)
 {
     returned_scope = TypeTable.real_type;//entry_scope.FindName(PascalABCCompiler.TreeConverter.compiler_string_consts.real_type_name);
     cnst_val.prim_val = _double_const.val;
 }
コード例 #5
0
ファイル: GPPGTools.cs プロジェクト: lisiynos/pascalabcnet
 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;
 }
コード例 #6
0
		public override void visit(double_const _double_const)
		{
			returned_scope = new ElementScope(TypeTable.real_type);
		}
コード例 #7
0
		public void visit(double_const _double_const)
		{
			read_double_const(_double_const);
		}
コード例 #8
0
 public override void visit(double_const _double_const)
 {
     AddPossibleComments(_double_const, true, true);
 }
コード例 #9
0
 public override void visit(double_const _double_const)
 {
     WriteNode(_double_const);
 }
コード例 #10
0
ファイル: visualizator.cs プロジェクト: Slav76/pascalabcnet
		public override void visit(double_const _double_const)
		{
			
		}
コード例 #11
0
        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); // это обязательно!
        }
コード例 #12
0
 public void CompareInternal(double_const left, double_const right)
 {
     if (left == null && right != null || left != null && right == null)
         throw_not_equal(left, right);
     if (left != null && right != null)
     {
         if (left.val != right.val)
             throw_not_equal(left, right);
     }
 }
コード例 #13
0
 public override void visit(double_const _double_const)
 {
     RetValue val = new RetValue();
     val.prim_val = _double_const.val;
     names.Add(_double_const.val.ToString());
     eval_stack.Push(val);
 }
コード例 #14
0
		public void visit(double_const _double_const)
		{
			bw.Write((Int16)11);
			write_double_const(_double_const);
		}
コード例 #15
0
		public void read_double_const(double_const _double_const)
		{
			read_const_node(_double_const);
			_double_const.val = br.ReadDouble();
		}
コード例 #16
0
		public void write_double_const(double_const _double_const)
		{
			write_const_node(_double_const);
			bw.Write(_double_const.val);
		}
コード例 #17
0
		public override void visit(double_const _double_const)
		{
			text="Value: "+_double_const.val.ToString();
		}