Пример #1
0
void output(void)
{
    const_array = jflag ? "private final static " : "";
    free_itemsets();
    free_shifts();
    free_reductions();
    output_prefix();
    output_stored_text();
    output_defines();
    output_rule_data();
    output_yydefred();
    output_actions();
    free_parser();
    output_debug();
    if (!jflag) {
	output_stype();
	if (rflag) write_section(tables);
	write_section(header);
	output_trailing_text();
    }
    write_section(jflag ? jbody : body);
    output_semantic_actions();
    write_section(jflag ? jtrailer : trailer);
    if (jflag)
	output_trailing_text();
}
Пример #2
0
void Logger::vlog(const Logger::LEVEL level, const char *format, va_list args)
{
  if (level >= level_) {
    char buf[128];
#ifdef _MSC_VER
	vsnprintf_s(buf, sizeof buf, format, args);
#else
    vsnprintf(buf, sizeof buf, format, args);
#endif
    output_prefix(os_, level);
    os_ << buf << std::endl;
  }
}
Пример #3
0
output()
{
    free_itemsets();
    free_shifts();
    free_reductions();
    output_prefix();
    output_stored_text();
    output_defines();
    output_rule_data();
    output_yydefred();
    output_actions();
    free_parser();
    output_debug();
    output_stype();
    if (rflag) write_section(tables);
    write_section(header);
    output_trailing_text();
    write_section(body);
    output_semantic_actions();
    write_section(trailer);
}
void level_converter::generate_level_header_file()
{
    fstream header_file( output_prefix() + string(".hpp"), ios_base::out );

    header_file << "#ifndef " << output_basename << "_hpp\n"
                << "#define " << output_basename << "_hpp\n\n\n"
                << "#include \"../game_engine_stuff/level_stuff/"
                << "level_class.hpp\"\n"
                << "#include \"../game_engine_stuff/level_stuff/"
                << "sprite_level_data_stuff.hpp\"\n";

    header_file << "\n\n";

    for ( tiled_sublevel& the_tiled_sublevel : tiled_sublevel_vec )
    {
        header_file << "// " << the_tiled_sublevel.sublevel_file_name
                    << "\n";

        header_file << "extern const sublevel< "
                    << the_tiled_sublevel.the_sublevel.compressed_block_data_vec
                    .size() << ", "
                    << the_tiled_sublevel.the_sublevel.real_size_2d.x << ", "
                    << the_tiled_sublevel.the_sublevel.real_size_2d.y << ", "
                    << the_tiled_sublevel.the_sublevel.sprite_ipg_vec.size() << ", "
                    << the_tiled_sublevel.the_sublevel.sublevel_entrance_vec.size()
                    << " > " << output_basename << "_"
                    << the_tiled_sublevel.output_basename << ";\n\n";

    }


    header_file << "\nextern const level " << output_basename << ";\n";

    header_file << "\n\n";

    header_file << "#endif\t\t// " << output_basename << "_hpp";


}
Пример #5
0
void
output(void)
{
    FILE *fp;

    free_itemsets();
    free_shifts();
    free_reductions();

    if (iflag)
    {
	++outline;
	fprintf(code_file, "#include \"%s\"\n", externs_file_name);
	fp = externs_file;
    }
    else
	fp = code_file;

    output_prefix(iflag ? externs_file : output_file);
    output_pure_parser(fp);
    output_stored_text(fp);
    output_stype(fp);
    output_parse_decl(fp);
    output_lex_decl(fp);
    output_error_decl(fp);
    write_section(fp, xdecls);

    if (iflag)
    {
	output_externs(externs_file, global_vars);
	if (!pure_parser)
	    output_externs(externs_file, impure_vars);
    }

    if (iflag)
    {
	++outline;
	fprintf(code_file, "#include \"%s\"\n", defines_file_name);
	if (!dflag)
	    output_defines(externs_file);
    }
    else
    {
	putc_code(code_file, '\n');
	output_defines(code_file);
    }

    if (dflag)
	output_defines(defines_file);

    output_rule_data();
    output_yydefred();
    output_actions();
    free_parser();
    output_debug();
    if (rflag)
    {
	output_prefix(code_file);
	write_section(code_file, xdecls);
	write_section(code_file, tables);
    }
    write_section(code_file, global_vars);
    if (!pure_parser)
    {
	write_section(code_file, impure_vars);
    }
    write_section(code_file, hdr_defs);
    if (!pure_parser)
    {
	write_section(code_file, hdr_vars);
    }
    output_trailing_text();
    write_section(code_file, body_1);
    if (pure_parser)
    {
	write_section(code_file, body_vars);
    }
    write_section(code_file, body_2);
    output_yyerror_call("syntax error");
    write_section(code_file, body_3);
    output_semantic_actions();
    write_section(code_file, trailer);
    output_yyerror_call("yacc stack overflow");
    write_section(code_file, trailer_2);
}
void level_converter::generate_level_cpp_file()
{
    fstream cpp_file( output_prefix() + string(".thumb.cpp"),
                      ios_base::out );

    cpp_file << "#include \"" << output_basename << ".hpp\"\n\n\n";

    //for ( tiled_sublevel& the_tiled_sublevel : tiled_sublevel_vec )
    for ( u32 i=0; i<tiled_sublevel_vec.size(); ++i )
    {
        tiled_sublevel& the_tiled_sublevel = tiled_sublevel_vec[i];

        cpp_file << "// " << the_tiled_sublevel.sublevel_file_name << "\n";

        cpp_file << "const sublevel< "
                 << the_tiled_sublevel.the_sublevel.compressed_block_data_vec
                 .size() << ", "
                 << the_tiled_sublevel.the_sublevel.real_size_2d.x << ", "
                 << the_tiled_sublevel.the_sublevel.real_size_2d.y << ", "
                 << the_tiled_sublevel.the_sublevel.sprite_ipg_vec.size() << ", "
                 << the_tiled_sublevel.the_sublevel.sublevel_entrance_vec.size()
                 << " > " << output_basename << "_"
                 << the_tiled_sublevel.output_basename << "\n" << "= {\n";


        // Build the array of compressed block data
        cpp_file << "\t{\n";

        u32 counter = 0;

        for ( u32& the_u32
                : the_tiled_sublevel.the_sublevel.compressed_block_data_vec )
        {
            ////cpp_file << hex << "\t\t0x" << *iter << dec << ",\n";
            //cpp_file << hex << "\t\t0x" << the_u32 << dec << ",\n";
            if ( counter % 4 == 0 )
            {
                cpp_file << "\t\t";
            }

            //cpp_file << hex << "0x" << *iter << dec;
            cpp_file << hex << "0x" << the_u32 << dec;

            if ( counter % 4 == 3 )
            {
                cpp_file << ",\n";
            }
            else
            {
                cpp_file << ", ";
            }

            ++counter;
        }

        if ( counter % 4 != 0 )
        {
            cpp_file << "\n";
        }
        cpp_file << "\t},\n\t\n";


        // Build the array of sprite_init_param_group's
        cpp_file << "\t{\n";

        for ( sprite_init_param_group& sprite_ipg
                : the_tiled_sublevel.the_sublevel.sprite_ipg_vec )
        {
            cpp_file << "\t\t{ ";

            if ( sprite_ipg.type < sprite_type_helper::st_name_vec.size() )
            {
                cpp_file << sprite_type_helper::get_st_name
                         (sprite_ipg.type);
            }
            else
            {
                // Print out a number if the_sprite_type doesn't have a
                // corresponding string in sprite_type_helper::st_name_vec.
                cpp_file << sprite_ipg.type;
            }

            cpp_file << ", " << sprite_ipg.initial_block_grid_x_coord
                     << ", " << sprite_ipg.initial_block_grid_y_coord << ", "
                     << ( sprite_ipg.facing_right ? "true" : "false" );


            // This had to be changed to make the Sherwin's Adventure code
            // compile with the OUTDATED version of arm-none-eabi- prefixed
            // GCC and Binutils that are included in devkitARM
            //// Don't clutter the sprite_init_param_group's that have only
            //// zeroes as extra parameters.
            //if ( !( sprite_ipg.extra_param_0 == 0
            //	&& sprite_ipg.extra_param_1 == 0
            //	&& sprite_ipg.extra_param_2 == 0
            //	&& sprite_ipg.extra_param_3 == 0 ) )
            //{
            //	cpp_file << ", " << sprite_ipg.extra_param_0 << ", "
            //		<< sprite_ipg.extra_param_1 << ", "
            //		<< sprite_ipg.extra_param_2 << ", "
            //		<< sprite_ipg.extra_param_3;
            //}

            //cpp_file << ", " << sprite_ipg.extra_param_0 << ", "
            //	<< sprite_ipg.extra_param_1 << ", "
            //	<< sprite_ipg.extra_param_2 << ", "
            //	<< sprite_ipg.extra_param_3;

            if ( sprite_ipg.type >= sprite_type_helper::lowest_warp_id_st
                    && sprite_ipg.type
                    <= sprite_type_helper::highest_warp_id_st )
            {
                cpp_file << ", " << sprite_ipg.extra_param_0 << ", ";

                //if ( sprite_ipg
                //	<< sprite_ipg.extra_param_1 << ", ";
                if ( sprite_ipg.extra_param_1 == (u32)-1 )
                {
                    //cout << "Found a sprite_init_param_group with -1 for "
                    //	<< "its extra_param_1!\n";
                    cpp_file << i;
                }
                else
                {
                    cpp_file << sprite_ipg.extra_param_1;
                }


                cpp_file << ", " << sprite_ipg.extra_param_2 << ", "
                         << sprite_ipg.extra_param_3;
            }
            else
            {
                cpp_file << ", " << sprite_ipg.extra_param_0 << ", "
                         << sprite_ipg.extra_param_1 << ", "
                         << sprite_ipg.extra_param_2 << ", "
                         << sprite_ipg.extra_param_3;
            }

            cpp_file << " },\n";
        }

        cpp_file << "\t},\n\t\n";

        // Build the array of sublevel_entrance's
        cpp_file << "\t{\n";

        for ( sublevel_entrance& the_sle
                : the_tiled_sublevel.the_sublevel.sublevel_entrance_vec )
        {
            cpp_file << "\t\t{ " << get_sle_name_debug(the_sle.type)
                     << hex << ", vec2_f24p8( {0x"
                     << the_sle.in_sublevel_pos.x.data << "}, {0x"
                     << the_sle.in_sublevel_pos.y.data << "} ) },\n" << dec;
        }

        cpp_file << "\t},\n";


        cpp_file << "};\n\n\n";
    }


    cpp_file << "const level " << output_basename << " = level\n\t"
             << "( sublevel_pointer(" << output_basename << "_"
             << tiled_sublevel_vec[0].output_basename << ")";

    if ( tiled_sublevel_vec.size() == 1 )
    {
        cpp_file << " );\n";
    }
    else
    {
        cpp_file << ",\n";

        //for ( tiled_sublevel& the_tiled_sublevel : tiled_sublevel_vec )
        for ( size_t i=1; i<tiled_sublevel_vec.size(); ++i )
        {
            cpp_file << "\tsublevel_pointer(" << output_basename << "_"
                     << tiled_sublevel_vec[i].output_basename << ")";

            if ( i == tiled_sublevel_vec.size() - 1 )
            {
                cpp_file << " );";
            }
            else
            {
                cpp_file << ",";
            }

            cpp_file << "\n";
        }
    }

    cpp_file << "\n\n\n";


}