1 #include <boost/program_options.hpp>
2 #include <boost/foreach.hpp>
6 #include <ozulis/core/assert.hh>
7 #include <ozulis/compiler.hh>
8 #include <ozulis/parse-task.hh>
10 namespace po
= boost::program_options
;
11 using namespace ozulis
;
14 main(int argc
, char **argv
)
16 po::options_description
desc("Help");
18 ("help,h", "produce help message")
19 ("out,o", "specify the output")
20 ("include-path,I", po::value
< std::vector
<std::string
> >(), "include path")
21 ("input-file,i", po::value
< std::vector
<std::string
> >(), "input sources")
22 ("ast-dump", "dump the AST at each pass")
23 ("ast-dump-parse", "dump the AST after the parsing")
24 ("ast-dump-type-check", "dump the AST after the type checking")
25 ("ast-dump-simplify", "dump the AST after the simplification");
27 po::positional_options_description pdesc
;
28 pdesc
.add("input-file", -1);
31 //po::store(po::parse_command_line(argc, argv, desc), vm);
32 po::store(po::command_line_parser(argc
, argv
).
33 options(desc
).positional(pdesc
).run(), vm
);
36 if (vm
.count("help")) {
37 std::cout
<< desc
<< "\n";
41 Compiler
& compiler
= Compiler::instance();
43 #define SET_OPT(Method, Opt) \
46 compiler.Method(true); \
49 /* compiler settings */
50 SET_OPT(enableAstDump
, "ast-dump");
51 SET_OPT(enableAstDumpParse
, "ast-dump-parse");
52 SET_OPT(enableAstDumpTypeCheck
, "ast-dump-type-check");
53 SET_OPT(enableAstDumpSimplify
, "ast-dump-simplify");
56 if (vm
.count("input-file"))
58 BOOST_FOREACH(const std::string
& filename
,
59 vm
["input-file"].as
< std::vector
<std::string
> >())
61 ParseTask
* parseTask
= new ParseTask();
62 parseTask
->filename
= filename
;
63 compiler
.addTask(parseTask
);