00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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;
00065 } else {
00066 ofstream out(args->arg(1));
00067 out << s;
00068 return 0;
00069 }
00070 } else args->usage();
00071 }
00072