Ejemplo n.º 1
0
        public void TestDoubleValueInDifferentCulture()
        {
            var frCulture = CultureInfo.CreateSpecificCulture("fr-FR");
            
            var currentCulture = Thread.CurrentThread.CurrentCulture;
            var currentUICulture = Thread.CurrentThread.CurrentUICulture;

            Thread.CurrentThread.CurrentCulture = frCulture;
            Thread.CurrentThread.CurrentUICulture = frCulture;

            // manually verified s="1,234";
            double d = 1.234;
            string s = d.ToString();

            DoubleNode d1 = new DoubleNode(1.234);
            string s1 = d1.ToString();
            Assert.AreEqual(s1, "1.234");

            ProtoCore.AST.ImperativeAST.DoubleNode d2 = new ProtoCore.AST.ImperativeAST.DoubleNode(1.234);
            string s2 = d2.ToString();
            Assert.AreEqual(s2, "1.234");

            Thread.CurrentThread.CurrentCulture = currentCulture;
            Thread.CurrentThread.CurrentUICulture = currentUICulture;
        }
Ejemplo n.º 2
0
        void Imperative_num(out ProtoCore.AST.ImperativeAST.ImperativeNode node)
        {
            node = null; String localvalue = String.Empty;
            int line = ProtoCore.DSASM.Constants.kInvalidIndex; int col = ProtoCore.DSASM.Constants.kInvalidIndex;

            if (la.kind == 12) {
            Get();
            localvalue = "-"; line = t.line; col = t.col;
            }
            if (la.kind == 2) {
            Get();
            node = new ProtoCore.AST.ImperativeAST.IntNode() { value = localvalue + t.val };
            if (ProtoCore.DSASM.Constants.kInvalidIndex != line){
               node.line = line; node.col = col; }
            else{
               NodeUtils.SetNodeLocation(node, t); }

            } else if (la.kind == 3) {
            Get();
            node = new ProtoCore.AST.ImperativeAST.DoubleNode() { value = localvalue + t.val };
            if (ProtoCore.DSASM.Constants.kInvalidIndex != line){
               node.line = line; node.col = col; }
            else{
               NodeUtils.SetNodeLocation(node, t); }

            } else SynErr(125);
        }
Ejemplo n.º 3
0
	void Imperative_num(out ProtoCore.AST.ImperativeAST.ImperativeNode node) {
		node = null; 
		int sign = 1;
		int line = ProtoCore.DSASM.Constants.kInvalidIndex; int col = ProtoCore.DSASM.Constants.kInvalidIndex;
		
		if (la.kind == 15) {
			Get();
			sign = -1;
			line = t.line; 
			col = t.col; 
			
		}
		if (la.kind == 2) {
			Get();
			Int64 value;
			if (Int64.TryParse(t.val, System.Globalization.NumberStyles.Number, System.Globalization.CultureInfo.InvariantCulture, out value))
			{
			   node = new ProtoCore.AST.ImperativeAST.IntNode(value * sign);
			}
			else
			{
			   node = new ProtoCore.AST.ImperativeAST.NullNode();
			}
			
			if (ProtoCore.DSASM.Constants.kInvalidIndex != line)
			{
			   node.line = line; node.col = col; 
			}
			else
			{
			   NodeUtils.SetNodeLocation(node, t); 
			}
			
		} else if (la.kind == 3) {
			Get();
			double value;
			if (Double.TryParse(t.val, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out value))
			{
			   node = new ProtoCore.AST.ImperativeAST.DoubleNode(value * sign);
			}
			else
			{
			   node = new ProtoCore.AST.ImperativeAST.NullNode();
			}
			
			if (ProtoCore.DSASM.Constants.kInvalidIndex != line){
			   node.line = line; node.col = col; }
			else{
			   NodeUtils.SetNodeLocation(node, t); }
			
		} else SynErr(123);
	}
Ejemplo n.º 4
0
	void Imperative_num(out ProtoCore.AST.ImperativeAST.ImperativeNode node) {
		node = null; 
		int sign = 1;
		int line = ProtoCore.DSASM.Constants.kInvalidIndex; int col = ProtoCore.DSASM.Constants.kInvalidIndex;
		
		if (la.kind == 13) {
			Get();
			sign = -1;
			line = t.line; 
			col = t.col; 
			
		}
		if (la.kind == 2) {
			Get();
			Int64 value;
			if (Int64.TryParse(t.val, out value))
			{
			   node = new ProtoCore.AST.ImperativeAST.IntNode(value * sign);
			}
			else
			{
			   node = new ProtoCore.AST.ImperativeAST.NullNode();
			}
			
			if (ProtoCore.DSASM.Constants.kInvalidIndex != line)
			{
			   node.line = line; node.col = col; 
			}
			else
			{
			   NodeUtils.SetNodeLocation(node, t); 
			}
			
		} else if (la.kind == 3) {
			Get();
			double value;
			if (Double.TryParse(t.val, out value))
			{
			   node = new ProtoCore.AST.ImperativeAST.DoubleNode(value * sign);
			}
			else
			{
			   node = new ProtoCore.AST.ImperativeAST.NullNode();
			}
			
			if (ProtoCore.DSASM.Constants.kInvalidIndex != line){
			   node.line = line; node.col = col; }
			else{
			   NodeUtils.SetNodeLocation(node, t); }
			
		} else SynErr(130);
	}