Пример #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public ParseTreeNode convertInfixNotationToASTForIcePlugin(String paramString) throws Exception
        public virtual ParseTreeNode convertInfixNotationToASTForIcePlugin(string paramString)
        {
            System.Collections.Stack stack1 = new System.Collections.Stack();
            System.Collections.Stack stack2 = new System.Collections.Stack();
            string[] arrayOfString          = paramString.Split("", true);
            sbyte    b1    = 0;
            string   str   = "";
            bool     @bool = true;

            for (sbyte b2 = 0; b2 < arrayOfString.Length; b2++)
            {
                string str2;
                bool   bool1;
                string str1;
                if (arrayOfString[b2].Equals(" ") || arrayOfString[b2].Equals(""))
                {
                    b1 = 1;
                }
                else if (arrayOfString[b2].Equals("("))
                {
                    b1 = 2;
                }
                else if (arrayOfString[b2].Equals(")"))
                {
                    b1 = 3;
                }
                else
                {
                    b1 = 4;
                }
                switch (b1)
                {
                case 1:
                    break;

                case 2:
                    stack1.Push("(");
                    break;

                case 3:
                    while (true)
                    {
                        if (stack1.Count > 0)
                        {
                            string str3 = (string)stack1.Pop();
                            if ("(".Equals(str3))
                            {
                                break;
                            }
                            addNode(stack2, str3);
                            continue;
                        }
                        throw new System.InvalidOperationException("Unbalanced right parentheses");
                    }
                    break;

                default:
                    if (this.operators.ContainsKey(arrayOfString[b2]))
                    {
                        @bool = false;
                        BaseOperator baseOperator1 = (BaseOperator)this.operators[arrayOfString[b2]];
                        BaseOperator baseOperator2;
                        while (stack1.Count > 0 && null != (baseOperator2 = (BaseOperator)this.operators[stack1.Peek()]) && ((!baseOperator1.RightAssociative && 0 == baseOperator1.comparePrecedence(baseOperator2)) || baseOperator1.comparePrecedence(baseOperator2) < 0))
                        {
                            stack1.Pop();
                            addNode(stack2, baseOperator2.Symbol + "");
                        }
                        stack1.Push(arrayOfString[b2]);
                        break;
                    }
                    str1  = arrayOfString[b2];
                    bool1 = b2 + true;
                    while (b2 + true < arrayOfString.Length && !arrayOfString[b2 + true].Equals(" ") && !arrayOfString[b2 + true].Equals("(") && !arrayOfString[b2 + true].Equals(")") && !this.operators.ContainsKey(arrayOfString[b2 + true]))
                    {
                        str1 = str1 + arrayOfString[b2 + true];
                        b2++;
                    }
                    str2 = str1;
                    str1 = createValidNameForInput(str1);
                    if (str1.EndsWith("R", StringComparison.Ordinal) && str1.IndexOf("R", StringComparison.Ordinal) != 0)
                    {
                        string str3 = str1.Substring(0, str1.Length - 1);
                        str1 = "( ROUND( (" + str3 + "- INT(" + str3 + ")) * (10^( LEN(ROUND(" + str3 + " - INT(" + str3 + "),2))-2)),4))";
                    }
                    else if (str1.EndsWith("L", StringComparison.Ordinal) && str1.IndexOf("L", StringComparison.Ordinal) != 0)
                    {
                        str1 = "INT(" + str1.Substring(0, str1.Length - 1) + ")";
                    }
                    else if (str1.EndsWith("\"", StringComparison.Ordinal))
                    {
                        if (str1.Substring(0, str1.Length - 1).EndsWith("R", StringComparison.Ordinal) && str1.IndexOf("R", StringComparison.Ordinal) != 0)
                        {
                            string str3 = str1.Substring(0, str1.Length - 2);
                            str1 = "( ROUND( (" + str3 + "- INT(" + str3 + ")) * (10^( LEN(ROUND(" + str3 + " - INT(" + str3 + "),2))-2)),4))";
                        }
                        else if (str1.Substring(0, str1.Length - 1).EndsWith("L", StringComparison.Ordinal) && str1.IndexOf("L", StringComparison.Ordinal) != 0)
                        {
                            str1 = "INT(" + str1.Substring(0, str1.Length - 1) + "\")";
                        }
                    }
                    stack2.Push(new ParseTreeNode(str1, null, null));
                    break;
                }
            }
            while (stack1.Count > 0)
            {
                addNode(stack2, (string)stack1.Pop());
            }
            return((ParseTreeNode)stack2.Pop());
        }
