File indexing completed on 2024-12-01 05:12:31
0001 /*************************************************************************** 0002 * Copyright (C) 2004-2005 by Daniel Clarke * 0003 * Copyright (C) 2005 by David Saxton * 0004 * daniel.jc@gmail.com * 0005 * * 0006 * 24-04-2007 * 0007 * Modified to add pic 16f877,16f627 and 16f628 * 0008 * by george john george@space-kerala.org,az.j.george@gmail.com * 0009 * supported by SPACE www.space-kerala.org * 0010 * * 0011 * This program is free software; you can redistribute it and/or modify * 0012 * it under the terms of the GNU General Public License as published by * 0013 * the Free Software Foundation; either version 2 of the License, or * 0014 * (at your option) any later version. * 0015 * * 0016 * This program is distributed in the hope that it will be useful, * 0017 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0019 * GNU General Public License for more details. * 0020 * * 0021 * You should have received a copy of the GNU General Public License * 0022 * along with this program; if not, write to the * 0023 * Free Software Foundation, Inc., * 0024 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 0025 ***************************************************************************/ 0026 0027 #include "microbe.h" 0028 #include "pic14.h" 0029 0030 #include <KAboutData> 0031 #include <KLocalizedString> 0032 0033 #include <QCoreApplication> 0034 #include <QCommandLineParser> 0035 0036 #include <iostream> 0037 #include <fstream> 0038 using namespace std; 0039 0040 int main(int argc, char **argv) 0041 { 0042 QCoreApplication app(argc, argv); 0043 KLocalizedString::setApplicationDomain("ktechlab"); // sharing strings with ktechlab 0044 0045 KAboutData aboutData("microbe", 0046 i18n("Microbe"), 0047 QStringLiteral("0.3"), 0048 i18n("The Microbe Compiler"), 0049 KAboutLicense::GPL_V2, 0050 i18n("(C) 2004-2005, The KTechlab developers"), 0051 QString(), 0052 QStringLiteral("https://userbase.kde.org/KTechlab")); 0053 aboutData.addAuthor(i18n("Daniel Clarke"), QString(), QStringLiteral("daniel.jc@gmail.com")); 0054 aboutData.addAuthor(i18n("David Saxton"), QString(), QStringLiteral("david@bluehaze.org")); 0055 aboutData.addAuthor(i18n("George John"), i18n("Added pic 16f877,16f627 and 16f628"), QStringLiteral("az.j.george@gmail.com")); 0056 0057 KAboutData::setApplicationData(aboutData); 0058 0059 QCommandLineParser parser; 0060 aboutData.setupCommandLine(&parser); 0061 0062 QCommandLineOption showSourceOption(QStringLiteral("show-source"), i18n( "Show source code lines in assembly output")); 0063 parser.addOption(showSourceOption); 0064 QCommandLineOption noOptimizeOption(QStringLiteral("no-optimize"), i18n( "Do not attempt optimization of generated instructions.")); 0065 parser.addOption(noOptimizeOption); 0066 parser.addPositionalArgument( QStringLiteral("Input URL"), i18n( "Input filename" )); 0067 parser.addPositionalArgument( QStringLiteral("Output URL"), i18n( "Output filename" )); 0068 0069 parser.process(app); 0070 aboutData.processCommandLine(&parser); 0071 0072 const QStringList positionArguments = parser.positionalArguments(); 0073 if (positionArguments.count() == 2 ) 0074 { 0075 MicrobeApp mb; 0076 // QString s = mb.compile( positionArguments[0], parser.isSet(showSourceOption), !parser.isSet(noOptimizeOption)); 0077 0078 QString s = mb.compile( positionArguments[0], !parser.isSet(noOptimizeOption)); 0079 0080 QString errorReport = mb.errorReport(); 0081 0082 if ( !errorReport.isEmpty() ) 0083 { 0084 cerr << mb.errorReport().toStdString(); 0085 return 1; // If there was an error, don't write the output to file. 0086 } 0087 0088 else 0089 { 0090 ofstream out(positionArguments[1].toStdString().c_str()); 0091 out << s.toStdString(); 0092 return 0; 0093 } 0094 } 0095 else parser.showHelp(); 0096 } 0097