示例#1
0
文件: main.cpp 项目: KDE/discover
int main(int argc, char** argv)
{
    QApplication app(argc, argv);
    app.setWindowIcon(QIcon::fromTheme(QStringLiteral("plasmadiscover")));
    app.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
    app.setAttribute(Qt::AA_UseHighDpiPixmaps, true);
    KCrash::initialize();
    KLocalizedString::setApplicationDomain("plasma-discover");
    KAboutData about(QStringLiteral("discover"), i18n("Discover"), version, i18n("An application explorer"),
                     KAboutLicense::GPL, i18n("© 2010-2016 Plasma Development Team"));
    about.addAuthor(i18n("Aleix Pol Gonzalez"), QString(), QStringLiteral("*****@*****.**"));
    about.addAuthor(i18n("Jonathan Thomas"), QString(), QStringLiteral("*****@*****.**"));
    about.setProductName("discover/discover");
    KAboutData::setApplicationData(about);

    DiscoverMainWindow *mainWindow = nullptr;
    {
        QScopedPointer<QCommandLineParser> parser(createParser());
        parser->process(app);
        about.processCommandLine(parser.data());
        DiscoverBackendsFactory::processCommandLine(parser.data(), parser->isSet(QStringLiteral("test")));

        if (parser->isSet(QStringLiteral("test"))) {
            QStandardPaths::setTestModeEnabled(true);
        }

        KDBusService* service = new KDBusService(KDBusService::Unique, &app);

        mainWindow = new DiscoverMainWindow(s_decodeCompactMode->value(parser->value(QStringLiteral("compact")), DiscoverMainWindow::Full));
        QObject::connect(&app, &QCoreApplication::aboutToQuit, mainWindow, &DiscoverMainWindow::deleteLater);
        QObject::connect(service, &KDBusService::activateRequested, mainWindow, [mainWindow](const QStringList &arguments, const QString &/*workingDirectory*/){
            mainWindow->rootObject()->raise();
            if (arguments.isEmpty())
                return;
            QScopedPointer<QCommandLineParser> parser(createParser());
            parser->process(arguments);
            processArgs(parser.data(), mainWindow);
        });

        processArgs(parser.data(), mainWindow);

        if(parser->isSet(QStringLiteral("listmodes"))) {
            QTextStream(stdout) << i18n("Available modes:\n");
            foreach(const QString& mode, mainWindow->modes())
                QTextStream(stdout) << " * " << mode << '\n';
            return 0;
        }

        if (parser->isSet(QStringLiteral("test"))) {
            const QUrl testFile = QUrl::fromUserInput(parser->value(QStringLiteral("test")), {}, QUrl::AssumeLocalFile);
            Q_ASSERT(!testFile.isEmpty() && testFile.isLocalFile());

            mainWindow->loadTest(testFile);
        }
    }
示例#2
0
文件: compiler.c 项目: 8l/ark-c
void startCompiler(Compiler *self) {
	if (!self->sourceFiles || self->sourceFiles->size == 0) {
		printf("not running \n");
		return;
	}

	// lex file
	verboseModeMessage("Started lexing");
	self->lexer = createLexer(self->sourceFiles);
	startLexingFiles(self->lexer, self->sourceFiles);
	if (self->lexer->failed) {
		return;
	}
	verboseModeMessage("Finished lexing");

	// initialise parser after we tokenize
	verboseModeMessage("Started parsing");
	self->parser = createParser();
	startParsingSourceFiles(self->parser, self->sourceFiles);
	verboseModeMessage("Finished parsing");
	
	// failed parsing stage
	if (self->parser->failed) {
		return; // don't do stuff after this
	}

	self->semantic = createSemanticAnalyzer(self->sourceFiles);
	startSemanticAnalysis(self->semantic);
	if (self->semantic->failed) {
		return;
	}

	self->generatorLLVM = createLLVMCodeGenerator(self->sourceFiles);
	startLLVMCodeGeneration(self->generatorLLVM);
}
示例#3
0
int main(){
	initialize_All();
	checkParserData();
	createParser();
	showParser();
	parse();
	freeMemory();
	return 0;
}
示例#4
0
//-----------------------------------------------------------------------------
//
void WaypointGeo::parse( const char* filename )
{
    // create the parser
    PsrParser *parser = createParser( filename );

    // now parse the file
    readFile(parser);

    // cleanup
    delete parser;
}
示例#5
0
void Predicate::readBeginImpl()
{
    if (!m_pythonMethod)
    {
        createParser();
    }

    m_numPointsProcessed = m_numPointsPassed = 0;

    pdal::GlobalEnvironment::get().getPythonEnvironment().set_stdout(m_predicateFilter.log()->getLogStream());

    return;
}
示例#6
0
IrcClient::IrcClient(QWidget* parent) : QSplitter(parent)
{
    createParser();
    createConnection();
    createCompleter();
    createUserList();
    createLayout();
    createBufferList();

    // queue a command to automatically join the channel when connected
    connection->sendCommand(IrcCommand::createJoin(CHANNEL));
    connection->open();

    textEdit->append(IrcMessageFormatter::formatMessage(tr("! Welcome to the Communi %1 example client.").arg(IRC_VERSION_STR)));
    textEdit->append(IrcMessageFormatter::formatMessage(tr("! This example connects %1 and joins %2.").arg(SERVER, CHANNEL)));
    textEdit->append(IrcMessageFormatter::formatMessage(tr("! PS. Available commands: JOIN, ME, NICK, PART")));
}
示例#7
0
//----------------------------------------------------------------------------//
void System::setupXMLParser()
{
    // handle creation / initialisation of XMLParser
    if (!d_xmlParser)
    {
#ifndef CEGUI_STATIC
        setXMLParser(d_defaultXMLParserName);
#else
        //Static Linking Call
        d_xmlParser = createParser();
        // make sure we know to cleanup afterwards.
        d_ourXmlParser = true;
#endif
    }
    // parser object already set, just initialise it.
    else
        d_xmlParser->initialise();
}
示例#8
0
void* XmlBinder::initialize(int size) {

	void* buffer = NULL;

	if (!createParser()) {
		THROW(XmlParsingException, EXCEP_MSSG(PARSER_CREATION_ERROR));
    }
    
	if (size > 0)
		buffer = getBuffer(size);

	enableHandlers(
		EnableElementHandlers|
		EnableCharacterDataHandler|
		EnableCdataSectionHandlers );

	return buffer;
}
bool EnvironmentMgr::loadSchema(const std::string &configPath, const std::string &masterConfigFile, const std::vector<std::string> &cfgParms)
{
    bool rc = false;
    if (createParser())
    {
        rc = m_pSchemaParser->parse(configPath, masterConfigFile, cfgParms);
        if (rc)
        {
            // unique attribure value sets are global across a schema. Allocate one here and pass it in
            // for use in building the necessary references and dependencies across the schema, then pass
            // it to the post processing for finalization. Once referencs and dependencies are built, the
            // attribute value sets are no longer needed.
            std::map<std::string, std::vector<std::shared_ptr<SchemaValue>>> uniqueAttributeValueSets;
            m_pSchema->processDefinedUniqueAttributeValueSets(uniqueAttributeValueSets);  // This must be done first
            m_pSchema->postProcessConfig(uniqueAttributeValueSets);
        }
    }
    return rc;
}
示例#10
0
// native SMCParser:SMC_CreateParser();
static cell AMX_NATIVE_CALL SMC_CreateParser(AMX *amx, cell *params)
{
	return createParser();
}
示例#11
0
文件: parser.cpp 项目: humem/cabocha
Parser *Parser::create(const char *arg) {
  return createParser(arg);
}
示例#12
0
文件: parser.cpp 项目: humem/cabocha
Parser *Parser::create(int argc, char **argv) {
  return createParser(argc, argv);
}
int main( int argc, char** argv ) {
   uint32 format = MAX_UINT32;
   uint32 port = 0;
   PropertyHelper::PropertyInit propInit;

   auto_ptr<CommandlineOptionHandler>
      coh( new CommandlineOptionHandler( argc, argv ) );
   coh->setSummary( "The TrafficServer has a listening socket that "
                   "accepts traffic information files. Each received "
                   "file will be processed and the resulting traffic "
                   "situations sent to the InfoModule.\n\n"
                   "Optionally it can be run with one or more files "
                   "specified on the commandline. Each file will be "
                   "read and processed in turn. When all files have "
                   "been processed, the TrafficServer will exit. " );

   coh->addOption( "-n", "--TrafficServerPort",
                  CommandlineOptionHandler::uint32Val,
                  1, &port, "0",
                  "Sets the preferred TrafficServerPort.");

   typedef pair< MC2String, MC2String > OptionPair;
   const OptionPair options[] = {
      make_pair( "--datexii_as",  "Vägverket DatexII Accident Service" ),
      make_pair( "--datexii_eis", "Vägverket DatexII Emergency Info Service" ),
      make_pair( "--datexii_rws", "Vägverket DatexII Road Work Service" ),
      make_pair( "--datexii_tmx", "Vägverket DatexII Traffic Message Service" )
   };

   coh->addSingleChoiceOption( "-f", 
                              options,
                              options + sizeof (options) / sizeof (*options),
                              &format, MAX_UINT32,
                              "Sets the type of data to read." );
   coh->setTailHelp("[files]");
   if ( ! coh->parse() ) {
      mc2log << error << "TrafficServer: Error on commandline (-h for help)"
             << endl;
      return 2;
   }

   if ( ! Properties::setPropertyFileName( coh->getPropertyFileName() ) ) {
      mc2log << error << "TrafficServer: No such file or directory: '"
             << coh->getPropertyFileName() << "'" << endl;
      return 3;
   }


   // Initialize the XML system
   XMLTool::XMLInit xmlInit;
   SSLCleaner sslInit;
   ISABThreadInitialize threadInit;

   TrafficParser* parser = createParser( format );

   if ( parser == NULL ) {
      mc2log << error << "Invalid parser choice!" << endl;
      return 4;
   }

   TrafficFeed* feed = NULL;

   TrafficServerComponent trafficServer( coh.get() );

   if ( port != 0 ) {
      feed = new TCPTrafficFeed( port,
                                 trafficServer.getShutdownPipe() );
   } else {

      vector<MC2String> files;
      for ( uint32 i = 0; i < coh->getTailLength(); ++i ) {
         files.push_back( coh->getTail( i ) );
      }

      feed = new FileTrafficFeed( files );
   }
   coh.release();

   ISABThreadHandle workThread =
      new TrafficThread( parser->getProvider(),
                         parser, feed,
                         trafficServer.getShutdownPipe() );

   trafficServer.setWorkThread( workThread );
   trafficServer.init();
   trafficServer.gotoWork( threadInit );

   return 0;
}
示例#14
0
/**
 * Create a compiler object for a given language.
 * @param name name of the language handled by the compiler
 * @return compiler object pointer
 */
cdk::Compiler *pipoca::CompilerFactory::createCompiler(const char *name) {
  cdk::syntax::Parser *parser = createParser(name);
  return new cdk::Compiler(name, parser);
}
示例#15
0
XmlDomDocument::XmlDomDocument(const char* xmlfile) : m_doc(NULL)
{
    createParser();
    parser->parse(xmlfile);
    m_doc = parser->adoptDocument();
}
示例#16
0
int main( int argc, char** argv ) {
    CommandlineOptionHandler coh( argc, argv );
    typedef pair< MC2String, MC2String > OptionPair;

    uint32 format = MAX_UINT32;

    const OptionPair options[] = {
        make_pair( "--datexii_as", "Vägverket DatexII Accident Service" ),
        make_pair( "--datexii_eis", "Vägverket DatexII Emergency Info Service" ),
        make_pair( "--datexii_rws", "Vägverket DatexII Road Work Service" ),
        make_pair( "--datexii_tmx", "Vägverket DatexII Traffic Message Service" ),
    };

    coh.addSingleChoiceOption( "-f",
                               options,
                               options + sizeof (options) / sizeof (*options),
                               &format, MAX_UINT32,
                               "Sets the type of data to read." );

    coh.setTailHelp("[files]");

    if ( ! coh.parse() ) {
        mc2log << error << "Failed to parse command line!" << endl;
        return 1;
    }

    if ( ! Properties::setPropertyFileName( coh.getPropertyFileName() ) ) {
        mc2log << error << "TrafficServer: No such file or directory: '"
               << coh.getPropertyFileName() << "'" << endl;
        return 2;
    }

    // Initialize the XML system
    XMLTool::XMLInit xmlInit;

    vector<MC2String> files;
    for ( uint32 i = 0; i < coh.getTailLength(); ++i ) {
        files.push_back( coh.getTail( i ) );
    }


    FileTrafficFeed feed( files );
    // we need files!
    if ( feed.eos() ) {
        mc2log << error << "No feed!" << endl;
        return 3;
    }

    auto_ptr<TrafficParser> parser( createParser( format ) );

    if ( ! parser.get() ) {
        mc2log << error << "Failed to create parser" << endl;
        return 4;
    }

    while ( ! feed.eos() ) {

        // get data and parse situations

        TrafficFeed::Data data;
        if ( ! feed.getData( data ) ) {
            mc2log << error << "Failed to get feed." << endl;
            break;
        }

        TrafficParser::Situations situations;
        if ( ! parser->parse( data, situations ) ) {
            mc2log << error << "Failed to parse feed." << endl;
            return 5;
        }

        if ( situations.empty() ) {
            mc2log << error << "No situations parsed from feed." << endl;
            return 6;
        }

        mc2log << "Situations parsed: " << situations.size() << endl;

        STLUtility::deleteValues( situations );
    }

    return 0;
}