Exemplo n.º 1
0
 public void setDTAll()
 {
     foreach (var item in datatypes)
     {
         foreach (tokenCounter t in item.counter)
         {
             if (!(new List <string>()
             {
                 "bool", "char", "short", "float", "int", "FILE", "int32", "double", "long", "void"
             }.Exists(element => t.getLexeme() == element)))
             {
                 if (dataTypesAllFile.Select(a => a.getLexeme()).Contains("newDataType"))
                 {
                     tokenCounter t2 = dataTypesAllFile.Find(a => a.getLexeme() == "newDataType");
                     t2.setCount(t2.getCount() + t.getCount());
                 }
                 else
                 {
                     tokenCounter t2 = new tokenCounter(new token("newDataType", "datatype"));
                     t2.setCount(t.getCount());
                     dataTypesAllFile.Add(t2.copy());
                 }
             }
             else if (dataTypesAllFile.Select(a => a.getLexeme()).Contains(t.getLexeme()))
             {
                 tokenCounter t2 = dataTypesAllFile.Find(a => a.getLexeme() == t.getLexeme());
                 t2.setCount(t2.getCount() + t.getCount());
             }
             else
             {
                 dataTypesAllFile.Add(t.copy());
             }
         }
     }
 }
Exemplo n.º 2
0
        public tokenCounter copy()
        {
            tokenCounter t = new tokenCounter(this);

            t.count = this.count;
            return(t);
        }
Exemplo n.º 3
0
 public void setOpAll()
 {
     foreach (var item in operations)
     {
         foreach (tokenCounter t in item.counter)
         {
             if (operationsAllFile.Select(a => a.getLexeme()).Contains(t.getLexeme()))
             {
                 tokenCounter t2 = operationsAllFile.Find(a => a.getLexeme() == t.getLexeme());
                 t2.setCount(t2.getCount() + t.getCount());
             }
             else
             {
                 operationsAllFile.Add(t.copy());
             }
         }
     }
 }
Exemplo n.º 4
0
 public void setSpecialCahrAll()
 {
     foreach (var item in specialChars)
     {
         foreach (tokenCounter t in item.counter)
         {
             if (specialCharAllFile.Select(a => a.getLexeme()).Contains(t.getLexeme()))
             {
                 tokenCounter t2 = specialCharAllFile.Find(a => a.getLexeme() == t.getLexeme());
                 t2.setCount(t2.getCount() + t.getCount());
             }
             else
             {
                 specialCharAllFile.Add(t.copy());
             }
         }
     }
 }
Exemplo n.º 5
0
        public static void adjustLibraries(List <result> rs)
        {
            List <tokenCounter> tcList = new List <tokenCounter>();

            foreach (result r in rs)
            {
                foreach (tokenCounter tc in r.libraries)
                {
                    if (!tcList.Select(a => a.getLexeme()).Contains(tc.getLexeme()))
                    {
                        tokenCounter newTc = tc.copy();
                        newTc.setCount(0);
                        tcList.Add(newTc);
                    }
                }
            }
            allLibrariesZero = tcList;
        }
Exemplo n.º 6
0
 public void setKWAll()
 {
     foreach (var item in keyWords)
     {
         foreach (tokenCounter t in item.counter)
         {
             if (keyWordsAllFile.Select(a => a.getLexeme()).Contains(t.getLexeme()))
             {
                 tokenCounter t2 = keyWordsAllFile.Find(a => a.getLexeme() == t.getLexeme());
                 t2.setCount(t2.getCount() + t.getCount());
             }
             else
             {
                 keyWordsAllFile.Add(t.copy());
             }
         }
     }
 }
Exemplo n.º 7
0
        public List <variableCounter> varsAllFile     = new List <variableCounter>(); //not used


        #region setAll
        public void setValuesAll()
        {
            foreach (var item in values)
            {
                foreach (tokenCounter t in item.counter)
                {
                    if (valuesAllFile.Select(a => a.getType()).Contains(t.getType()))
                    {
                        tokenCounter t2 = valuesAllFile.Find(a => a.getType() == t.getType());
                        t2.setCount(t2.getCount() + t.getCount());
                    }
                    else
                    {
                        tokenCounter t5 = t.copy();
                        t5.setLexeme(t.getType());
                        valuesAllFile.Add(t5);
                    }
                }
            }
        }
