Beispiel #1
0
 public a(dk.b A_0, double A_1)
 {
     this.a = A_0;
     this.c = A_1;
     this.b = "";
 }
Beispiel #2
0
    private static dk.a a(string A_0)
    {
        if (A_0.Length == 0)
        {
            return(new dk.a(dk.b.b, 0.0));
        }
        Queue <dk.a> queue = new Queue <dk.a>();

        dk.b b          = dk.b.a;
        bool flag       = false;
        int  startIndex = -1;

        for (int i = 0; i < A_0.Length; i++)
        {
            dk.b c = dk.b.c;
            if (flag)
            {
                flag = false;
            }
            else
            {
                if (A_0[i] == '\\')
                {
                    flag = true;
                    continue;
                }
                if (e.ContainsKey(A_0[i]))
                {
                    c = e[A_0[i]];
                }
                if (char.IsWhiteSpace(A_0[i]))
                {
                    continue;
                }
            }
            if (((c != b) || (b == dk.b.e)) || (b == dk.b.f))
            {
                if (b != dk.b.a)
                {
                    queue.Enqueue(new dk.a(b, A_0.Substring(startIndex, i - startIndex).Trim()));
                }
                b          = c;
                startIndex = i;
            }
        }
        queue.Enqueue(new dk.a(b, A_0.Substring(startIndex, A_0.Length - startIndex).Trim()));
        Queue <dk.a> queue2 = new Queue <dk.a>();

        while (queue.Count > 0)
        {
            dk.a item = queue.Dequeue();
            switch (item.a)
            {
            case dk.b.b:
                item.c = double.Parse(item.b.Trim(), CultureInfo.InvariantCulture);
                break;

            case dk.b.c:
                dk.a a2;
                if (a(item.b, out a2))
                {
                    item = a2;
                }
                break;
            }
            queue2.Enqueue(item);
        }
        Queue <dk.a> queue3 = new Queue <dk.a>();
        Stack <dk.a> stack  = new Stack <dk.a>();

        while (queue2.Count > 0)
        {
            int  num3;
            dk.a a3 = queue2.Dequeue();
            switch (a3.a)
            {
            case dk.b.b:
            {
                queue3.Enqueue(a3);
                continue;
            }

            case dk.b.c:
            {
                queue3.Enqueue(a3);
                continue;
            }

            case dk.b.d:
                num3 = a3.a();
                goto Label_0210;

            case dk.b.e:
            {
                stack.Push(a3);
                continue;
            }

            case dk.b.f:
                break;

            default:
            {
                continue;
            }
            }
            while (true)
            {
                if (stack.Count == 0)
                {
                    throw new dk.d("No matching '(' found");
                }
                dk.a a4 = stack.Pop();
                if (a4.a != dk.b.e)
                {
                    queue3.Enqueue(a4);
                }
            }
Label_0202:
            queue3.Enqueue(stack.Pop());
Label_0210:
            if (((stack.Count > 0) && (stack.Peek().a == dk.b.d)) && (num3 <= stack.Peek().a()))
            {
                goto Label_0202;
            }
            stack.Push(a3);
        }
        while (stack.Count > 0)
        {
            dk.a a5 = stack.Pop();
            if (a5.a == dk.b.f)
            {
                throw new dk.d("No matching '(' found");
            }
            if (a5.a == dk.b.e)
            {
                throw new dk.d("No matching ')' found");
            }
            queue3.Enqueue(a5);
        }
        while (queue3.Count > 0)
        {
            dk.a a6 = queue3.Dequeue();
            switch (a6.a)
            {
            case dk.b.b:
            case dk.b.c:
                stack.Push(a6);
                break;

            case dk.b.d:
            {
                dk.a a7 = stack.Pop();
                dk.a a8 = stack.Pop();
                stack.Push(a(a8, a7, a6));
                break;
            }
            }
        }
        if (stack.Count == 0)
        {
            throw new dk.d("No operands");
        }
        if (stack.Count > 1)
        {
            throw new dk.d("Operand without intervening operator");
        }
        return(stack.Pop());
    }
Beispiel #3
0
 public a(dk.b A_0, string A_1)
 {
     this.a = A_0;
     this.b = A_1;
     this.c = 0.0;
 }