예제 #1
0
파일: parser.c 프로젝트: gliptic/dcpu16-drc
void parse(context* C, char const* str) {
	parser P;
	
	P.line = 1;
	P.cur = str;
	P.dest = C->data;
	P.dest_end = C->data + 0x10000;
	
	lex(&P);
	
	r_file(&P);
}
예제 #2
0
int read_in_plists()
{
	//r_file("/usr/local/share/iDeviceActivator/data/latest.plist");
	strcpy(latest_plist, data);

	r_file("/usr/local/share/iDeviceActivator/data/img.plist");
	strcpy(img_plist, data);

	//r_file("/usr/local/share/iDeviceActivator/data/current.plist");
	strcpy(current_plist, data);

	return 0;
}
bool Reaction::filepkg_creation()
{
    string nature_declaration = NATURE_DECLARATION;
    string alias_declaration = ALIAS_DECLARATION;

    string pattern_syst_path = "pattern_files\\" + pattern_pkg_file_name;
    ifstream r_file(pattern_syst_path.c_str(), ios::in);
    string path = "generated_files\\biological_systems_pkg.vhd";

    ofstream w_file(path.c_str(), ios::out | ios::trunc);

    bool res = w_file;

    if(r_file && w_file)
    {
        string line;
        size_t found = string::npos;

        while(r_file)
        {
            getline(r_file, line);

            found = line.find(nature_declaration);
            if(found!=string::npos)
            {
                line.erase(found,nature_declaration.size());
                line.insert(found,nature_declaration_fct());
            }

            found = line.find(alias_declaration);
            if(found!=string::npos)
            {
                line.erase(found,alias_declaration.size());
                line.insert(found,alias_declaration_fct());
            }

            w_file << line << endl;
        }

        w_file.close();
        r_file.close();
    }
    else
    {
        cerr << "Impossible d'ouvrir le fichier !" << endl;
    }

    return res;

}
예제 #4
0
파일: main.cpp 프로젝트: BengtHolm/STLexer
void FileWrite()
{
	ofstream r_file( RECTANGLE_FILE, ios::trunc );
	copy( Rect_List.begin(), Rect_List.end(),
			ostream_iterator<CRectangle>( r_file, "\n" ) );

	ofstream t_file( TRIANGLE_FILE, ios::trunc );
	copy( Tria_List.begin(), Tria_List.end(),
			ostream_iterator<CTriangle>( t_file, "\n" ) );

	ofstream c_file( CIRCLE_FILE, ios::trunc );
	copy( Circ_List.begin(), Circ_List.end(),
			ostream_iterator<CCircle>( c_file, "\n" ) );

	cout << "Files written.\n";
}
예제 #5
0
파일: main.cpp 프로젝트: BengtHolm/STLexer
void FileRead()
{
	ifstream r_file( RECTANGLE_FILE );

	copy( istream_iterator<CRectangle>( r_file ),
				  istream_iterator<CRectangle>(),
					  back_inserter( Rect_List ) );

	ifstream t_file( TRIANGLE_FILE );

	copy( istream_iterator<CTriangle>( t_file ),
			      istream_iterator<CTriangle>(),
					  back_inserter( Tria_List ) );

	ifstream c_file( CIRCLE_FILE );

	copy( istream_iterator<CCircle>( c_file ),
			      istream_iterator<CCircle>(),
					  back_inserter( Circ_List ) );

		cout << "Files read.\n";
}
예제 #6
0
bool Reaction::file_creation()
{

    string entity_code = ENTITY_NAME;
    string port_code = PORT_DECLARATION;
    string equ_code = LOGICAL_EQUATION;


    string pattern_path = "pattern_files\\" + pattern_file_name;
    ifstream r_file(pattern_path.c_str(), ios::in);
    //file_name_user += ".vhd";
    string path = "generated_files\\" + file_name_user + ".vhd";

    ofstream w_file(path.c_str(), ios::out | ios::trunc);

    bool test = r_file;
    bool res = w_file;

    if(r_file && w_file)
    {
        string line;
        size_t found = string::npos;

        while(r_file)
        {
            getline(r_file, line);

            found = line.find(entity_code);
            if(found!=string::npos)
            {
                line.erase(found,entity_code.size());
                line.insert(found,entity_name_user);
            }

            found = line.find(port_code);
            if(found!=string::npos)
            {
                line.erase(found,port_code.size());
                line.insert(found,portmap());
            }


            found = line.find(equ_code);
            if(found!=string::npos)
            {
                line.erase(found,equ_code.size());



                line.insert(found,log_eq());
            }
            w_file << line << endl;
        }

        w_file.close();
        r_file.close();
    }
    else
    {
        cerr << "Impossible d'ouvrir le fichier !" << endl;
    }

    return res;

}
bool Reaction::filereact_creation()
{
    string entity_name = ENTITY_NAME;
    string act_nature = ACT_NATURE;
    string rep_nature = REP_NATURE;
    string arnm_nature = ARNM_NATURE;
    string prot_nature = PROT_NATURE;
    string act_cell = ACT_CELL;
    string rep_cell = REP_CELL;
    string arnm_cell = ARNM_CELL;
    string prot_cell = PROT_CELL;
    string resistor_act_name = RESISTOR_ACT_NAME;
    string resistor_rep_name = RESISTOR_REP_NAME;
    string resistor_arnm_name = RESISTOR_ARNM_NAME;
    string capacitor_arnm_name = CAPACITOR_ARNM_NAME;
    string resistor_prot_name = RESISTOR_PROT_NAME;
    string capacitor_prot_name = CAPACITOR_PROT_NAME;

    string pattern_path = "pattern_files\\" + pattern_react_file_name;
    ifstream r_file(pattern_path.c_str(), ios::in);
    //file_name_user += ".vhd";
    string path = "generated_files\\" + file_name_user + ".vhd";

    ofstream w_file(path.c_str(), ios::out | ios::trunc);

//    bool test = r_file;
    bool res = w_file;

    if(r_file && w_file)
    {
        string line;
        size_t found = string::npos;

        while(r_file)
        {
            getline(r_file, line);

            found = line.find(entity_name);
            if(found!=string::npos)
            {
                line.erase(found,entity_name.size());
                line.insert(found,entity_name_user);
            }

            found = line.find(act_nature);
            if(found!=string::npos)
            {
                line.erase(found,act_nature.size());
                line.insert(found,Act_nature_fct());
            }

            found = line.find(rep_nature);
            if(found!=string::npos)
            {
                line.erase(found,rep_nature.size());
                line.insert(found,Rep_nature_fct());
            }

            found = line.find(arnm_nature);
            if(found!=string::npos)
            {
                line.erase(found,arnm_nature.size());
                line.insert(found,arnm_nature_fct());
            }

            found = line.find(prot_nature);
            if(found!=string::npos)
            {
                line.erase(found,prot_nature.size());
                line.insert(found,out_nature_fct());
            }

            found = line.find(act_cell);
            if(found!=string::npos)
            {
                line.erase(found,act_cell.size());
                line.insert(found,Act_cell_fct());
            }

            found = line.find(rep_cell);
            if(found!=string::npos)
            {
                line.erase(found,rep_cell.size());
                line.insert(found,Rep_cell_fct());
            }

            found = line.find(arnm_cell);
            if(found!=string::npos)
            {
                line.erase(found,arnm_cell.size());
                line.insert(found,arnm_cell_fct());
            }

            found = line.find(prot_cell);
            if(found!=string::npos)
            {
                line.erase(found,prot_cell.size());
                line.insert(found,out_cell_fct());
            }

            found = line.find(resistor_act_name);
            if(found!=string::npos)
            {
                line.erase(found,resistor_act_name.size());
                line.insert(found,Act_resistor_fct());
            }

            found = line.find(resistor_rep_name);
            if(found!=string::npos)
            {
                line.erase(found,resistor_rep_name.size());
                line.insert(found,Rep_resistor_fct());
            }

            found = line.find(resistor_arnm_name);
            if(found!=string::npos)
            {
                line.erase(found,resistor_arnm_name.size());
                line.insert(found,arnm_resistor_fct());
            }

            found = line.find(capacitor_arnm_name);
            if(found!=string::npos)
            {
                line.erase(found,capacitor_arnm_name.size());
                line.insert(found,arnm_capacitor_fct());
            }

            found = line.find(resistor_prot_name);
            if(found!=string::npos)
            {
                line.erase(found,resistor_prot_name.size());
                line.insert(found,out_resistor_fct());
            }

            found = line.find(capacitor_prot_name);
            if(found!=string::npos)
            {
                line.erase(found,capacitor_prot_name.size());
                line.insert(found,out_capacitor_fct());
            }

            w_file << line << endl;
        }

        w_file.close();
        r_file.close();
    }
    else
    {
        cerr << "Impossible d'ouvrir le fichier !" << endl;
    }

    return res;

}