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