Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

main.cc

Go to the documentation of this file.
00001 /*
00002  *  File:       cucu.c
00003  *              $Id: main.cc,v 1.9 2002/06/05 21:34:03 alec Exp $
00004  *
00005  *  Author:     Alec Panoviciu (alecu@email.com)
00006  *
00007  *  Comments:
00008  *
00009  *  Revision history:
00010  *
00011  *  $Log: main.cc,v $
00012  *  Revision 1.9  2002/06/05 21:34:03  alec
00013  *  ret code from main fix
00014  *
00015  *  Revision 1.8  2002/05/22 01:38:43  alec
00016  *  (finally) fixed the / problem :)
00017  *
00018  *  Revision 1.7  2002/05/16 21:27:03  alec
00019  *  *** empty log message ***
00020  *
00021  *  Revision 1.6  2002/05/04 17:39:22  alec
00022  *  the scanner works (slightly tested)
00023  *
00024  *  Revision 1.5  2002/05/01 16:32:14  alec
00025  *  dfa ok. huh !
00026  *
00027  *  Revision 1.4  2002/04/29 17:55:41  alec
00028  *  regexps almost done
00029  *
00030  *  Revision 1.3  2002/04/29 09:34:10  alec
00031  *  scanner ptree building compiles
00032  *
00033  */
00034 
00035 /* 
00036   Copyright (C) 2002 Alexandru Panoviciu (alecu@email.com)
00037 
00038   This program is free software; you can redistribute it and/or modify
00039   it under the terms of the GNU General Public License as published by
00040   the Free Software Foundation; either version 2 of the License, or
00041   (at your option) any later version.
00042 
00043   This program is distributed in the hope that it will be useful,
00044   but WITHOUT ANY WARRANTY; without even the implied warranty of
00045   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00046   GNU General Public License for more details.
00047 
00048   You should have received a copy of the GNU General Public License
00049   along with this program; if not, write to the Free Software
00050   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00051 
00052  */
00053 
00054 #include "../config.h"
00055 #include "cmdline_parser.hh"
00056 #include "prop_registry.hh"
00057 #include "parse_util.hh"
00058 #include "cppcc_driver.hh"
00059 
00060 void printVersion ()
00061 {
00062   cerr << "C++ Compiler Compiler Ver. " << VERSION << endl
00063        << "Copyright (C) 2002 Alec Panovici (alecu@email.com)" << endl
00064        << "This program is free software; you may redistribute it under the terms of" << endl
00065        << "the GNU General Public License." << endl 
00066        << endl;
00067 }
00068 
00069 int main (int argc, char *argv[]) throw (exception)
00070 {
00071   PropRegistry registry;
00072   CmdLineParser clp("cppcc", registry);
00073   int fileArgc;
00074   
00075 
00076   /* set up default options values */
00077   registry["print_usage"] = false;
00078   registry["print_version"] = false;
00079   registry["be_verbose"] = false;
00080   registry["debug"] = "";
00081   registry["target_dir"] = "";
00082 
00083   /* set up command line syntax */
00084   clp
00085     .add("b", false, true, "h", "help", "print_usage", "Prints this help message.")
00086     .add("b", false, true, "V", "version", "print_version", "Output version and copyright information.")
00087     .add("b", false, true, "v", "verbose", "be_verbose", "Makes CppCC be verbose about what it's doing.")
00088     .add("s", false, true, "d", "dir", "target_dir", "Put the ouput files ino the specified dir.")
00089 #ifdef DEBUG
00090     .add("s", false, true, "g", "debug", "debug", "Enables debug switches; each letter in the string argument enables a certain feature: \'s\' - enables scanner's debug features, \'p\' - enables parser's debug features, \'o\' - enables the option parser debug features, \'d\' - causes a parse tree dump \'f\' - dumps DFA intermediate data.");
00091 #endif
00092     ;
00093 
00094   
00095   try {
00096     fileArgc = clp.parse(--argc, ++argv);
00097   } catch (CmdLineParseException &pex)
00098   {
00099     die(formatError((string) ("Bad command line syntax "
00100                               "(run cppcc --help for usage help) :")
00101                     + pex.what()));
00102   } 
00103 
00104   if (((string) registry["target_dir"]) != "")
00105     registry["target_dir"] = (string) registry["target_dir"] + '/';
00106 
00107   if (registry["print_usage"]) {
00108     printVersion();
00109     clp.printUsage(cout);
00110     return 0;
00111   }
00112 
00113   if (registry["print_version"]) { printVersion(); }
00114 
00115   if (fileArgc == argc)
00116     die(formatError("No input files given."));
00117 
00118   registry["input_file"] = argv[fileArgc];
00119 
00120   /* setup done, we move to the real thing */
00121   bool ok = CppCcDriver().run(registry);
00122 
00123   if (registry["be_verbose"])
00124     cerr << "CppCC finished " << (ok ? "" : "un" ) << "successfully." << endl;
00125   
00126   return !ok;
00127 }

Generated at Tue Jul 9 21:05:44 2002 for CppCC by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001