2011-11-05 22:38:03 +04:00
|
|
|
#include "tests-common.h"
|
|
|
|
#include "openscad.h"
|
|
|
|
#include "module.h"
|
|
|
|
#include "handle_dep.h"
|
2012-05-02 20:07:56 +04:00
|
|
|
#include "boosty.h"
|
2011-11-05 22:38:03 +04:00
|
|
|
|
|
|
|
#include <sstream>
|
2012-05-02 20:07:56 +04:00
|
|
|
#include <fstream>
|
2011-11-05 22:38:03 +04:00
|
|
|
|
2012-02-04 04:43:53 +04:00
|
|
|
Module *parsefile(const char *filename)
|
2011-11-05 22:38:03 +04:00
|
|
|
{
|
2012-02-04 04:43:53 +04:00
|
|
|
Module *root_module = NULL;
|
2011-11-05 22:38:03 +04:00
|
|
|
|
|
|
|
handle_dep(filename);
|
2012-05-02 20:07:56 +04:00
|
|
|
std::ifstream ifs(filename);
|
|
|
|
if (!ifs.is_open()) {
|
2011-11-05 22:38:03 +04:00
|
|
|
fprintf(stderr, "Can't open input file `%s'!\n", filename);
|
2012-05-02 20:07:56 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
std::string text((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
|
|
|
|
text += "\n" + commandline_commands;
|
|
|
|
std::string pathname = boosty::stringy(fs::path(filename).parent_path());
|
|
|
|
root_module = parse(text.c_str(), pathname.c_str(), false);
|
2012-02-04 04:43:53 +04:00
|
|
|
if (root_module) {
|
|
|
|
root_module->handleDependencies();
|
|
|
|
}
|
2011-11-05 22:38:03 +04:00
|
|
|
}
|
|
|
|
return root_module;
|
|
|
|
}
|