Пример #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public ParseTreeNode convertInfixNotationToAST(String paramString) throws Exception
        public virtual ParseTreeNode convertInfixNotationToAST(string paramString)
        {
            System.Collections.Stack stack1 = new System.Collections.Stack();
            System.Collections.Stack stack2 = new System.Collections.Stack();
            string[] arrayOfString          = paramString.Split("", true);
            sbyte    b1    = 0;
            string   str   = "";
            bool     @bool = true;

            for (sbyte b2 = 0; b2 < arrayOfString.Length; b2++)
            {
                bool   bool1;
                string str1;
                if (arrayOfString[b2].Equals(" "))
                {
                    b1 = 1;
                }
                else if (arrayOfString[b2].Equals("("))
                {
                    b1 = 2;
                }
                else if (arrayOfString[b2].Equals(")"))
                {
                    b1 = 3;
                }
                else
                {
                    b1 = 4;
                }
                switch (b1)
                {
                case 1:
                    break;

                case 2:
                    stack1.Push("(");
                    break;

                case 3:
                    while (true)
                    {
                        if (stack1.Count > 0)
                        {
                            string str2 = (string)stack1.Pop();
                            if ("(".Equals(str2))
                            {
                                break;
                            }
                            addNode(stack2, str2);
                            continue;
                        }
                        throw new System.InvalidOperationException("Unbalanced right parentheses");
                    }
                    break;

                default:
                    if (this.operators.ContainsKey(arrayOfString[b2]))
                    {
                        @bool = false;
                        BaseOperator baseOperator1 = (BaseOperator)this.operators[arrayOfString[b2]];
                        BaseOperator baseOperator2;
                        while (stack1.Count > 0 && null != (baseOperator2 = (BaseOperator)this.operators[stack1.Peek()]) && ((!baseOperator1.RightAssociative && 0 == baseOperator1.comparePrecedence(baseOperator2)) || baseOperator1.comparePrecedence(baseOperator2) < 0))
                        {
                            stack1.Pop();
                            addNode(stack2, baseOperator2.Symbol + "");
                        }
                        stack1.Push(arrayOfString[b2]);
                        break;
                    }
                    str1  = arrayOfString[b2];
                    bool1 = b2 + true;
                    while (b2 + true < arrayOfString.Length && !arrayOfString[b2 + true].Equals(" ") && !arrayOfString[b2 + true].Equals("(") && !arrayOfString[b2 + true].Equals(")") && !this.operators.ContainsKey(arrayOfString[b2 + true]))
                    {
                        str1 = str1 + arrayOfString[b2 + true];
                        b2++;
                    }
                    stack2.Push(new ParseTreeNode(str1, null, null));
                    break;
                }
            }
            while (stack1.Count > 0)
            {
                addNode(stack2, (string)stack1.Pop());
            }
            return((ParseTreeNode)stack2.Pop());
        }
