Пример #1
0
        public IntConst GetNextIntConst()
        {
            if (this.lastIntConstPosition < this.IntConsts.Count)
            {
                IntConst IntConst = this.IntConsts[this.lastIntConstPosition];
                this.lastIntConstPosition++;

                return(IntConst);
            }
            else
            {
                return(null);
            }
        }
Пример #2
0
        static public IntConst FindIntConst(int index, string text)
        {
            Regex regexToFindIntConsts = new Regex(@"(?<=[\s,;,+,-,\,*,\,,'(',')'])[\d]+(?=[\s,;,+,-,\,*,\,,'(',')'])");
            Match intConstsMatch       = regexToFindIntConsts.Match(text, index);

            if (intConstsMatch.Success)
            {
                string value = intConstsMatch.Value;

                IntConst newIntConst = new IntConst(Int32.Parse(intConstsMatch.ToString()), intConstsMatch.Index);

                return(newIntConst);
            }
            else
            {
                return(null);
            }
        }
Пример #3
0
        public static IntConst FindIntConst(int index, string text)
        {
            Regex regexToFindIntConsts = new Regex(@"(?<=[\s,;,+,-,\,*,\,,'(',')'])[\d]+(?=[\s,;,+,-,\,*,\,,'(',')'])");
            Match intConstsMatch = regexToFindIntConsts.Match(text, index);
            if (intConstsMatch.Success)
            {
                string value = intConstsMatch.Value;

                IntConst newIntConst = new IntConst(Int32.Parse(intConstsMatch.ToString()), intConstsMatch.Index);

                return newIntConst;

            }
            else
            {
                return null;
            }
        }
Пример #4
0
        private string WorkWithConsts(string text)
        {
            Func     func;
            IntConst intConst = null;

            int lastIntConstIndex = 0;
            int lastFuncIndex     = 0;

            while ((func = Programm.FindFunc(lastFuncIndex, text)) != null)
            {
                lastIntConstIndex = 0;
                string callFuncToRead = "";
                while ((func = Programm.FindFunc(lastFuncIndex, text)) != null && (intConst = Programm.FindIntConst(lastIntConstIndex + callFuncToRead.Length, func.GetBody())) != null)
                {
                    int index       = this._table.AddVar(intConst.GetItemForVar());
                    int posIntoText = intConst.GetIndexIntoText() + func.GetIndexBody() + func.GetIndexFuncIntoText();

                    text           = text.Remove(posIntoText, intConst.GetLength());
                    callFuncToRead = this.GetFuncCallToRead(index, "int");
                    text           = text.Insert(posIntoText, callFuncToRead);

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

            StringConst stringConst = null;

            int lastStringConstIndex = 0;

            lastFuncIndex = 0;

            while ((func = Programm.FindFunc(lastFuncIndex, text)) != null)
            {
                lastStringConstIndex = 0;
                string callFuncToRead = "";
                while ((func = Programm.FindFunc(lastFuncIndex, text)) != null && (stringConst = Programm.FindStringConst(lastStringConstIndex + callFuncToRead.Length, func.GetBody())) != null)
                {
                    int index       = this._table.AddVar(stringConst.GetItemForVar());
                    int posIntoText = stringConst.GetIndexIntoText() + func.GetIndexBody() + func.GetIndexFuncIntoText();
                    // 2 кавычки
                    text = text.Remove(posIntoText, stringConst.GetLength() + 2);

                    callFuncToRead = this.GetFuncCallToRead(index, "string");

                    /*callFuncToRead = "(" + this.GetFuncCallToRead(index, "char");
                     *
                     * for (int i = 1; i < stringConst.GetLength(); i++)
                     * {
                     *  int indexOfChar = index + i;
                     *  callFuncToRead += "+"+this.GetFuncCallToRead(indexOfChar, "char");
                     * }
                     *
                     * callFuncToRead += ").ToString()";*/
                    text = text.Insert(posIntoText, callFuncToRead);

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

            return(text);
        }