diff options
Diffstat (limited to 'tiger-compiler/src/parse/tasks.cc')
| -rw-r--r-- | tiger-compiler/src/parse/tasks.cc | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/tiger-compiler/src/parse/tasks.cc b/tiger-compiler/src/parse/tasks.cc new file mode 100644 index 0000000..1423696 --- /dev/null +++ b/tiger-compiler/src/parse/tasks.cc @@ -0,0 +1,53 @@ +/** + ** \file parse/tasks.cc + ** \brief Parse module related tasks' implementation. + **/ + +#include <cstdlib> +#include <iostream> +#include <memory> + +#include <assert/tasks.hh> +#include <ast/tasks.hh> +#include <common.hh> +#include <misc/file-library.hh> +#include <object/tasks.hh> +#include <parse/libparse.hh> +#define DEFINE_TASKS 1 +#include <parse/tasks.hh> +#undef DEFINE_TASKS + +namespace parse::tasks +{ + const char* tc_pkgdatadir = getenv("TC_PKGDATADIR"); + misc::file_library l = + misc::file_library(tc_pkgdatadir ? tc_pkgdatadir : PKGDATADIR); + + void no_prelude() { prelude = ""; } + + void parse() + { + precondition(filename != nullptr); + bool scan_trace = scan_trace_p || getenv("SCAN"); + bool parse_trace = parse_trace_p || getenv("PARSE"); + std::pair<ast::ChunkList*, misc::error> result = + ::parse::parse(prelude, filename, l, scan_trace, parse_trace, + object::tasks::enable_object_extensions_p, + assert::tasks::enable_assert_extensions_p); + + // If the parsing completely failed, stop. + task_error() << result.second; + if (!result.first) + task_error().exit(); + + // FIXME DONE: Some code was deleted here (Set `the_program' to the result of parsing). + ast::tasks::the_program = std::unique_ptr<ast::ChunkList>{result.first}; + } + + void library_display() { std::cout << l << '\n'; } + + void library_append(const std::string& dir) { l.append_dir(dir); } + + void library_prepend(const std::string& dir) { l.prepend_dir(dir); } + +} // namespace parse::tasks |
