test.cc File Reference

#include <lestes/lang/cplus/lex/file_system.hh>
#include <lestes/lang/cplus/lex/preprocessor.hh>
#include <lestes/lang/cplus/sem/sa_statements.g.hh>
#include <lestes/lang/cplus/sem/ss_misc.g.hh>
#include <lestes/lang/cplus/syn/dump_at_lassert.g.hh>
#include <lestes/lang/cplus/syn/hinter.hh>
#include <lestes/lang/cplus/syn/manager.hh>
#include <lestes/lang/cplus/syn/parse_result.hh>
#include <lestes/lang/cplus/syn/parser.hh>
#include <lestes/lang/cplus/syn/prefixer.hh>
#include <lestes/msg/logger.hh>
#include <lestes/package.hh>
#include <lestes/std/action.g.hh>
#include <lestes/std/data_types.hh>
#include <lestes/std/dumper.hh>
#include <vector>
#include <iostream>
#include <fstream>
#include <cstdlib>

Go to the source code of this file.

Namespaces

namespace  lestes
namespace  lestes::lang
namespace  lestes::lang::cplus
namespace  lestes::lang::cplus::syn

Classes

struct  usage_and_exit

Functions

int lestes::lang::cplus::syn::do_it (bool flat_dump, lstring filename, lstring ss_filename, lstring context_filename, bool hinter_on)
void operator<< (::std::ostream &os, const usage_and_exit &)
int main (int argc, char *argv[])


Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 144 of file test.cc.

References lestes::lang::cplus::syn::do_it(), lestes::msg::logger::dump_skeleton(), lestes::msg::logger::finish(), and lestes::msg::logger::init().

00145 {
00146         vector<lstring> args( argv, argv+argc );
00147         vector<lstring>::iterator it = args.begin();
00148         ++it;
00149         lstring filename = "";
00150         lstring ss_filename = "";
00151         lstring context_filename = "";
00152         bool log_finish = false;
00153         bool o_seen = false;
00154         bool f_seen = false;
00155         bool c_seen = false;
00156         bool l_seen = false;
00157         bool h_seen = false;
00158         while (it != args.end() && (*it)[0] == '-') {
00159                 // option found
00160                 if (*it == "-o") {
00161                         if (o_seen)
00162                                 cout << "Error: -o option used multiple times." << usage_and_exit();
00163                         o_seen = true;
00164                         ++it;
00165                         if (it == args.end())
00166                                 cout << "Argument to -o option is missing." << usage_and_exit();
00167                         filename = *it++;
00168                 } else if (*it == "-f") {
00169                         if (f_seen)
00170                                 cout << "Error: -f option used multiple times." << usage_and_exit();
00171                         f_seen = true;
00172                         ++it;
00173                         if (it == args.end())
00174                                 cout << "Argument to -f option is missing." << usage_and_exit();
00175                         ss_filename = *it++;
00176                 } else if (*it == "-c") {
00177                         if (c_seen)
00178                                 cout << "Error: -c option used multiple times." << usage_and_exit();
00179                         c_seen = true;
00180                         ++it;
00181                         if (it == args.end())
00182                                 cout << "Argument to -c option is missing." << usage_and_exit();
00183                         context_filename = *it++;
00184                 } else if (*it == "-l") {
00185                         if (l_seen)
00186                                 cout << "Error: -l option used multiple times." << usage_and_exit();
00187                         l_seen = true;
00188                         ++it;
00189                         if (it == args.end())
00190                                 cout << "Argument to -l option is missing." << usage_and_exit();
00191                         log_finish = ::lestes::msg::logger::init(*it++);
00192                         if (!log_finish)
00193                                 cout << "Error, loggers will be off." << endl;
00194                 } else if (*it == "-s") {
00195                         // can be used multiple times
00196                         ++it;
00197                         if (it == args.end())
00198                                 cout << "Argument to -s option is missing." << usage_and_exit();
00199                         ::std::ofstream of( it->c_str() );
00200                         ++it;
00201 			::lestes::msg::logger::dump_skeleton(of);
00202                         of.close();
00203                 } else if (*it == "-h") {
00204                         ++it;
00205                         h_seen = true;
00206                 } else
00207                         cout << "Unknown option '" << *it << "'." << usage_and_exit();
00208         }
00209         bool flat_dump = false;
00210         if (it != args.end()) {
00211                 if (*it == "flat")
00212                         flat_dump = true;
00213                 else if (*it != "deep")
00214                         cout << "Unknown dump type '" << *it << "'." << usage_and_exit();
00215                 ++it;
00216                 if (it != args.end())
00217                         cout << "Too many arguments." << usage_and_exit();
00218         }
00219         int result = ::lestes::lang::cplus::syn::do_it( flat_dump, filename, ss_filename, context_filename, h_seen );
00220         if (log_finish)
00221 		::lestes::msg::logger::finish();
00222         return result;
00223 }

void operator<< ( ::std::ostream &  os,
const usage_and_exit  
)

Definition at line 125 of file test.cc.

00126 {
00127         os << "\n\n"
00128                 "Usage: parser_test [-h] [-l llc_file] [-s skel_file] [-o output_file] [-f filename] [-c context_filename] [dump_type]\n"
00129                 "\n"
00130                 "Logger configuration is read from llc_file, if specified.\n"
00131                 "Logger configuration skeleton is dumped to skel_file, if specified.\n"
00132                 "AS structures will be dumped into file specified by the -o option.\n"
00133                 "  When the option is missing, they will not be dumped at all.\n"
00134                 "SS structures will be dumped into file specified by the -f option.\n"
00135                 "  When the option is missing, they will not be dumped at all.\n"
00136                 "SA context will be dumped into file specified by the -c option.\n"
00137                 "  When the option is missing, they will not be dumped at all.\n"
00138                 "dump_type is either 'flat' or 'deep', the default is 'deep'.\n"
00139                 "Hinter is turned on by the -h option.\n"
00140                 << endl;
00141         return exit(1);
00142 }


Generated on Mon Feb 12 18:23:47 2007 for lestes by doxygen 1.5.1-20070107