Пример #3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public java.util.List<String> getOperantsListForIce(String paramString) throws Exception
        public virtual IList <string> getOperantsListForIce(string paramString)
        {
            List <object> arrayList = new List <object>();

            System.Collections.Stack stack1 = new System.Collections.Stack();
            System.Collections.Stack stack2 = new System.Collections.Stack();
            string[] arrayOfString          = paramString.Split("", true);
            sbyte    b1    = 0;
            string   str   = "";
            bool     @bool = true;

            for (sbyte b2 = 0; b2 < arrayOfString.Length; b2++)
            {
                string str3;
                string str2;
                bool   bool1;
                string str1;
                if (arrayOfString[b2].Equals(" ") || StringUtils.isNullOrBlank(arrayOfString[b2]))
                {
                    b1 = 1;
                }
                else if (arrayOfString[b2].Equals("("))
                {
                    b1 = 2;
                }
                else if (arrayOfString[b2].Equals(")"))
                {
                    b1 = 3;
                }
                else
                {
                    b1 = 4;
                }
                switch (b1)
                {
                case 1:
                    break;

                case 2:
                    stack1.Push("(");
                    break;

                case 3:
                    while (true)
                    {
                        if (stack1.Count > 0)
                        {
                            string str4 = (string)stack1.Pop();
                            if ("(".Equals(str4))
                            {
                                break;
                            }
                            addNode(stack2, str4);
                            continue;
                        }
                        throw new System.InvalidOperationException("Unbalanced right parentheses");
                    }
                    break;

                default:
                    if (this.operators.ContainsKey(arrayOfString[b2]))
                    {
                        @bool = false;
                        BaseOperator baseOperator1 = (BaseOperator)this.operators[arrayOfString[b2]];
                        BaseOperator baseOperator2;
                        while (stack1.Count > 0 && null != (baseOperator2 = (BaseOperator)this.operators[stack1.Peek()]) && ((!baseOperator1.RightAssociative && 0 == baseOperator1.comparePrecedence(baseOperator2)) || baseOperator1.comparePrecedence(baseOperator2) < 0))
                        {
                            stack1.Pop();
                            addNode(stack2, baseOperator2.Symbol + "");
                        }
                        stack1.Push(arrayOfString[b2]);
                        break;
                    }
                    str1  = arrayOfString[b2];
                    bool1 = b2 + true;
                    while (b2 + true < arrayOfString.Length && !arrayOfString[b2 + true].Equals(" ") && !arrayOfString[b2 + true].Equals("(") && !arrayOfString[b2 + true].Equals(")") && !this.operators.ContainsKey(arrayOfString[b2 + true]))
                    {
                        str1 = str1 + arrayOfString[b2 + true];
                        b2++;
                    }
                    str2 = null;
                    if (str1.EndsWith("R", StringComparison.Ordinal) && str1.LastIndexOf("R", StringComparison.Ordinal) != 0)
                    {
                        str2 = str1.Substring(0, str1.Length - 1);
                        stack2.Push(new ParseTreeNode(str2, null, null));
                    }
                    else if (str1.EndsWith("L", StringComparison.Ordinal) && str1.LastIndexOf("L", StringComparison.Ordinal) != 0)
                    {
                        str2 = str1.Substring(0, str1.Length - 1);
                        stack2.Push(new ParseTreeNode(str2, null, null));
                    }
                    else if (str1.EndsWith("\"", StringComparison.Ordinal))
                    {
                        if (str1.Substring(0, str1.Length - 1).EndsWith("R", StringComparison.Ordinal) && str1.LastIndexOf("R", StringComparison.Ordinal) != 0)
                        {
                            str2 = str1.Substring(0, str1.Length - 2);
                            stack2.Push(new ParseTreeNode(str2, null, null));
                        }
                        else if (str1.Substring(0, str1.Length - 1).EndsWith("L", StringComparison.Ordinal) && str1.LastIndexOf("L", StringComparison.Ordinal) != 0)
                        {
                            str2 = str1.Substring(0, str1.Length - 1);
                            stack2.Push(new ParseTreeNode(str2, null, null));
                        }
                    }
                    str3 = str1;
                    str1 = createValidNameForInput(str1);
                    if (!string.ReferenceEquals(str2, null) && !isNumeric(str2) && !str2.StartsWith("@", StringComparison.Ordinal))
                    {
                        arrayList.Add(str2);
                        stack2.Push(new ParseTreeNode(str1, null, null));
                        break;
                    }
                    if (!string.ReferenceEquals(str1, null) && !isNumeric(str1) && !str1.StartsWith("@", StringComparison.Ordinal))
                    {
                        arrayList.Add(str1);
                        stack2.Push(new ParseTreeNode(str1, null, null));
                        break;
                    }
                    stack2.Push(new ParseTreeNode(str1, null, null));
                    break;
                }
            }
            while (stack1.Count > 0)
            {
                addNode(stack2, (string)stack1.Pop());
            }
            return(arrayList);
        }