Пример #1
0
        public static void Term(GATNode node)
        {
            int     childnum = node.ChildCount();
            string  mulop    = "";
            GATNode child;

            Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().ReflectedType.FullName);

            child = node.getChild(0);
            node.SetProperty("value", child.GetProperty("value"));
            for (int i = 1; i < childnum; i++)
            {
                child = node.getChild(i);
                if (child.GetProperty("value") == "*")
                {
                    mulop = "*";
                }
                else if (child.GetProperty("value") == "/")
                {
                    mulop = "/";
                }
                else//有待解决如何记录结果
                {
                    CodeGenerator.AddCode(mulop, node.GetProperty("value"), child.GetProperty("value"), "T" + CodeGenerator.tempnum);
                    Console.WriteLine(mulop + " " + node.GetProperty("value") + " " + child.GetProperty("value") + " " + "T" + CodeGenerator.tempnum);
                    node.SetProperty("value", "T" + CodeGenerator.tempnum);
                    CodeGenerator.tempnum++;
                }
            }
        }
Пример #2
0
        public static void Var(GATNode node)
        {
            Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().ReflectedType.FullName);
            GATNode IDnode = node.getChild(0);

            node.SetProperty("value", IDnode.GetProperty("value"));
        }
        public static void varDeclaration(GATNode node)
        {
            Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().ReflectedType.FullName);

            string type, id;

            type = node.getChild(0).GetProperty("value");
            id   = node.getChild(1).GetProperty("value");
            node.SetProperty("value", id);
            node.SetProperty("type", type);
            GATNode process = node.GetParent();

            while (process.name == "")
            {
                process = process.GetParent();
            }
            CodeGenerator.AddSymbol(node.GetProperty("value"), process.name, null);
        }