#include "module.h" namespace MODULE{ void decode_modules(std::vector & modules, std::vector & tokens,std::string filename){ //std::string output_file_name = filename+".evl_output"; //std::ofstream output_file(output_file_name.c_str()); /*if (!output_file) { std::cerr << "I can't write " << filename << ".tokens ." << std::endl; exit(EXIT_FAILURE); } */ int i = 0; while(i < (int)(tokens).size()){ Module* mod; mod = new Module(); if(parse_modules(tokens, &i, mod, INIT)){ modules.push_back(*mod); } else { std::cerr << "Module parsing failed" << std::endl; exit(EXIT_FAILURE); } } for(std::vector::iterator i = modules.begin(); i < modules.end(); i++){ //std::cout << *i; //output_file << *i; } } bool parse_modules(std::vector &tokens, int * i, Module * module, module_fsm_states state ){ //std::cout << *i << " " << state << std::endl; if((tokens)[*i].getData().compare("module")){ return false; } (*i)++; if(!((tokens)[*i].getType() == Token::NAME)){ return false; } module -> name = (tokens)[*i].getData(); (*i)++; if((tokens)[*i].getData().compare(";")){ return false; } (*i)++; while(true){ if(!(tokens)[*i].getData().compare("wire")){ //std::cout << "Wire on Token "<< *i << std::endl; parse_wires(&(module -> wires), NULL, 0, tokens, i, WIRE::INIT); continue; } if(!(tokens)[*i].getData().compare("endmodule")){ (*i)++; return true; } if((tokens)[*i].getType() == Token::NAME){ //std::cout << "Component on Token "<< *i << std::endl; Component* comp; comp = new Component(); //Timer * t = new Timer(); COMPONENT::component_fsm_parser(comp, NULL, tokens, i, COMPONENT::INIT); //delete t; module->add_component(comp); continue; } return false; } } }