Ejemplo n.º 1
0
 protected internal virtual Unit createDSNode(DataSet ds, string id, bool check)
 {
     if (id[0] == '#')
     {
         int colNo = 0;
         try
         {
             colNo = int.Parse(id.Substring(1));
         }
         catch (FormatException)
         {
             throw new ReportError("数据集列索引格式不正确");
         }
         if (check)
         {
             if (ds == null)
             {
                 throw new ReportError("数据集未产生");
             }
             if (colNo > ds.ColumnCount)
             {
                 throw new ReportError("数据集列索引超出范围");
             }
             return(new DSVar(ds, colNo));
         }
     }
     if (!this.Boolean_0)
     {
         if (!check)
         {
             return(new DSVar(ds, id));
         }
         if (ds == null)
         {
             throw new ReportError("数据集未产生");
         }
         if (ds.isColumnName(id))
         {
             return(new DSVar(ds, ds.getColumnNo(id)));
         }
     }
     else if (LoadFunction.isDSFunName(id))
     {
         FunctionUnit unit2 = check ? LoadFunction.newDSFunction(id, this.env_0, this.cellExt1_0, ds) : LoadFunction.newDSFunction(id, this.env_0, this.cellExt1_0);
         unit2.setParameter(this.scanParameter());
         return(unit2);
     }
     return(null);
 }
Ejemplo n.º 2
0
        protected internal virtual Unit createNode()
        {
            char ch  = this.string_0[this.int_0];
            int  num = -1;

            switch (ch)
            {
            case '"':
            case '\'':
            {
                num = ExpString.scanQuotation(this.string_0, this.int_0);
                if (num == -1)
                {
                    throw new ReportError("引号不匹配");
                }
                string str3 = this.string_0.Substring(this.int_0 + 1, num - (this.int_0 + 1));
                this.int_0 = num + 1;
                return(new Constant(str3));
            }
            }
            if ((this.cellExt1_0 != null) && (ch == '{'))
            {
                num = ExpString.scanBrace(this.string_0, this.int_0);
                if (num == -1)
                {
                    throw new ReportError("大括号不匹配");
                }
                FunctionUnit unit7 = LoadFunction.newFunction("select", this.env_0, this.cellExt1_0, this.dataSet_0);
                unit7.setParameter(this.string_0.Substring(this.int_0 + 1, num - (this.int_0 + 1)));
                this.int_0 = num + 1;
                return(unit7);
            }
            if ((this.cellExt1_0 != null) && (ch == '['))
            {
                FunctionUnit unit6;
                num = ExpString.scanBracket(this.string_0, this.int_0);
                if (num == -1)
                {
                    throw new ReportError("中括号不匹配");
                }
                if ((this.unit_1 != null) && !this.unit_1.Operator)
                {
                    if (this.unit_1 is CSVar)
                    {
                        unit6 = LoadFunction.newFunction("move", this.env_0, this.cellExt1_0, this.dataSet_0);
                        unit6.setParameter(this.string_0.Substring(this.int_0 + 1, num - (this.int_0 + 1)));
                    }
                    else
                    {
                        unit6 = LoadFunction.newFunction("offset", this.env_0, this.cellExt1_0, this.dataSet_0);
                        unit6.setParameter(this.string_0.Substring(this.int_0 + 1, num - (this.int_0 + 1)));
                    }
                }
                else
                {
                    unit6 = LoadFunction.newFunction("list", this.env_0, this.cellExt1_0, this.dataSet_0);
                    unit6.setParameter(this.string_0.Substring(this.int_0 + 1, num - (this.int_0 + 1)));
                }
                this.int_0 = num + 1;
                return(unit6);
            }
            string id = this.scanId();

            if (id.ToUpper().Equals("and".ToUpper()))
            {
                return(new And());
            }
            if (id.ToUpper().Equals("or".ToUpper()))
            {
                return(new Or());
            }
            if (id.ToUpper().Equals("not".ToUpper()))
            {
                return(new Not());
            }
            if (id.ToUpper().Equals("in".ToUpper()))
            {
                return(new In());
            }
            if (id.ToUpper().Equals("to".ToUpper()))
            {
                return(new To());
            }
            if (id.ToUpper().Equals("like".ToUpper()))
            {
                return(new Like());
            }
            DataSet ds    = this.dataSet_0;
            int     index = id.IndexOf('.');

            if ((index > 0) && !char.IsDigit(id[0]))
            {
                string str2 = id.Substring(0, index);
                if (this.env_0.isDataSetName(str2))
                {
                    ds = this.env_0.getDataSet(str2);
                    id = id.Substring(index + 1);
                    Unit unit5 = this.createDSNode(ds, id, true);
                    if (unit5 == null)
                    {
                        throw new ReportError("有不可识别的数据集函数" + id.ToString().ToString());
                    }
                    return(unit5);
                }
            }
            if (this.dataSet_0 != null)
            {
                Unit unit4 = this.createDSNode(this.dataSet_0, id, true);
                if (unit4 != null)
                {
                    return(unit4);
                }
            }
            if (this.unit_1 is DSMember)
            {
                Unit unit3 = this.createDSNode(this.dataSet_0, id, false);
                if (unit3 != null)
                {
                    return(unit3);
                }
            }
            bool isSaved = false;

            if (id[0] != '@')
            {
                if (id[0] == '$')
                {
                    id      = id.Substring(1);
                    isSaved = true;
                }
            }
            else
            {
                id = id.Substring(1);
            }
            if ((this.cellExt1_0 != null) && id.ToUpper().Equals("value".ToUpper()))
            {
                return(new CSCurrent(this.cellExt1_0));
            }
            if (this.env_0.isParamName(id))
            {
                return(new Constant(this.env_0.getParam(id)));
            }
            if ((this.cellExt1_0 != null) && this.cellExt1_0.isSource(id.ToLower()))
            {
                id = id.ToLower();
                if (this.cellExt1_0.getSource(id) != null)
                {
                    return(new CSVar(this.cellExt1_0.getSource(id), isSaved));
                }
                return(new CSVar(this.cellExt1_0, id));
            }
            if (!this.Boolean_0)
            {
                return(new Constant(ConvertTool.parse(id)));
            }
            if (!LoadFunction.isFunName(id))
            {
                throw new ReportError("未知的函数" + id.ToString().ToString());
            }
            FunctionUnit unit2 = LoadFunction.newFunction(id, this.env_0, this.cellExt1_0, this.dataSet_0);

            unit2.setParameter(this.scanParameter());
            return(unit2);
        }
