public void AtomicDismantling(Container.Container container, int index)
        {
            Console.WriteLine("\t\t### Expression ###");

            if (container.Elements.Count <= index)
            {
                return;
            }

            counter++;

            try
            {
                Console.WriteLine("--------  "+ index +"  -------  " + container.Elements[index].Type + "   >>>>>>>     " + container.Elements[index].Data.Data);
                if (!DismantlingValidityTest(container.Elements[index].Data.Data, index))
                {
                    DismantlingContext.AtomicDismantling(GetDismantlingType(index, container), container, index + 1);
                }

                int nullidx = index;
                while (nullidx < DefinedList.CompositionList.Count
                    && DefinedList.CompositionList[nullidx] != null
                    && !(hsOperators.Contains(container.Elements[nullidx].Data.Data as string) || (GetDismantlingType(nullidx, container) == eDismantlingTypes.SimpleExpression)))
                {
                    nullidx++;
                }

                if (nullidx != DefinedList.CompositionList.Count)
                {
                    if (hsOperators.Contains(container.Elements[nullidx].Data.Data as string))
                        DefinedList.CompositionList[nullidx] = new CompositionValue(-1, eCompositionTypes.undefined);
                    DismantlingContext.AtomicDismantling(eDismantlingTypes.Expression, container, nullidx);

                    if (counter == 1 && DefinedList.OperationList.Peek().Index == index && DefinedList.OperationList.Peek().Operator != null)
                    {
                        Operation(-1, nullidx + 1);
                    }
                    else if (counter == 2)
                    {
                        counter--;
                    }
                }
                else
                {
                    /* 
                     * Elvileg ez kiszedi az olyan Node-okat, ami már biztosan nem lesz semmire sem felhasználva
                     * (leginkább egy felesleges node-ot amit az olyan lefutás eredményez, mikor amúgy végigszaladnánk a tömbön)
                     */
                    //DefinedList.RemoveOperationsNodeToIndex(index);
                    counter--;
                }
                
            }
            catch (Exception exc)
            {
                Console.WriteLine("EXPRESSION EXCEPTION EXPRESSION EXCEPTION EXPRESSION EXCEPTION EXPRESSION EXCEPTION " + Environment.NewLine);
                Console.WriteLine(exc.Message);
                Console.WriteLine(Environment.NewLine + "EXPRESSION EXCEPTION EXPRESSION EXCEPTION EXPRESSION EXCEPTION EXPRESSION EXCEPTION ");
            }
        }
        public void AtomicDismantling(Container.Container container, int index)
        {
            Console.WriteLine("### Program line ###");
            if (container.Elements.Count <= index)
            {
                return;
            }
            
            string type = Regex.Replace(container.Elements[index].Type, "[^0-9a-zA-Z]+", "");
            eDismantlingTypes literalType = eDismantlingTypes.undefined;
            try
            {
                literalType = (eDismantlingTypes)Enum.Parse(typeof(eDismantlingTypes), type);
            }
            catch (Exception) { }

            if (literalType != eDismantlingTypes.undefined)
            {
                if (literalType == eDismantlingTypes.Expression)
                {
                    DismantlingContext.AtomicDismantling(literalType, container, index + 1);
                    EqualizationContext.CopyValue(DefinedList.CompositionList[index + 1].returnType, index + 1, index);
                }
            }
        }
        public void AtomicDismantling(Container.Container container, int i)
        {
            int index = i;
            if (container.Elements.Count <= i)
            {
                return;
            }

            try
            {
                eAtomicLiteralContexts literalType = eAtomicLiteralContexts.undefined;

                bool runable = false;

                if (DismantlingValidityTest(container.Elements[index].Type, index))
                {
                    literalType = (eAtomicLiteralContexts)Enum.Parse(typeof(eAtomicLiteralContexts), container.Elements[index].Type);
                    Console.WriteLine();
                    Console.WriteLine("--- >> FACTOR: " + literalType);
                    Console.WriteLine();
                    LiteralContext.Execute(literalType, container, index);
                    EqualizationContext.DefineValue(DefinedList.CompositionList[index].returnType, index, DefinedList.CompositionList[index].value);
                }
                else
                {
                    string type = Regex.Replace(container.Elements[index + 1].Type, "[^0-9a-zA-Z]+", "");
                    eDismantlingTypes dismantlingType = (eDismantlingTypes)Enum.Parse(typeof(eDismantlingTypes), type);

                    DismantlingContext.AtomicDismantling(dismantlingType, container, index + 2);

                    EqualizationContext.CopyValue(DefinedList.CompositionList[index + 2].returnType, index + 2, index + 1);

                    runable = true;
                }

                if (DismantlingModifiers.Count > 0 && runable)
                {
                    Operation(i);
                    runable = false;
                    DismantlingModifiers.Clear();
                }
            }
            catch (NotImplementedException exc)
            {
                Console.WriteLine("FACTOR EXCEPTION FACTOR EXCEPTION FACTOR EXCEPTION FACTOR EXCEPTION FACTOR EXCEPTION ");
                Console.WriteLine(exc.Message);
                Console.WriteLine("FACTOR EXCEPTION FACTOR EXCEPTION FACTOR EXCEPTION FACTOR EXCEPTION FACTOR EXCEPTION ");
            }
            catch (Exception exc)
            {
                Console.WriteLine("CONVERT ERROR");
                Console.WriteLine("volt faktor, amire még nem készültünk fel, emiatt nem tudtam becserélni");
            }
        }
        public void AtomicDismantling(Container.Container container, int index)
        {
            Console.WriteLine("\t\t### Term ###");

            if (container.Elements.Count <= index)
            {
                return;
            }

            counter++;

            string type = Regex.Replace(container.Elements[index].Type, "[^0-9a-zA-Z]+", "");
            eDismantlingTypes literalType = (eDismantlingTypes)Enum.Parse(typeof(eDismantlingTypes), type);

            DismantlingContext.AtomicDismantling(literalType, container, index + 1);

            EqualizationContext.CopyValue(DefinedList.CompositionList[index + 1].returnType, index + 1, index);
        }
        public void Execute(Container.Container container, int i)
        {
            Console.WriteLine("-- RealLiteral found, starting the parse methode... (" + i + ")");
            Console.WriteLine(container.Elements[i].Data.Data);

            try
            {
                Value = new CompositionValue();
                float s = float.Parse(container.Elements[i].Data.Data.ToString());
                Value.value = s;
                Value.returnType = eCompositionTypes.Real;
                Console.WriteLine("-+- Parsing success, the data = " + Value.value);
            }
            catch (Exception exc)
            {
                Console.WriteLine("-->> RealLiteralParseError" + Environment.NewLine + exc);
                Value = null;
            }

            //Console.WriteLine(">>>>> "+ DefinedList.CompositionList.Count +" <<<<<<");

            DefinedList.CompositionList[i] = new CompositionValue(Value.value, eCompositionTypes.Real);
        }
        public eDismantlingTypes GetDismantlingType(int index, Container.Container container)
        {
            eDismantlingTypes literalType = eDismantlingTypes.undefined;
            try
            {
                string type = Regex.Replace(container.Elements[index].Type, "[^0-9a-zA-Z]+", "");
                literalType = (eDismantlingTypes)Enum.Parse(typeof(eDismantlingTypes), type);
            }
            catch (Exception exc)
            {
                Console.WriteLine("#############################################################");
                Console.WriteLine("# Term dismantling strategy - GetDismantlingType");
                Console.WriteLine("# " + exc.Message);
                Console.WriteLine("# Term dismantling strategy - GetDismantlingType");
                Console.WriteLine("#############################################################");
            }

            return literalType;
        }
Ejemplo n.º 7
0
 public Processor(Container container)
 {
     this.container = container;
     Process();
 }
 public eDismantlingTypes GetDismantlingType(int index, Container.Container container)
 {
     throw new NotImplementedException();
 }