int main(int argc,char *argv[]) { /* Get root file from comand line, defaulting to "radix"*/ if (argc>1) root_filename=argv[1]; INITIALIZE_FRAMER(); printf("\n%%%%%%%% Welcome to the FRAMER shell under %s %%%%%%%%\n",OPSYS); read_eval_print(stdin,stdout,NULL,flush_input_on_error); backup_everything(); printf("Exited FRAMER -- see you later"); return 0; }
int main( int argc, char *argv[] ){ int ret = 0; signed char option; int i = 0; int lastopt = 0; bool interactive = false; bool load_libs = true; bool set_a_gc_profile = false; unsigned new_gc_profile = 0; stack_frame_t *global_frame; if ( argc < 2 ){ // By default, go into an REPL interactive = true; } else { // otherwise parse options lastopt = 1; for ( i = 1; i < argc && argv[i][0] == '-'; i++ ){ option = argv[i][1]; switch ( option ){ case 'i': interactive = true; break; case 'h': print_help( ); exit( 0 ); break; case 'L': load_libs = false; break; case 'g': { char *profile = argv[++i]; set_a_gc_profile = true; if ( strcmp( profile, "fast" ) == 0 ){ new_gc_profile = GC_PROFILE_FAST; } else if ( strcmp( profile, "balanced" ) == 0 ){ new_gc_profile = GC_PROFILE_BALANCED; } else if ( strcmp( profile, "lowmem" ) == 0 ){ new_gc_profile = GC_PROFILE_LOWMEM; } else { printf( "Unknown garbage collector profile \"%s\", " "using \"balanced\" instead...\n", profile ); new_gc_profile = GC_PROFILE_BALANCED; } } case 'v': break; default: print_help( ); exit( 1 ); break; } /* This keeps track of where the argument after the current argument is, in order to find the filenames after option parsing is done. */ lastopt = i + 1; } } // print some info about the interpreter going into a REPL if ( interactive ){ printf( "%s\n", GOJIRA_BUILD_NAME ); } // Initialize the global interpreter state global_frame = frame_create( NULL, NULL, MAKE_ENV ); init_global_frame( global_frame ); if ( set_a_gc_profile ){ gc_set_profile( get_current_gc( global_frame ), new_gc_profile ); } // Load the 'base' library for needed primatives if ( load_libs ){ evaluate_file( global_frame, BASE_LIB ); } make_argument_var( global_frame, lastopt, argc, argv ); if ( lastopt ){ evaluate_file( global_frame, argv[lastopt] ); } // Go into the REPL if the interpreter flag is set if ( interactive ){ read_eval_print( global_frame ); } // Clean up the global frame, and free all tokens left in the token cache gc_collect( get_current_gc( global_frame )); destroy_token_cache( ); return ret; }