Ejemplo n.º 3
0
        protected internal virtual void create()
        {
            int  num  = this.string_0.Length;
            Unit unit = null;
            int  num2 = 0;

            while (this.int_0 < num)
            {
                char ch2 = this.string_0[this.int_0];
                if (char.IsWhiteSpace(ch2))
                {
                    goto Label_041D;
                }
                unit = null;
                char ch = ch2;
                switch (ch)
                {
                case '!':
                    this.int_0++;
                    if ((this.int_0 < num) && (this.string_0[this.int_0] == '='))
                    {
                        unit = new NotEquals();
                        this.int_0++;
                    }
                    if (unit == null)
                    {
                        unit = new Not();
                    }
                    goto Label_03B6;

                case '"':
                case '#':
                case '$':
                case '\'':
                case ';':
                    goto Label_02D1;

                case '%':
                    unit = new Mod();
                    this.int_0++;
                    goto Label_03B6;

                case '&':
                    this.int_0++;
                    if ((this.int_0 >= num) || (this.string_0[this.int_0] != '&'))
                    {
                        break;
                    }
                    unit = new And();
                    this.int_0++;
                    goto Label_03B6;

                case '(':
                    goto Label_02DD;

                case ')':
                    goto Label_02F4;

                case '*':
                    goto Label_0312;

                case '+':
                    goto Label_032B;

                case ',':
                    throw new ReportError(new StringBuilder("位置").Append(this.int_0).Append("不应该出现逗号").ToString().ToString());

                case '-':
                    goto Label_0341;

                case '.':
                    goto Label_0357;

                case '/':
                    unit = new Divide();
                    this.int_0++;
                    goto Label_03B6;

                case ':':
                    unit = new Link(this.cellExt1_0);
                    this.int_0++;
                    goto Label_03B6;

                case '<':
                    this.int_0++;
                    if ((this.int_0 < num) && (this.string_0[this.int_0] == '='))
                    {
                        unit = new NotGreater();
                        this.int_0++;
                    }
                    if (unit == null)
                    {
                        unit = new Smaller();
                    }
                    goto Label_03B6;

                case '=':
                    this.int_0++;
                    if ((this.int_0 < num) && (this.string_0[this.int_0] == '='))
                    {
                        this.int_0++;
                    }
                    unit = new Equals();
                    goto Label_03B6;

                case '>':
                    this.int_0++;
                    if ((this.int_0 < num) && (this.string_0[this.int_0] == '='))
                    {
                        unit = new NotSmaller();
                        this.int_0++;
                    }
                    if (unit == null)
                    {
                        unit = new Greater();
                    }
                    goto Label_03B6;

                default:
                    if (ch != '|')
                    {
                        goto Label_02D1;
                    }
                    this.int_0++;
                    if ((this.int_0 >= num) || (this.string_0[this.int_0] != '|'))
                    {
                        throw new ReportError("不能识别标识符|");
                    }
                    unit = new Or();
                    this.int_0++;
                    goto Label_03B6;
                }
                unit = LoadFunction.newFunction("address", this.env_0, this.cellExt1_0, this.dataSet_0);
                goto Label_03B6;
Label_02D1:
                unit = this.createNode();
                goto Label_03B6;
Label_02DD:
                num2++;
                this.int_0++;
                continue;
Label_02F4:
                if (--num2 < 0)
                {
                    throw new ReportError("括号不匹配,右括号太多!");
                }
                this.int_0++;
                continue;
Label_0312:
                unit = new Multiply();
                this.int_0++;
                goto Label_03B6;
Label_032B:
                unit = new Add();
                this.int_0++;
                goto Label_03B6;
Label_0341:
                unit = new Subtract();
                this.int_0++;
                goto Label_03B6;
Label_0357:
                if ((this.unit_1 != null) && !this.unit_1.Operator)
                {
                    unit = LoadFunction.newFunction("dsmember", this.env_0, this.cellExt1_0, this.dataSet_0);
                    this.int_0++;
                }
                else
                {
                    unit = this.createNode();
                }
Label_03B6:
                unit.InBrackets = num2;
                this.unit_1     = unit;
                if (this.unit_0 != null)
                {
                    Unit right = this.unit_0;
                    Unit unit2 = null;
                    while (right != null)
                    {
                        if (right.Priority >= unit.Priority)
                        {
                            break;
                        }
                        unit2 = right;
                        right = right.Right;
                    }
                    unit.Left = right;
                    if (unit2 == null)
                    {
                        this.unit_0 = unit;
                    }
                    else
                    {
                        unit2.Right = unit;
                    }
                    continue;
                }
                this.unit_0 = unit;
                continue;
Label_041D:
                this.int_0++;
            }
            if (num2 > 0)
            {
                throw new ReportError("括号不匹配,左括号太多!");
            }
        }