コード例 #1
0
        public static string ParseParameters(string subStringParameters, PFContainer lineNew)
        {
            string[] separator       = { "," };
            string[] linesParameters = subStringParameters.Split(separator, StringSplitOptions.RemoveEmptyEntries);
            if (linesParameters.Length > 0)
            {
                lineNew.Parameters = new List <string>();
                foreach (string line in linesParameters)
                {
                    string parameterName         = line.Replace("Знач ", "");
                    int    indexOfSubStringEquel = parameterName.IndexOf("=");
                    if (indexOfSubStringEquel >= 0)
                    {
                        parameterName = parameterName.Substring(0, indexOfSubStringEquel);
                    }
                    parameterName = parameterName.Trim(new char[] { ' ', '\r', '\n', '\t' });
                    lineNew.Parameters.Add(parameterName);
                }
            }

            return("fff");
        }
コード例 #2
0
        public static string ParseCFModuleFileText(string cfModuleFileText, List <PFContainer> linesNew, int startIndex, int endIndex)
        {
            if (startIndex >= endIndex)
            {
                return("fff");
            }

            string subStringFunction     = "Функция";
            string subStringProcedure    = "Процедура";
            string subStringLeftBracket  = "(";
            string subStringRightBracket = ")";
            string subStringExport       = "Экспорт";

            PFContainer lineNew = new PFContainer();

            int indexOfSubStringFunctionOrProcedure = -1;

            int indexOfSubStringFunction  = cfModuleFileText.IndexOf(subStringFunction, startIndex, StringComparison.CurrentCultureIgnoreCase);
            int indexOfSubStringProcedure = cfModuleFileText.IndexOf(subStringProcedure, startIndex, StringComparison.CurrentCultureIgnoreCase);

            if (indexOfSubStringFunction >= 0 && indexOfSubStringProcedure >= 0)
            {
                if (indexOfSubStringFunction < indexOfSubStringProcedure)
                {
                    indexOfSubStringFunctionOrProcedure = indexOfSubStringFunction;
                    lineNew.Type = TypePF.Function;
                    startIndex   = indexOfSubStringFunction + 7;
                }
                else
                {
                    indexOfSubStringFunctionOrProcedure = indexOfSubStringProcedure;
                    lineNew.Type = TypePF.Procedure;
                    startIndex   = indexOfSubStringProcedure + 9;
                }
            }
            else if (indexOfSubStringFunction >= 0)
            {
                indexOfSubStringFunctionOrProcedure = indexOfSubStringFunction;
                lineNew.Type = TypePF.Function;
                startIndex   = indexOfSubStringFunction + 7;
            }
            else if (indexOfSubStringProcedure >= 0)
            {
                indexOfSubStringFunctionOrProcedure = indexOfSubStringProcedure;
                lineNew.Type = TypePF.Procedure;
                startIndex   = indexOfSubStringProcedure + 9;
            }

            //Процедура/функция
            if (indexOfSubStringFunctionOrProcedure >= 0)
            {
                int indexOfSubStringLeftBracket = cfModuleFileText.IndexOf(subStringLeftBracket, startIndex, StringComparison.CurrentCultureIgnoreCase);

                //Левая скобка
                if (indexOfSubStringLeftBracket >= 0)
                {
                    string subStringName = cfModuleFileText.Substring(startIndex, indexOfSubStringLeftBracket - startIndex);
                    subStringName = subStringName.Trim(new char[] { ' ', '\r', '\n', '\t' });
                    if (subStringName.IndexOf(" ") < 0)//В имени процедуры/функции не должно быть пробелов
                    {
                        //Получаем наименование процедуры/функции
                        lineNew.Name = subStringName;
                        startIndex   = indexOfSubStringLeftBracket + 1;

                        int indexOfSubStringRightBracket = cfModuleFileText.IndexOf(subStringRightBracket, startIndex, StringComparison.CurrentCultureIgnoreCase);

                        //Правая скобка
                        if (indexOfSubStringRightBracket >= 0)
                        {
                            //Получаем параметры
                            if (startIndex + 1 < indexOfSubStringRightBracket)
                            {
                                string subStringParameters = cfModuleFileText.Substring(startIndex, indexOfSubStringRightBracket - startIndex);
                                ParseParameters(subStringParameters, lineNew);
                            }

                            startIndex = indexOfSubStringRightBracket + 1;
                            int indexOfSubStringExport = cfModuleFileText.IndexOf(subStringExport, startIndex, StringComparison.CurrentCultureIgnoreCase);

                            //Экспорт
                            if (indexOfSubStringExport >= 0)
                            {
                                if (indexOfSubStringRightBracket + 1 == indexOfSubStringExport)//Между правой скобкой и экпсорт нет символов
                                {
                                    lineNew.Text  = cfModuleFileText.Substring(indexOfSubStringFunctionOrProcedure, indexOfSubStringExport - indexOfSubStringFunctionOrProcedure + 7);
                                    lineNew.Index = indexOfSubStringFunctionOrProcedure;
                                    linesNew.Add(lineNew);
                                    startIndex = indexOfSubStringExport + 8;
                                }
                                else
                                {
                                    string subStringBetweenRightBracketAndExport = cfModuleFileText.Substring(indexOfSubStringRightBracket + 1, indexOfSubStringExport - 1 - indexOfSubStringRightBracket);
                                    string TrimString = subStringBetweenRightBracketAndExport.Trim(new char[] { ' ', '\r', '\n', '\t' });
                                    if (TrimString.Length == 0)
                                    {
                                        lineNew.Text  = cfModuleFileText.Substring(indexOfSubStringFunctionOrProcedure, indexOfSubStringExport - indexOfSubStringFunctionOrProcedure + 7);
                                        lineNew.Index = indexOfSubStringFunctionOrProcedure;
                                        linesNew.Add(lineNew);
                                        startIndex = indexOfSubStringExport + 8;
                                    }
                                }
                            }
                        }
                    }

                    ParseCFModuleFileText(cfModuleFileText, linesNew, startIndex, endIndex);
                }

                else
                {
                    return("fff");
                }
            }

            return("fff");
        }