Example #1
0
int main(int argc, char** argv) {
    // Create a new empty environment to store the AST and symbols tables, and
    // set the options for compilation.
    argp = new ArgParser(env, argc, argv);
    env->output("doc");
    env->generator("Markdown");

    parse_options();
    File::mkdir(env->output());
    env->workspace_load();

    // Run the compiler.  Output to a temporary file if the compiler will
    // continue on to another stage; otherwise, output the file directly.
    Parser::Ptr parser(new Parser(env));
    SemanticAnalyzer::Ptr semant(new SemanticAnalyzer(env));
    MarkdownGenerator::Ptr md(new MarkdownGenerator(env));

    return 0;
}
Example #2
0
void parse_option(std::string const& flag) {
    if ("output" == flag) {
        env->output(argp->required_arg());
    } else if ("include" == flag) {
        env->include(argp->required_arg());
    } else if ("format" == flag) {
        env->generator(argp->required_arg());
    } else if ("verbose" == flag) {
        env->verbose(true);
    } else {
        argp->bad_option(flag);
    }
}
Example #3
0
int main(int argc, char** argv) {
    // This program recursively finds and builds all files in the source
    // directory, and then generates the output in the lib/bin directory.
    env->workspace_load();
    env->output(".");
    env->make(true);
    env->monolithic_build(false);

    argp = new ArgParser(env, argc, argv);
    load_options(); 
    parse_options();
    save_options();

    Builder::Ptr builder(new Builder(env));
    return builder->errors();
}
Example #4
0
void parse_option(std::string const& flag) {
    // Parses an option and all the corresponding arguments to that option.
    if ("verbose" == flag) {
        env->verbose(true);
    } else if ("optimize" == flag) {
        env->optimize(true);
    } else if ("assembly" == flag) {
        env->assemble(false);
        env->link(false);
    } else if ("compile" == flag) {
        env->link(false);
    } else if ("make" == flag) {
        env->make(true);
    } else if ("debug" == flag) {
        env->debug(true);
    } else if ("dump-ir" == flag) {
        env->dump_ir(true);
    } else if ("dump-ast" == flag) {
        env->dump_ast(true);
    } else if ("dump-lex" == flag) {
        env->dump_lex(true);
    } else if ("dump-liveness" == flag) {
        env->dump_liveness(true);
    } else if ("dump-regalloc" == flag) {
        env->dump_regalloc(true);
    } else if ("dump-reggraph" == flag) {
        env->dump_reggraph(true);
    } else if ("execute" == flag) {
        env->execute(true);
    } else if ("no-default-libs" == flag) {
        env->no_default_libs(true);
        // Debugger flag that prevents default modules from getting
        // loaded automatically by the parser.
    } else if ("include" == flag) {
        env->include(argp->required_arg()); 
    } else if ("output" == flag) {
        env->output(argp->required_arg());
    } else if ("build-dir" == flag) {
        env->build_dir(argp->required_arg());
    } else if ("library" == flag) {
        env->lib(argp->required_arg());
    } else if ("generator" == flag) {
        env->generator(argp->required_arg());
    } else {
        argp->bad_option(flag);
    }
}