コード例 #1
0
        public void Add(Pattern pattern)
        {
            if (!pattern.IsOk())
            {
                return;
            }

            List <string> lPatternSignatures = new List <string>(8);

            for (int lTransform = 0; lTransform < 8; lTransform++)
            {
                string lSignature = DFAPattern.ToDFA(pattern, lTransform) + "\t" + DFAPattern.ToVariableDFA(pattern, lTransform);

                if (!lPatternSignatures.Contains(lSignature))
                {
                    DFAMatrixes.Push(new DFAMatrix(new PatternKey(pattern, lTransform)));
                    lPatternSignatures.Add(lSignature);
                }
            }
        }
コード例 #2
0
ファイル: PatternCollection.cs プロジェクト: tgiphil/GoTraxx
        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;
        }
コード例 #3
0
ファイル: DFAMatrixBuilder.cs プロジェクト: tgiphil/GoTraxx
        public void Add(Pattern pattern)
        {
            if (!pattern.IsOk())
                return;

            List<string> lPatternSignatures = new List<string>(8);

            for (int lTransform = 0; lTransform < 8; lTransform++)
            {
                string lSignature = DFAPattern.ToDFA(pattern, lTransform) + "\t" + DFAPattern.ToVariableDFA(pattern, lTransform);

                if (!lPatternSignatures.Contains(lSignature))
                {
                    DFAMatrixes.Push(new DFAMatrix(new PatternKey(pattern, lTransform)));
                    lPatternSignatures.Add(lSignature);
                }
            }
        }
コード例 #4
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);
        }