コード例 #1
0
        static void Main()
        {
            Console.Write("\n  Test ScopeStack");
            Console.Write("\n =================\n");

            ScopeStack <Elem> mystack = new ScopeStack <Elem>();

            Test.Elem e;
            e.type  = "namespace";
            e.name  = "foobar";
            e.place = 14;
            mystack.push(e);
            e.make("class", "feebar", 21);
            mystack.push(e);
            e.make("function", "doTest", 44);
            mystack.push(e);
            e.make("control", "for", 56);
            mystack.push(e);

            mystack.display();
            Console.WriteLine();

            Elem test = mystack.lastPopped();

            Console.Write("\n  last popped:\n  {0}\n", test);

            e = mystack.pop();
            Console.Write("\n  popped:\n  {0}", e);
            e = mystack.pop();
            Console.Write("\n  popped:\n  {0}\n", e);
            Console.Write("\n  last popped:\n  {0}\n", mystack.lastPopped());

            mystack.display();

            Console.Write("\n\n");
        }
コード例 #2
0
 public override void doAction(CSsemi.CSemiExp semi, string filename)
 {
     if (semi[1].Equals("Inheritance")) //Action for Inheritance
     {
         inheritance(semi, filename);
         return;
     }
     if (semi[0].Contains("Aggregation"))
     {
         aggregation(semi, filename);
         return;
     }
     if (semi[0].Contains("Composition"))
     {
         composition(semi, filename);
         return;
     }
     if (semi[0].Contains("Using"))
     {
         usingRelation(semi, filename);
         return;
     }
     if (semi[0].Contains("namespace"))
     {
         Elem ele = new Elem();
         ele.type = semi[0];
         ele.name = semi[1];
         ele.filename = filename;
         repo_.locations.Add(ele);
     }             
     if (semi[0].Contains("class"))
     {
         Elem ele = new Elem();
         ele.type = semi[0];
         ele.name = semi[1];
         ele.filename = filename;
         repo_.locations.Add(ele);
     }
     if (AAction.displaySemi)
     {
         Console.Write("\n  line# {0,-5}", repo_.semi.lineCount - 1);
         Console.Write("entering ");
         string indent = new string(' ', 2 * repo_.stack.count);
         Console.Write("{0}", indent);
         this.display(semi); // defined in abstract action
     }
     if (AAction.displayStack)
         repo_.stack.display();
 }
コード例 #3
0
        public override void doAction(CSsemi.CSemiExp semi, string filename)
        {
            Elem elem = new Elem();
            elem.type = semi[0];  // expects type
            elem.name = semi[1];  // expects name
            elem.filename = filename;
            if (elem.type.Equals("namespace"))
                elem.namespacename = elem.name;
            else
                elem.namespacename = namespacematch();
            //repo_.stack.push(elem);
            repo_.locations.Add(elem);
            if(!elem.type.Equals("namespace"))
            RepositoryForOutput.storageForOutput_.Add(elem);

            if (AAction.displaySemi)
            {
                Console.Write("\n  line# {0,-5}", repo_.semi.lineCount - 1);
                Console.Write("entering ");
                string indent = new string(' ', 2 * repo_.stack.count);
                Console.Write("{0}", indent);
                this.display(semi); // defined in abstract action
            }
            if (AAction.displayStack)
                repo_.stack.display();

        }
コード例 #4
0
        private static void repositoryForTestUP()
        {
            Elem e = new Elem();
            e.type = "class";
            e.name = "karan";
            e.filename = "file1";
            e.namespacename = "xyz";
            RepositoryForOutput.storageForOutput_.Add(e);
            Elem e1 = new Elem();
            e1.type = "class";
            e1.name = "karan1";
            e1.filename = "file2";
            e1.namespacename = "xyz";
            RepositoryForOutput.storageForOutput_.Add(e1);

            ElemRelation er = new ElemRelation();
            er.relationType = "Aggregation";
            er.fromName = "Display";
            er.toName = "Xyz";
            RepositoryForRelation.storageForRelationship_.Add(er);
            ElemRelation er1 = new ElemRelation();
            er1.relationType = "Inheritance";
            er1.fromName = "Display";
            er1.toName = "Test";
            RepositoryForRelation.storageForRelationship_.Add(er1);
        }
コード例 #5
0
        // ----------< Convert given String to XML and then Type Table List >------------ 
        public List<Elem> typeTableDecoding(string typeTableXML)
        {
            XDocument doc = XDocument.Parse(typeTableXML);
            var q = from x in
                        doc.Elements("TYPETABLE")
                    .Elements()
                    select x;

            List<Elem> typeTable = new List<Elem>();
            Elem el = null;
            int t = 0;
            foreach (var elem in q)
            {
                if (t == 0)
                {
                    el = new Elem();
                }
                if (elem.Name.ToString().Equals("Filename"))
                {
                    el.filename = elem.Value;
                    t++;
                }
                if (elem.Name.ToString().Equals("NamespaceName"))
                {
                    el.namespacename = elem.Value;
                    t++;
                }
                if (elem.Name.ToString().Equals("Type"))
                {
                    el.type = elem.Value;
                    t++;
                }
                if (elem.Name.ToString().Equals("TypeName"))
                {
                    el.name = elem.Value;
                    t++;
                }
                if (t == 4)
                {
                    typeTable.Add(el);
                    t = 0;
                }
            }
            return typeTable;
        }