Beispiel #1
0
int main(int argc, char **argv)
{

    if (argc < 2)
        exit_error(E_INTERNAL);

    FILE *fp = fopen(argv[1], "r");
    if (fp == NULL)
        exit_error(E_INTERNAL);

    //gcInit();

    lex_init(fp);

    global_init();
    
    expr_init();

    parse();

    fclose(fp);
	
	expr_destroy();
	
    interpret();

    //gcDestroy();

    return 0;
}
Beispiel #2
0
/*
 * blissc_target_set
 *
 * Sets the target tuple string for the compiler.
 */
int
blissc_target_set (blissc_driverctx_t ctx, const char *machspec)
{
    ctx->mach = machine_init(machspec);
    if (ctx->mach == 0) return 0;
    ctx->pctx = parser_init(ctx->strctx, 0, ctx->mach, &ctx->kwdscope, ctx->logctx, ctx->fioctx);
    ctx->ectx = expr_init(ctx->strctx, ctx->pctx, ctx->kwdscope);
    return 1;

} /* blissc_target_set */
Beispiel #3
0
void parse_init(void)
{
    expr_init();
    scanner_init();
    chunkpool_init(s->atom_pool, sizeof(struct atom));
    chunkpool_init(s->vec_pool, sizeof(struct vec));
    map_init(s->sym_table);
    named_buffer_init(s->named_buffer);

    map_init(s->initial_symbols);
    named_buffer_init(s->initial_named_buffer);
}
Beispiel #4
0
expr *expr_parse(char *str)
{
	expr *e;

	expr_init();

	debug_push_line(str);

	tok_begin(str);
	tok_next();

	e = parse();

	if(tok_cur != tok_eof)
		CPP_DIE("'%s' at end of expression", tok_last());

	debug_pop_line();

	return e;
}
Beispiel #5
0
void compile(void)
{
    LEXEME *lex = NULL ;
    SetGlobalFlag(TRUE);
    helpinit();
    errorinit();
    constoptinit();
    declare_init();
    init_init();
    inlineinit();
    lambda_init();
    rtti_init();
    expr_init();
    libcxx_init();
    statement_ini();
    syminit();
    preprocini(infile, inputFile);
    lexini();
    setglbdefs();
    templateInit();
#ifndef PARSER_ONLY
    SSAInit();
    outcodeini();
    conflictini();
    iexpr_init();
    iinlineInit();
    flow_init();
    genstmtini();
#endif
    ParseBuiltins();
    if (chosenAssembler->intrinsicInit)
        chosenAssembler->intrinsicInit();
    if (chosenAssembler->inlineAsmInit)
        chosenAssembler->inlineAsmInit();
    if (chosenAssembler->outcode_init)
        chosenAssembler->outcode_init();
    if (chosenAssembler->enter_filename)
        chosenAssembler->enter_filename(clist->data);
    if (cparams.prm_debug && chosenDebugger && chosenDebugger->init)
        chosenDebugger->init();
    if (cparams.prm_browse && chosenDebugger && chosenDebugger->init_browsedata)
        chosenDebugger->init_browsedata(clist->data);
    browse_init();
    browse_startfile(infile, 0);
    if (cparams.prm_assemble)
    {
        lex = getsym();
        if (lex)
        {
            BLOCKDATA block;
            memset(&block, 0, sizeof(block));
            block.type = begin;
            while ((lex = statement_asm(lex, NULL, &block)) != NULL) ;
#ifndef PARSER_ONLY
            genASM(block.head);
#endif
        }
    }
    else
    {
#ifndef PARSER_ONLY
        asm_header(clist->data, version);
#endif
        lex = getsym();
        if (lex)
        {
            while ((lex = declare(lex, NULL, NULL, sc_global, lk_none, NULL, TRUE, FALSE, FALSE, FALSE, ac_public)) != NULL) ;
        }
    }
#ifdef PARSER_ONLY
    ccDumpSymbols();
#endif
    if (!total_errors)
    {
        dumpInlines();
        dumpInitializers();
        dumpInlines();
        dumpStartups();
#ifndef PARSER_ONLY
        dumpLits();
#endif
/*        rewrite_icode(); */
        if (chosenAssembler->gen->finalGen)
            chosenAssembler->gen->finalGen();
        if (!cparams.prm_assemble && cparams.prm_debug)
            if (chosenDebugger && chosenDebugger->outputtypedef)
                debug_dumptypedefs(globalNameSpace);
#ifndef PARSER_ONLY
        putexterns();
#endif
        if (!cparams.prm_asmfile)
            if (chosenAssembler->output_obj_file)
                chosenAssembler->output_obj_file();
    }
    findUnusedStatics(globalNameSpace);
    dumperrs(stdout);
    if (cparams.prm_debug && chosenDebugger && chosenDebugger->rundown)
        chosenDebugger->rundown();
    if (cparams.prm_browse && chosenDebugger && chosenDebugger->rundown_browsedata)
        chosenDebugger->rundown_browsedata();
#ifndef PARSER_ONLY
    if (!cparams.prm_assemble)
        asm_trailer();
#endif
}