Example #1
0
        public bool Load(MemFile memFile, bool continueOnError)
        {
            ClearErrorMessages();

            StringBuilder lBuffer = new StringBuilder();

            bool pStarted = false;
            int lLineNbr = 0;

            while (!memFile.EOF)
            {
                string lLine = memFile.ReadLine('\n');

                if (lLine.Trim().ToUpper() == "###MATRIX")
                    return IsError();

                if (lLine.Length > 0)
                {
                    if (memFile.EOF)
                        lBuffer.Append(lLine);

                    if ((lLine[0] == 'P') || memFile.EOF)
                    {

                        if (pStarted)
                        {
                            // EOF of a Pattern
                            Pattern lPattern = new Pattern(lBuffer.ToString(), lLineNbr);

                            if (lPattern.IsOk())
                                Add(lPattern);
                            else
                            {
                                SetErrorMessage("ERROR: Unable to compile pattern - Line # " + lLineNbr.ToString() + ":", lPattern);

                                Console.Error.WriteLine("ERROR: Unable to compile pattern.");
                                Console.Error.WriteLine(lPattern.GetErrorMessage());
                                //								return true;
                                if (!continueOnError)
                                    return false;
                            }

                            lBuffer = new StringBuilder();

                            pStarted = false;
                        }
                        else
                        {
                            pStarted = true;
                            lLineNbr = memFile.LineNbr;
                        }
                    }

                    if (lLine[0] == 'P')
                        pStarted = true;

                    if (pStarted)
                        lBuffer.Append(lLine);

                }

            }

            return true;
        }
Example #2
0
        public bool Load(MemFile memFile, bool continueOnError)
        {
            ClearErrorMessages();

            StringBuilder lBuffer = new StringBuilder();

            bool pStarted = false;
            int  lLineNbr = 0;

            while (!memFile.EOF)
            {
                string lLine = memFile.ReadLine('\n');

                if (lLine.Trim().ToUpper() == "###MATRIX")
                {
                    return(IsError());
                }

                if (lLine.Length > 0)
                {
                    if (memFile.EOF)
                    {
                        lBuffer.Append(lLine);
                    }

                    if ((lLine[0] == 'P') || memFile.EOF)
                    {
                        if (pStarted)
                        {
                            // EOF of a Pattern
                            Pattern lPattern = new Pattern(lBuffer.ToString(), lLineNbr);

                            if (lPattern.IsOk())
                            {
                                Add(lPattern);
                            }
                            else
                            {
                                SetErrorMessage("ERROR: Unable to compile pattern - Line # " + lLineNbr.ToString() + ":", lPattern);

                                Console.Error.WriteLine("ERROR: Unable to compile pattern.");
                                Console.Error.WriteLine(lPattern.GetErrorMessage());
                                //								return true;
                                if (!continueOnError)
                                {
                                    return(false);
                                }
                            }

                            lBuffer = new StringBuilder();

                            pStarted = false;
                        }
                        else
                        {
                            pStarted = true;
                            lLineNbr = memFile.LineNbr;
                        }
                    }

                    if (lLine[0] == 'P')
                    {
                        pStarted = true;
                    }

                    if (pStarted)
                    {
                        lBuffer.Append(lLine);
                    }
                }
            }

            return(true);
        }