Ejemplo n.º 1
0
 public void AddItemToFinalArray(ItemForVar item)
 {
     for (int i = 0; i < item.GetSellsCount(); i++)
     {
         this._finalArray.Add(item.GetCellByIndex(i));
     }
 }
Ejemplo n.º 2
0
 public void AddItemToFinalArray(ItemForVar item)
 {
     for (int i = 0; i < item.GetSellsCount(); i++)
     {
         this._finalArray.Add(item.GetCellByIndex(i));
     }
 }
Ejemplo n.º 3
0
        private string WorkWithAssignments(string text)
        {
            Func func;

            int lastFuncIndex = 0;

            while ((func = Programm.FindFunc(lastFuncIndex, text)) != null)
            {
                int        lastVarInitIndex = 0;
                Assignment assignment;

                while ((func = Programm.FindFunc(lastFuncIndex, text)) != null && (assignment = Programm.FindAssignment(lastVarInitIndex, func.GetBody())) != null)
                {
                    ItemForVar varibale = this._table.GetItem(assignment.GetVaribaleName(), func.GetName());
                    text = text.Remove(func.GetIndexFuncIntoText() + func.GetIndexBody() + assignment.GetIndexIntoText(), assignment.GetText().Length);
                    string newAssignment = this.GetFuncCallToWrite(varibale.GetIndex(), varibale.GetType(), assignment.GetRightText());
                    text = text.Insert(func.GetIndexFuncIntoText() + func.GetIndexBody() + assignment.GetIndexIntoText(), newAssignment);

                    lastVarInitIndex = assignment.GetIndexIntoText() + assignment.GetText().Length;
                }

                lastFuncIndex = func.GetIndexFuncIntoText() + func.GetFuncText().Length;
            }
            return(text);
        }
Ejemplo n.º 4
0
        private string WorkWithVarInit(string text)
        {
            Func func;

            int lastFuncIndex = 0;

            while ((func = Programm.FindFunc(lastFuncIndex, text)) != null)
            {
                int     lastVarInitIndex = 0;
                VarInit varInit;

                while ((func = Programm.FindFunc(lastFuncIndex, text)) != null && (varInit = Programm.FindVarInit(lastVarInitIndex, func.GetBody())) != null)
                {
                    ItemForVar item = varInit.GetItemForVar();
                    item.SetView(func.GetName());

                    this._table.AddVar(item);
                    text = text.Remove(func.GetIndexFuncIntoText() + func.GetIndexBody() + varInit.GetIndexIntoText(), varInit.GetText().Length);

                    lastVarInitIndex = varInit.GetIndexIntoText() + varInit.GetText().Length;
                }

                lastFuncIndex = func.GetIndexFuncIntoText() + func.GetFuncText().Length;
            }

            return(text);
        }
Ejemplo n.º 5
0
        private string WorkWithFuncsParams(string text)
        {
            Func func;

            int lastFuncIndex = 0;

            while ((func = Programm.FindFunc(lastFuncIndex, text)) != null)
            {
                int     lastVarInitIndex = 0;
                VarInit varInit;

                int paramIndex = 0;
                while ((varInit = Programm.FindVarInit(lastVarInitIndex, func.GetFuncParamsText())) != null)
                {
                    //this._params.Add(varInit.GetItemForVar()); // Запомнить, какие параметры каким функциям принадлежат
                    ItemForVar item = varInit.GetItemForVar();
                    item.SetView(func.GetName());
                    item.SetParamStatus(true);
                    item.SetParamIndex(paramIndex++);

                    this._table.AddVar(item);
                    lastVarInitIndex = varInit.GetIndexIntoText() + varInit.GetText().Length;
                }

                text = text.Remove(func.GetIndexFuncParams() + func.GetIndexFuncIntoText(), func.GetFuncParamsText().Length);

                lastFuncIndex = func.GetIndexFuncIntoText() + func.GetFuncText().Length;
            }

            return(text);
        }
Ejemplo n.º 6
0
        public IntConst(int value, int indexIntoText)
        {
            this._value = value;
            this._indexIntoText = indexIntoText;
            this._item = new ItemForVar(null, null, -1, "int", indexIntoText);

            int letterPos = 0;
            this._item.SetCellByIndex(letterPos, this.GetValue());
        }
Ejemplo n.º 7
0
        public int AddVar(ItemForVar item)
        {
            int newIndex = this.GetNewCellIndex(item.GetType());
            item.SetIndex( newIndex );
            this._varItemList.Add(item);
            this.AddItemToFinalArray(item);

            return newIndex;
        }
Ejemplo n.º 8
0
        public IntConst(int value, int indexIntoText)
        {
            this._value         = value;
            this._indexIntoText = indexIntoText;
            this._item          = new ItemForVar(null, null, -1, "int", indexIntoText);

            int letterPos = 0;

            this._item.SetCellByIndex(letterPos, this.GetValue());
        }
Ejemplo n.º 9
0
        public int AddVar(ItemForVar item)
        {
            int newIndex = this.GetNewCellIndex(item.GetType());

            item.SetIndex(newIndex);
            this._varItemList.Add(item);
            this.AddItemToFinalArray(item);

            return(newIndex);
        }
Ejemplo n.º 10
0
        public StringConst(string text, int indexIntoText)
        {
            this._text = text;
            this._indexIntoText = indexIntoText;
            this._item = new ItemForVar(null, null, -1, "string", indexIntoText);

            int letterPos = 0;
            foreach(char letter in this.GetText())
            {
                this._item.SetCellByIndex( letterPos, (int)letter );
                letterPos++;
            }
        }
Ejemplo n.º 11
0
        public VarInit(string text, int indexIntoText)
        {
            this._text = text;
            this._indexIntoText = indexIntoText;

            Regex regexToType = new Regex(@"^(int|string)");
            Regex regexToName = new Regex(@"(?<=(string|int)\s+)[a-z,A-Z]+[0-9,a-z,A-Z]*(?=(\;|\,|\s*))");

            this._name = regexToName.Match(text).ToString().Split(new Char[] { ',' })[0];
            this._type = regexToType.Match(text).ToString();

            this._item = new ItemForVar(null, this.GetName(), -1, this.GetType(), indexIntoText);
        }
Ejemplo n.º 12
0
        public StringConst(string text, int indexIntoText)
        {
            this._text          = text;
            this._indexIntoText = indexIntoText;
            this._item          = new ItemForVar(null, null, -1, "string", indexIntoText);

            int letterPos = 0;

            foreach (char letter in this.GetText())
            {
                this._item.SetCellByIndex(letterPos, (int)letter);
                letterPos++;
            }
        }