static void runFromFile(Context *ctx, const char *filename) { FILE *fp = fopen(filename, "r"); if(fp == NULL) { fprintf(stderr, "file open error: %s\n", filename); return; } FileReader fr(fp); compileAndRun(ctx, &fr); fclose(fp); }
/* 此函数仅打开编译执行界面 */ void RunCompile::showCompileAndRun(QString getCompiler, QString getWorkingDir, QStringList getArgs, QString fn) { getConfig(getCompiler, getWorkingDir, getArgs, fn); compileAndRun(); twoLayout->addWidget(compileLable, 0, 0); twoLayout->addWidget(compileToRun, 0, 1); twoLayout->addWidget(clearCompile, 0, 2); twoLayout->addWidget(compileEdit, 1, 0, 1, 3); twoWidget->setLayout(twoLayout); this->setWidget(twoWidget); setWindowTitle(tr("编译并运行")); setMinimumHeight(150); show(); }
static void runInteractive(Context *ctx) { // init readline read_history(HISTFILE); // start while(true) { char *in = readline(">>"); if(in == NULL || strcmp(in, "exit") == 0 || strcmp(in, "quit") == 0) { if(in != NULL) free(in); break; } CharReader r(in); compileAndRun(ctx, &r); if(strlen(in) > 0) { add_history(in); write_history(HISTFILE); } free(in); } }
TEST_F(E2ETest, PrintAlphabet) { EXPECT_EQ( compileAndRun("data/end-to-end/alphabet.xylene"), ProgramResult({0, "abcdefghijklmnopqrstuvwxyz", ""}) ); }
void RunCompile::compilePrograms() { compileAndRun(); }