Update of /cvsroot/cpptool/rfta/src/astdumper
In directory sc8-pr-cvs1:/tmp/cvs-serv7218/src/astdumper
Modified Files:
Main.cpp
Log Message:
* astdump now takes the input and output file path as argument, and parse the whole file.
* added python script to recursively generate ast dump for all files contained in testdata/
Index: Main.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/astdumper/Main.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Main.cpp 1 Apr 2003 08:29:05 -0000 1.2
--- Main.cpp 30 Apr 2003 22:14:50 -0000 1.3
***************
*** 12,20 ****
std::cout <<
"ASTDump Usage:\n"
! "ASTDump firstLine lastLine filePath [outputDirectory]\n"
"\n"
! "ASTDump will dump the AST of the specified file range in an HTML\n"
"file located in the specified directory. Default for ouput duirectory\n"
! "is ./astdump.\n"
"\n"
"Warning: the outputDirectory must exist!"
--- 12,20 ----
std::cout <<
"ASTDump Usage:\n"
! "ASTDump inputFilePath outputHTMLFilePath\n"
"\n"
! "ASTDump will dump the AST of the specified file in a HTML\n"
"file located in the specified directory. Default for ouput duirectory\n"
! "is .\n"
"\n"
"Warning: the outputDirectory must exist!"
***************
*** 22,29 ****
}
int main( int argc,
char *argv[] )
{
! if ( argc < 4 || argc > 5 )
{
printUsage();
--- 22,46 ----
}
+
+ static std::string readSourceFile( const boost::filesystem::path &path )
+ {
+ boost::filesystem::ifstream stream( path );
+ std::string source;
+ while ( !stream.eof() )
+ {
+ std::string line;
+ std::getline( stream, line );
+ source += line;
+ source += '\n';
+ }
+
+ return source;
+ }
+
+
int main( int argc,
char *argv[] )
{
! if ( argc > 3 )
{
printUsage();
***************
*** 34,65 ****
try
{
! int firstLineNumber = boost::lexical_cast<int>( argv[1] );
! int lastLineNumber = boost::lexical_cast<int>( argv[2] );
! boost::filesystem::path path( argv[3],
boost::filesystem::native );
! std::string outputPathName = "astdump";
! if ( argc == 5 )
! outputPathName = argv[4];
! boost::filesystem::path outputPath( outputPathName,
boost::filesystem::native );
! boost::filesystem::ifstream stream( path );
! int currentLineNumber = 1;
! while ( currentLineNumber < firstLineNumber )
! {
! std::string discard;
! std::getline( stream, discard );
! ++currentLineNumber;
! }
!
! std::string source;
! while ( currentLineNumber <= lastLineNumber )
! {
! std::string line;
! std::getline( stream, line );
! source += line;
! source += '\n';
! ++currentLineNumber;
! }
Refactoring::ASTDumper dumper;
--- 51,60 ----
try
{
! boost::filesystem::path path( argv[1],
boost::filesystem::native );
! boost::filesystem::path outputPath( argv[2],
boost::filesystem::native );
! std::string source = readSourceFile( path );
Refactoring::ASTDumper dumper;
|