예제 #1
0
        ExplanationTree traverse(Cursor current, ExplanationTree parent)
        {
            if (parent == null)
            {
                parent = new ExplanationTree("EXPLANATIONS:\n", current.Location);
            }

            string          exp = useTemplate(current);
            ExplanationTree tree;

            if (exp == null)
            {
                tree = parent;
            }
            else
            {
                tree = new ExplanationTree(exp, current.Location);
            }

            foreach (var child in current.Children)
            {
                ExplanationTree childTree = traverse(child, tree);
                if (childTree != null && childTree != tree)
                {
                    tree.addChild(childTree);
                }
            }
            return(tree);
        }
예제 #2
0
        public static void DumpTree(ExplanationTree tree)
        {
            Console.Write(tree.explanation);

            foreach (var child in tree.getChildren())
            {
                DumpTree(child);
            }
        }
        /// <summary>
        /// Main Method for the prototype
        /// </summary>
        /// <param name="args">The command-line arguments.</param>
        public static void Run(string[] args)
        {
            ClangWrapper cw = new ClangWrapper("src/main.c");

            ClangWrapper.DumpAST(cw.getAST(), 0);

            Translator t = new Translator(cw);

            ExplanationTree.DumpTree(t.Translate());

            cw.Dispose();
            Console.ReadLine();
        }
예제 #4
0
 public void addChild(ExplanationTree tree)
 {
     children.Add(tree);
 }