Esempio n. 1
0
 protected void AttributeUnion(DFANode parent, DFANode left, DFANode right)
 {
     if (left.Count > right.Count)
     {
         parent.Add(left.Attributes);
         parent.Add(right.Attributes);
     }
     else
     {
         parent.Add(left.Attributes);
         parent.Add(right.Attributes);
     }
 }
Esempio n. 2
0
        protected void CreatePattern(PatternKey pattern)
        {
            string lDFA = (new DFAPattern(pattern.Pattern, pattern.Transformation)).DFA;

            DFANodes = new List <DFANode>(lDFA.Length + 1);
            DFANodes.Add(new DFANode());

            for (int lState = 0; lState < lDFA.Length; lState++)
            {
                DFANode lDFANode = new DFANode();

                char c = lDFA[lState];

                for (int z = 0; z < 4; z++)
                {
                    if (Buckets[z].IndexOf(c) >= 0)
                    {
                        lDFANode[z] = lState + 2;
                    }
                }

                DFANodes.Add(lDFANode);
            }

            DFANode lDFANodeLast = new DFANode();

            lDFANodeLast.Add(pattern);
            DFANodes.Add(lDFANodeLast);
        }
Esempio n. 3
0
        protected bool _LoadMatrix(MemFile memFile, PatternCollection patternCollection)
        {
            try
            {
                int lMatrixSize = Convert.ToInt32(memFile.ReadLine());

                DFANodes = new List <DFANode>(lMatrixSize);

                for (int i = 1; i < lMatrixSize; i++)
                {
                    //			Console.Error.Write(memFile.LineNbr.ToString() + " - " + i.ToString() + " - "+lMatrixSize.ToString());

                    DFANode lDFANode = new DFANode();

                    for (int z = 0; z < 4; z++)
                    {
                        lDFANode[z] = Convert.ToInt32(memFile.ReadPart('\t').Trim());
                    }

                    int lNodePatterns = Convert.ToInt32(memFile.ReadPart('\t').Trim());

                    if (lNodePatterns > 0)
                    {
                        lDFANode.Attributes = new List <PatternKey>(lNodePatterns);
                    }

                    for (int p = 0; p < lNodePatterns; p++)
                    {
                        int    lPatternTransformation = Convert.ToInt32(memFile.ReadPart(':').Trim());
                        string lPatternKey            = memFile.ReadPart('\t').Trim();

                        int lTransformation = Convert.ToInt32(memFile.ReadPart('\t').Trim());

                        Pattern lPattern = patternCollection.FindByKey(lPatternKey);

                        lDFANode.Add(new PatternKey(lPattern, lTransformation));
                    }

                    memFile.ReadLine();
                    DFANodes.Add(lDFANode);
                }
            }
            catch (Exception e)
            {
                return(SetErrorMessage("Matrix Error - Line # " + memFile.LineNbr.ToString() + ":", e));
            }

            return(false);
        }
Esempio n. 4
0
 protected void AttributeUnion(DFANode parent, DFANode left, DFANode middle, DFANode right)
 {
     parent.Add(left.Attributes);
     parent.Add(middle.Attributes);
     parent.Add(right.Attributes);
 }
Esempio n. 5
0
        protected bool _LoadMatrix(MemFile memFile, PatternCollection patternCollection)
        {
            try
            {
                int lMatrixSize = Convert.ToInt32(memFile.ReadLine());

                DFANodes = new List<DFANode>(lMatrixSize);

                for (int i = 1; i < lMatrixSize; i++)
                {
                    //			Console.Error.Write(memFile.LineNbr.ToString() + " - " + i.ToString() + " - "+lMatrixSize.ToString());

                    DFANode lDFANode = new DFANode();

                    for (int z = 0; z < 4; z++)
                        lDFANode[z] = Convert.ToInt32(memFile.ReadPart('\t').Trim());

                    int lNodePatterns = Convert.ToInt32(memFile.ReadPart('\t').Trim());

                    if (lNodePatterns > 0)
                        lDFANode.Attributes = new List<PatternKey>(lNodePatterns);

                    for (int p = 0; p < lNodePatterns; p++)
                    {
                        int lPatternTransformation = Convert.ToInt32(memFile.ReadPart(':').Trim());
                        string lPatternKey = memFile.ReadPart('\t').Trim();

                        int lTransformation = Convert.ToInt32(memFile.ReadPart('\t').Trim());

                        Pattern lPattern = patternCollection.FindByKey(lPatternKey);

                        lDFANode.Add(new PatternKey(lPattern, lTransformation));
                    }

                    memFile.ReadLine();
                    DFANodes.Add(lDFANode);
                }
            }
            catch (Exception e)
            {
                return SetErrorMessage("Matrix Error - Line # " + memFile.LineNbr.ToString() + ":", e);
            }

            return false;
        }
Esempio n. 6
0
        protected void CreatePattern(PatternKey pattern)
        {
            string lDFA = (new DFAPattern(pattern.Pattern, pattern.Transformation)).DFA;

            DFANodes = new List<DFANode>(lDFA.Length + 1);
            DFANodes.Add(new DFANode());

            for (int lState = 0; lState < lDFA.Length; lState++)
            {
                DFANode lDFANode = new DFANode();

                char c = lDFA[lState];

                for (int z = 0; z < 4; z++)
                    if (Buckets[z].IndexOf(c) >= 0)
                        lDFANode[z] = lState + 2;

                DFANodes.Add(lDFANode);
            }

            DFANode lDFANodeLast = new DFANode();
            lDFANodeLast.Add(pattern);
            DFANodes.Add(lDFANodeLast);
        }
Esempio n. 7
0
 protected void AttributeUnion(DFANode parent, DFANode left, DFANode middle, DFANode right)
 {
     parent.Add(left.Attributes);
     parent.Add(middle.Attributes);
     parent.Add(right.Attributes);
 }
Esempio n. 8
0
 protected void AttributeUnion(DFANode parent, DFANode left, DFANode right)
 {
     if (left.Count > right.Count)
     {
         parent.Add(left.Attributes);
         parent.Add(right.Attributes);
     }
     else
     {
         parent.Add(left.Attributes);
         parent.Add(right.Attributes);
     }
 }