int main(int argc, const char *argv[]) { init_tools(); init_values(); init_evaluator(); init_interpreter(); init_tests(); init_sexp_to_c(); // TO TRY: Add an -O3 flag to Xcode's compile. Then compile and profile, and see if it runs faster. // run_tests(); // run_benchmarks(); if (argc > 1) { if (streq(argv[1], "test")) { run_tests(); } else if (streq(argv[1], "benchmark")) { run_benchmarks(); } else { value str = value_set_str(argv[1]); value_import(str); value_clear(&str); } } else { run_interpreter(); } return 0; }
int main(int argc, char **argv) { init_interpreter(); return MLMain(argc, argv); shutdown_interpreter(); }
bool Theme::load(const char *f) { E_RETURN_VAL_IF_FAIL(f != NULL, false); /* do not allow loading if clear() wasn't called before */ E_RETURN_VAL_IF_FAIL(priv->sc == NULL, false); priv->is_loaded = false; init_interpreter(); scheme *ss = priv->sc; /* * Determine from which directory we loads file, and set that file as base directory * where '(include)' statement can search additional files. Include uses 'private::theme.search-path'. */ char *path = edelib_strndup(f, PATH_MAX); if(!path) E_FATAL(E_STRLOC ": No memory\n"); char *dir = local_dirname(path); /* If returned name is the same as file, dirname wasn't found directory name in given path. */ if(strcmp(dir, f) != 0) { pointer sym = mk_symbol(ss, "private:theme.search-path"); edelib_scheme_define(ss, ss->global_env, sym, mk_string(ss, dir)); ss->vptr->setimmutable(sym); } /* scheme copies path, so we do not need it any more */ free(path); FILE *fd = fopen(f, "r"); if(!fd) { edelib_scheme_deinit(ss); free(ss); priv->sc = 0; return false; } edelib_scheme_load_named_file(ss, fd, f); fclose(fd); if(ss->no_memory) { E_WARNING(E_STRLOC ": No memory to load theme source in interpreter\n"); return false; } if(ss->retcode != 0) return false; /* fetch common variables */ priv->name = get_string_var(ss, "private:theme.name"); priv->author = get_string_var(ss, "private:theme.author"); priv->sample = get_string_var(ss, "private:theme.sample"); priv->is_loaded = true; return true; }
int main(int argc, char* argv[]) { init_interpreter(); if (argc == 1) repl_loop(); else if (argc == 2) return interpret_main(argv[1]); else { printf("Takes an argument or no argument"); return 0; } return 0; }
/*================================== * main -- Main routine of LifeLines *================================*/ int main (int argc, char **argv) { extern char *optarg; extern int optind; char * msg; int c; BOOLEAN ok=FALSE; STRING dbrequested=NULL; /* database (path) requested */ STRING dbused=NULL; /* database (path) found */ BOOLEAN forceopen=FALSE, lockchange=FALSE; char lockarg = 0; /* option passed for database lock */ INT alteration=0; LIST exprogs=NULL; TABLE exargs=NULL; STRING progout=NULL; BOOLEAN graphical=TRUE; STRING configfile=0; STRING crashlog=0; int i=0; /* initialize all the low-level library code */ init_stdlib(); #if HAVE_SETLOCALE /* initialize locales */ setlocale(LC_ALL, ""); #endif /* HAVE_SETLOCALE */ /* capture user's default codeset */ ext_codeset = strsave(ll_langinfo()); /* TODO: We can use this info for default conversions */ #if ENABLE_NLS /* setup gettext translation */ ll_bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); #endif save_original_locales(); load_usage(); /* handle conventional arguments --version and --help */ /* needed for help2man to synthesize manual pages */ for (i=1; i<argc; ++i) { if (!strcmp(argv[i], "--version") || !strcmp(argv[i], "-v")) { print_version("llexec"); return 0; } if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h") || !strcmp(argv[i], "-?")) { print_usage(); return 0; } } /* Parse Command-Line Arguments */ opterr = 0; /* turn off getopt's error message */ while ((c = getopt(argc, argv, "adkrwil:fntc:Fu:x:o:zC:I:vh?")) != -1) { switch (c) { case 'c': /* adjust cache sizes */ while(optarg && *optarg) { if(isasciiletter((uchar)*optarg) && isupper((uchar)*optarg)) *optarg = tolower((uchar)*optarg); if(*optarg == 'i') { INT icsz_indi=0; sscanf(optarg+1, "%ld,%ld", &csz_indi, &icsz_indi); } else if(*optarg == 'f') { INT icsz_fam=0; sscanf(optarg+1, "%ld,%ld", &csz_fam, &icsz_fam); } else if(*optarg == 's') { INT icsz_sour=0; sscanf(optarg+1, "%ld,%ld", &csz_sour, &icsz_sour); } else if(*optarg == 'e') { INT icsz_even=0; sscanf(optarg+1, "%ld,%ld", &csz_even, &icsz_even); } else if((*optarg == 'o') || (*optarg == 'x')) { INT icsz_othr=0; sscanf(optarg+1, "%ld,%ld", &csz_othr, &icsz_othr); } optarg++; while(*optarg && isdigit((uchar)*optarg)) optarg++; if(*optarg == ',') optarg++; while(*optarg && isdigit((uchar)*optarg)) optarg++; } break; #ifdef FINNISH # ifdef FINNISHOPTION case 'F': /* Finnish sorting order [toggle] */ opt_finnish = !opt_finnish; /* TO DO - need to mark Finnish databases, as name records are not interoperable, because of different soundex encoding 2001/02/17, Perry Rapp */ break; # endif #endif case 'a': /* debug allocation */ alloclog = TRUE; break; case 'd': /* debug = no signal catchers */ debugmode = TRUE; break; case 'k': /* don't show key values */ keyflag = FALSE; break; case 'r': /* request for read only access */ readonly = TRUE; break; case 'w': /* request for write access */ writeable = TRUE; break; case 'i': /* immutable access */ immutable = TRUE; readonly = TRUE; break; case 'l': /* locking switch */ lockchange = TRUE; lockarg = *optarg; break; case 'f': /* force database open in all cases */ forceopen = TRUE; break; case 'n': /* use non-traditional family rules */ traditional = FALSE; break; case 't': /* show lots of trace statements for debugging */ prog_trace = TRUE; break; case 'x': /* execute program */ if (!exprogs) { exprogs = create_list2(LISTDOFREE); } push_list(exprogs, strdup(optarg ? optarg : "")); break; case 'I': /* program arguments */ { STRING optname=0, optval=0; parse_arg(optarg, &optname, &optval); if (optname && optval) { if (!exargs) { exargs = create_table_str(); } insert_table_str(exargs, optname, optval); } strfree(&optname); strfree(&optval); } break; case 'o': /* output directory */ progout = optarg; break; case 'z': /* nongraphical box */ graphical = FALSE; break; case 'C': /* specify config file */ configfile = optarg; break; case 'v': /* show version */ showversion = TRUE; goto usage; break; case 'h': /* show usage */ case '?': /* show usage */ showversion = TRUE; showusage = TRUE; goto usage; break; } } prompt_for_db: /* catch any fault, so we can close database */ if (debugmode) stdstring_hardfail(); else set_signals(); platform_init(); set_displaykeys(keyflag); /* initialize options & misc. stuff */ llgettext_set_default_localedir(LOCALEDIR); if (!init_lifelines_global(configfile, &msg, &main_db_notify)) { llwprintf("%s", msg); goto finish; } /* setup crashlog in case init_screen fails (eg, bad menu shortcuts) */ crashlog = getlloptstr("CrashLog_llexec", NULL); if (!crashlog) { crashlog = "Crashlog_llexec.log"; } crash_setcrashlog(crashlog); init_interpreter(); /* give interpreter its turn at initialization */ /* Validate Command-Line Arguments */ if ((readonly || immutable) && writeable) { llwprintf(_(qSnorwandro)); goto finish; } if (forceopen && lockchange) { llwprintf(_(qSnofandl)); goto finish; } if (lockchange && lockarg != 'y' && lockarg != 'n') { llwprintf(_(qSbdlkar)); goto finish; } if (forceopen) alteration = 3; else if (lockchange) { if (lockarg == 'y') alteration = 2; else alteration = 1; } c = argc - optind; if (c > 1) { showusage = TRUE; goto usage; } /* Open database, prompting user if necessary */ if (1) { STRING errmsg=0; if (!alldone && c>0) { dbrequested = strsave(argv[optind]); } else { strupdate(&dbrequested, ""); } if (!select_database(dbrequested, alteration, &errmsg)) { if (errmsg) { llwprintf(errmsg); } alldone = 0; goto finish; } } /* Start Program */ if (!init_lifelines_postdb()) { llwprintf(_(qSbaddb)); goto finish; } /* does not use show module */ /* does not use browse module */ if (exargs) { set_cmd_options(exargs); release_table(exargs); exargs = 0; } if (exprogs) { BOOLEAN picklist = FALSE; BOOLEAN timing = FALSE; interp_main(exprogs, progout, picklist, timing); destroy_list(exprogs); } else { /* TODO: prompt for report filename */ } /* does not use show module */ /* does not use browse module */ ok=TRUE; finish: /* we free this not because we care so much about these tiny amounts of memory, but to ensure we have the memory management right */ /* strfree frees memory & nulls pointer */ if (dbused) strfree(&dbused); strfree(&dbrequested); strfree(&readpath_file); shutdown_interpreter(); close_lifelines(); shutdown_ui(!ok); if (alldone == 2) goto prompt_for_db; /* changing databases */ termlocale(); strfree(&ext_codeset); usage: /* Display Version and/or Command-Line Usage Help */ if (showversion) { print_version("llexec"); } if (showusage) puts(usage_summary); /* Exit */ return !ok; }
void Theme::prompt(void) { init_interpreter(); printf("Theme console (edelib %s). Type \"(quit)\" to exit.", EDELIB_VERSION); edelib_scheme_load_file(priv->sc, stdin); }
int main() { init_dicos(); init_pile_table(); init_scan(); A = genForet(); {// imprim foret G0 printf("-------- *********************** ---------\n"); printf("-------- Affichage foret G0 ---------\n"); printf("-------- *********************** ---------\n"); ImprimArbre(A[0]); ImprimArbre(A[1]); ImprimArbre(A[2]); ImprimArbre(A[3]); ImprimArbre(A[4]); } printf("-------- *********************** ---------\nresultat analyse G0 : %d\n", AnalyseG0(A[0])); printf("-------- *********************** ---------\n\n"); {//imprim foret GPL int i; printf("-------- *********************** ---------\n"); printf("-------- Affichage foret GPL ---------\n"); printf("-------- *********************** ---------\n"); for(i=5 ; i<tailleForet ; i++){ ImprimArbre(A[i]); } } init_interpreter(); init_scanGPL(); printf("-------- *********************** ---------\nresultat analyse GPL : %d\n", AnalyseGPL(A[5])); printf("-------- *********************** ---------\n\n"); printf("S = "); //on affiche la valeur de S avec du PCODE /*pcode[c0] = LDV; c0++; pcode[c0] = 0; c0++; pcode[c0] = WRTLN; c0++;*/ pcode[c0] = STOP; c0++; c0=0; exec(); printf("-------- *********************** ---------\n"); printf("-------- Test interpreter :---------\n"); printf("* Somme des N premiers entiers, entrez N *\n"); printf("-------- *********************** ---------\n"); //test interpreter spx = 2;//3 variables //I=0; pcode[0] = LDA; pcode[1] = 0; pcode[2] = LDC; pcode[3] = 0; pcode[4] = AFF; //S=0; pcode[5] = LDA; pcode[6] = 1; pcode[7] = LDC; pcode[8] = 0; pcode[9] = AFF; //N=read(); pcode[10] = LDA; pcode[11] = 2; pcode[12] = RDLN; pcode[13] = AFF; //while(I<=N){ pcode[14] = LDV; pcode[15] = 0; pcode[16] = LDV; pcode[17] = 2; pcode[18] = INFE; pcode[19] = JIF; pcode[20] = 37; //S=S+I; pcode[21] = LDA; pcode[22] = 1; pcode[23] = LDV; pcode[24] = 1; pcode[25] = LDV; pcode[26] = 0; pcode[27] = ADD; pcode[28] = AFF; //I++; pcode[29] = LDA; pcode[30] = 0; pcode[31] = LDV; pcode[32] = 0; pcode[33] = INC; pcode[34] = AFF; //} pcode[35] = JMP; pcode[36] = 14; //writeln(S); pcode[37] = LDV; pcode[38] = 1; pcode[39] = WRTLN; pcode[40] = STOP; c0 = 0; exec(); return 0; }