Exemplo n.º 8
0
        public static void adjustOperations(List <result> rs)
        {
            List <tokenCounter> tcList = new List <tokenCounter>();

            foreach (result r in rs)
            {
                foreach (scopeTokenCounter operation in r.operations)
                {
                    foreach (tokenCounter tc in operation.counter)
                    {
                        if (!tcList.Select(a => a.getLexeme()).Contains(tc.getLexeme()))
                        {
                            tokenCounter newTc = tc.copy();
                            newTc.setCount(0);
                            tcList.Add(newTc);
                        }
                    }
                }
            }
            alloperationsZero = tcList;
        }
Exemplo n.º 9
0
        public static void adjustKeywords(List <result> rs)
        {
            List <tokenCounter> tcList = new List <tokenCounter>();

            foreach (result r in rs)
            {
                foreach (scopeTokenCounter keywords in r.keyWords)
                {
                    foreach (tokenCounter tc in keywords.counter)
                    {
                        if (!tcList.Select(a => a.getLexeme()).Contains(tc.getLexeme()))
                        {
                            tokenCounter newTc = tc.copy();
                            newTc.setCount(0);
                            tcList.Add(newTc);
                        }
                    }
                }
            }
            allKeywordsZero = tcList;
        }
Exemplo n.º 10
0
        public static void adjustValues(List <result> rs)
        {
            List <tokenCounter> allValuesTypesZero = new List <tokenCounter>();
            tokenCounter        tc1 = new tokenCounter(new token("", "vfloat"));

            tc1.decCount();
            tokenCounter tc2 = new tokenCounter(new token("", "vint"));

            tc2.decCount();
            tokenCounter tc3 = new tokenCounter(new token("", "vchar"));

            tc3.decCount();
            tokenCounter tc4 = new tokenCounter(new token("", "vstring"));

            tc4.decCount();
            allValuesTypesZero.Add(tc1);
            allValuesTypesZero.Add(tc2);
            allValuesTypesZero.Add(tc3);
            allValuesTypesZero.Add(tc4);
            result.allValuesTypesZero = allValuesTypesZero;
        }
Exemplo n.º 11
0
        public void dataTypesComp(coupleComp c)
        {
            List <myrow>        l     = new List <myrow>();
            List <tokenCounter> temp1 = new List <tokenCounter>(c.f1.result.dataTypesAllFile);
            List <tokenCounter> temp2 = new List <tokenCounter>(c.f2.result.dataTypesAllFile);

            foreach (tokenCounter tt in temp1)
            {
                if (!temp2.Select(a => a.getLexeme()).Contains(tt.getLexeme()))
                {
                    tokenCounter tc = tt.copy();
                    tc.setCount(0);
                    temp2.Add(tc);
                }
            }
            foreach (tokenCounter tt in temp2)
            {
                if (!temp1.Select(a => a.getLexeme()).Contains(tt.getLexeme()))
                {
                    tokenCounter tc = tt.copy();
                    tc.setCount(0);
                    temp1.Add(tc);
                }
            }

            foreach (tokenCounter t2 in temp2)
            {
                int a = temp1.Find(aa => aa.getLexeme() == t2.getLexeme()).getCount();
                int b = t2.getCount();
                if ((a != 0) || (b != 0))
                {
                    l.Add(new myrow(a, b, t2.getLexeme(), c.f1.name, c.f2.name));
                }
            }
            c.refreshResult(l);
        }
Exemplo n.º 12
0
 public ComparisonTable(tokenCounter congruentTokenCounter, int firstScopeId, int secondScopeId)
 {
     CongruentTokenCounter = congruentTokenCounter;
     FirstScopeId          = firstScopeId;
     SecondScopeId         = secondScopeId;
 }