Inferno  0.2
doc_graphs.cpp
Go to the documentation of this file.
00001 #include "tree/cpptree.hpp"
00002 #include "helpers/transformation.hpp"
00003 #include "sr/search_replace.hpp"
00004 #include "sr/soft_patterns.hpp"
00005 #include "common/trace.hpp"
00006 #include "common/read_args.hpp"
00007 #include "doc_graphs.hpp"
00008 #include "graph.hpp"
00009 #include "steps/inferno_patterns.hpp"
00010 #include <inttypes.h>
00011 
00012 using namespace CPPTree;
00013 
00014 /// Output a graph of the subtree at node, to a dot file with basename
00015 /// name and path supplied by user with -o (or local dir)
00016 static void Output( TreePtr<Node> root, string name )
00017 {
00018     string path = ReadArgs::outfile + name + string(".dot");
00019     TRACE("Generating graph ")(path)("\n");    
00020     Graph g( path );
00021     g( root ); 
00022 }
00023 
00024 /// Output a graph for search and replace documentation. For eg section 2.3a use major=2
00025 /// minor=3 and subsection="a". If no letter, leave subsection empty.
00026 static void OutputSR( TreePtr<Node> root, int major, int minor, string subsection, string tag )
00027 {
00028     string name = SSPrintf( "srdoc_%d_%d%s_%s\n", major, minor, subsection.c_str(), tag.c_str() );
00029     Output(root, name); 
00030 }
00031 
00032 void GenerateDocumentationGraphs()
00033 {
00034     MakeTreePtr<If> i;
00035     Output(i, "if"); 
00036 }