microbe/main.cpp

00001 /***************************************************************************
00002  *   Copyright (C) 2004-2005 by Daniel Clarke                              *
00003  *   Copyright (C) 2005 by David Saxton                                    *
00004  *   daniel.jc@gmail.com                                                   *
00005  *                                                                         *
00006  *   This program is free software; you can redistribute it and/or modify  *
00007  *   it under the terms of the GNU General Public License as published by  *
00008  *   the Free Software Foundation; either VERSION 2 of the License, or     *
00009  *   (at your option) any later VERSION.                                   *
00010  *                                                                         *
00011  *   This program is distributed in the hope that it will be useful,       *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU General Public License for more details.                          *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU General Public License     *
00017  *   along with this program; if not, write to the                         *
00018  *   Free Software Foundation, Inc.,                                       *
00019  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00020  ***************************************************************************/
00021 
00022 #include "microbe.h"
00023 #include "pic14.h"
00024 #include "config.h"
00025 
00026 #include <kaboutdata.h>
00027 #include <kcmdlineargs.h>
00028 #include <klocale.h>
00029 #include <qfile.h>
00030 
00031 #include <iostream>
00032 #include <fstream>
00033 using namespace std;
00034 
00035 static const char description[] =
00036     I18N_NOOP("The Microbe Compiler");
00037 
00038 static KCmdLineOptions options[] =
00039 {
00040         { "show-source", I18N_NOOP( "Show source code lines in assembly output"),0},
00041         { "nooptimize", I18N_NOOP( "Do not attempt optimization of generated instructions."),0},
00042         { "+[Input URL]", I18N_NOOP( "Input filename" ),0},
00043         { "+[Output URL]", I18N_NOOP( "Output filename" ),0},
00044         KCmdLineLastOption
00045 };
00046 
00047 int main(int argc, char **argv)
00048 {
00049         KAboutData about("microbe", I18N_NOOP("Microbe"), VERSION, description, KAboutData::License_GPL, "(C) 2004-2005, The KTechlab developers", 0, "http://ktechlab.org", "ktechlab-devel@lists.sourceforge.net" );
00050         about.addAuthor( "Daniel Clarke", 0, "daniel.jc@gmail.com" );
00051         about.addAuthor( "David Saxton", 0, "david@bluehaze.org" );
00052     KCmdLineArgs::init(argc, argv, &about);
00053     KCmdLineArgs::addCmdLineOptions( options );
00054         
00055         KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
00056         
00057         if(args->count() == 2 ) {
00058                 Microbe mb;     
00059                 QString s = mb.compile( args->arg(0), args->isSet("show-source"), args->isSet("optimize"));
00060                 QString errorReport = mb.errorReport();
00061                 
00062                 if ( !errorReport.isEmpty() ) {
00063                         cerr << mb.errorReport();
00064                         return 1; // If there was an error, don't write the output to file.
00065                 } else {
00066                         ofstream out(args->arg(1));
00067                         out << s;
00068                         return 0;
00069                 }
00070         } else args->usage();
00071 }
00072 

Generated on Tue May 8 17:05:31 2007 for KTechLab by  doxygen 1.5.1