static void init_parser(void) { init_symbols(); init_first(); init_follow(); init_parsing_table(); }
void main_load(char *name, char *path, char *args) { if (!load_inferior (name, path, args)) { console_printf (OUTPUT_SYSTEM, "New process loaded"); init_breakpoints(); console_printf(OUTPUT_SYSTEM, "Interpreting stabs..."); stabs_init(); init_symbols(); if(!stabs_load_module(exec_elfhandle, name)) console_printf(OUTPUT_WARNING, "Failed to load stabs section for %s", name); console_printf(OUTPUT_SYSTEM, "Done!"); if(!modules_lookup_entry(name)) modules_add_entry(name, path, TRUE); enable(TRUE, GAD_START_BUTTON, GAD_KILL_BUTTON, GAD_SETBREAK_BUTTON, GAD_FILENAME_STRING, GAD_HEX_BUTTON, TAG_END); enable(FALSE, GAD_SELECT_BUTTON, GAD_RELOAD_BUTTON, TAG_END); button_set_start(); IIntuition->SetGadgetAttrs((struct Gadget *)MainObj[GAD_FILENAME_STRING], mainwin, NULL, STRINGA_TextVal, name, TAG_DONE); sourcelist_update(); if(db101_prefs.prefs_show_main_at_entry) sourcelist_show_main(); show_source(); } }
void mesh_parser_init(FILE* f, const char* filename) { mesh_lexer_init(f); parser_filename = filename; init_mem(); init_symbols(); }
int main(int argc, char** argv) { // Should ParseCommandLineOptions be able to accept a const argv? llvm::cl::ParseCommandLineOptions(argc, argv, "ploy compiler\n"); const char* file_location = InputFile.c_str(); symbol_table* tbl = sym_tbl = init_symbol_table(); init_symbols(tbl); pointer ret = parse_file_to_tree(file_location, tbl); if(!ret) return 1; materialize_includes(&ret, tbl); ploy_do_compile(ret, tbl); type_map type_define_map; transform_tree_gen_typedef(ret, tbl, &type_define_map); transform_tree_gen_typeinfo(ret, tbl, &type_define_map); compiler* compile = init_compiler(tbl); compiler_compile_expression(compile, ret, EntryFunc.c_str()); compiler_print_module(compile); compiler_write_asm_file(compile, OutputFile.c_str()); destroy_compiler(compile); destroy_symbol_table(tbl); return 0; }
void mesh_parser_init(FILE* f, const char* filename) { mesh_lexer_init(f); H2D_PARSER_FILENAME = filename; init_mem(); init_symbols(); }
static bool parse_symbol_file (void) { init_symbols (); char symbol = '\0', expression [257] = { '\0' }; int value = 0, n = 0; while ( EOF != (n = fscanf (symbols_fp, "%c: %256[A-Z 0-9-+*]\n", &symbol, expression)) ) { init_stack (); expression [256] = '\0'; if ( !( (2 == n) && evaluate_expression (expression) && pop (&value) && set_symbol_value (symbol, value)) ) { return false; } } return true; }
struct symbol_list *sparse_initialize(int argc, char **argv, struct string_list **filelist) { char **args; struct symbol_list *list; // Initialize symbol stream first, so that we can add defines etc init_symbols(); args = argv; for (;;) { char *arg = *++args; if (!arg) break; if (arg[0] == '-' && arg[1]) { args = handle_switch(arg+1, args); continue; } add_ptr_list_notag(filelist, arg); } handle_switch_W_finalize(); handle_switch_v_finalize(); handle_arch_finalize(); list = NULL; if (!ptr_list_empty(filelist)) { // Initialize type system init_ctype(); create_builtin_stream(); add_pre_buffer("#define __CHECKER__ 1\n"); if (!preprocess_only) declare_builtin_functions(); list = sparse_initial(); /* * Protect the initial token allocations, since * they need to survive all the others */ protect_token_alloc(); } return list; }
int compiler_main(int argc, char* argv[]) { init_colors(); init_symbols(syms); po::options_description common("common options"); common.add_options() ("help", "print help message") ("version", "print version message") ("input,i", po::value<String_seq>(), "specify build inputs") ("output,o", po::value<String>(), "specify the build output file") ("keep,k", "keep temporary files"); // FIXME: These really define the compilation mode. // Here are some rules: // // -s implies -c // -c implies no linking // // -b [archive|library|program] // po::options_description compiler("compile options"); compiler.add_options() ("assemble,s", "compile to native assembly") ("compile,c", "compile but do not link") ("target,t", po::value<String>()->default_value("program"), "produce an archive, module, or program"); po::positional_options_description pos; pos.add("input", -1); po::options_description all; all.add(common) .add(compiler); // Parse command line options. Config conf; po::variables_map vm; try { po::store( po::command_line_parser(argc, argv) .options(all) .positional(pos) .run(), vm); po::notify(vm); } catch(std::exception& err) { std::cerr << "error: " << err.what() << "\n\n"; usage(std::cerr, all); return -1; } // Check for obvious flags first. if (vm.count("help")) { usage(std::cout, all); return 0; } if (vm.count ("version")) { // TODO: Generate the version number from the build. std::cout << "beaker v0.0" << '\n'; return 0; } // Check options. if (vm.count("compile")) conf.compile = true; if (vm.count("assemble")) { conf.assemble = true; conf.compile = true; } if (vm.count("target")) { String t = vm["target"].as<String>(); if (t == "program") { conf.target = program_tgt; } else if (t == "module") { conf.target = module_tgt; } else { std::cerr << "error: invalid build target\n"; usage(std::cerr, all); return -1; } } // Validate the input files. if (!vm.count("input")) { std::cerr << "error: no input files given\n"; usage(std::cerr, all); return -1; } Path_seq inputs; for (String const& s : vm["input"].as<String_seq>()) inputs.push_back(s); // Look for an output file. If not given, assume that // the end result is going to be a native binary. Note // that this is the end goal for inputs of any variety. String output; if (!vm.count("output")) { // TODO: This should depend on the compilation mode. output = "a.out"; } else { output = vm["output"].as<String>(); } // Parse all of the input files into the translation module. // // FIXME: We should collect a set of output files from // parsing since we could potentially pass .ll/.bc/.s/.o // files to the next phase of transdlation. // // FIXME: Clean up temporary files. Path ir = to_ir_file(output); if (!parse(inputs, ir, conf)) return -1; Path as = to_asm_file(output); if (!lower(ir, as, conf)) return -1; if (conf.assemble) return 0; Path obj = to_object_file(output); if (!assemble(as, obj, conf)) return -1; if (conf.compile) return 0; // Generate the linked result. if (conf.target == program_tgt) return executable({obj}, output, conf); if (conf.target == module_tgt) return module({obj}, output, conf); return 0; }
int translator_main(int argc, char* argv[]) { // Intitialize various subsystems. // // TODO: Always initialize parsing components? init_colors(); init_symbols(syms); // TODO: Support extraction to other intermediate formats? // Maybe C, for example? Gimple? // // Note that an introspection tool would have a considerably // different interface. po::options_description common("options"); common.add_options() ("help", "print help message") ("version", "print version message") ("input,i", po::value<String>(), "specify the input file") ("output,o", po::value<String>(), "specify the output file") ("keep,k", "keep temporary files"); po::positional_options_description pos; pos.add("input", 1); po::options_description all; all.add(common); // Parse command line options. po::variables_map vm; try { po::store( po::command_line_parser(argc, argv) .options(all) .positional(pos) .run(), vm); po::notify(vm); } catch(std::exception& err) { std::cerr << "error: " << err.what() << "\n\n"; usage(std::cerr, all); return -1; } // Check for obvious flags first. if (vm.count("help")) { usage(std::cout, all); return 0; } if (vm.count ("version")) { // TODO: Generate the version number from the // build. std::cout << "beaker v0.0" << '\n'; return 0; } // Validate the input. if (!vm.count("input")) { std::cerr << "error: no input file given\n"; usage(std::cerr, all); return -1; } Path input = vm["input"].as<String>(); // Look for an output file. If not given, the default // will be to produce .asm. Note that the default output // file is generated in the current directory. Path output; if (!vm.count("output")) output = to_asm_file(input.filename()); else output = vm["output"].as<String>(); // Compile the input into LLVM. Path temp; if (get_file_kind(input) == beaker_file) { temp = to_ir_file(input.filename()); if (!compile(input, temp)) return -1; input = temp; } // Lower llvm input to assembly. if (!lower(input, output)) return -1; // Remove the temporary file. if (!temp.empty() && !vm.count("keep")) fs::remove(temp); return 0; }