elna/include/elna/cli/cl.hpp

47 lines
1.1 KiB
C++

#pragma once
#include <algorithm>
#include <filesystem>
#include "elna/source/result.hpp"
namespace elna::cli
{
/**
* Reads an input file and returns its contents.
*
* \param source Input file.
*
* \return File contents.
*/
std::string read_source(const char *source);
/**
* Formats and prints the given error.
*
* \param compile_error The error to print.
*/
void print_error(const std::unique_ptr<source::error>& compile_error);
/**
* Prints the given errors to the standard output.
*
* \param begin Pointer to the first error.
* \param end Pointer pass the last error.
*/
template<typename I>
void print_errors(I begin, I end)
{
std::for_each(begin, end, &print_error);
}
/**
* Compiles \a in_file and writes the generated code into \a out_file.
*
* \param in_file Input file.
* \param out_file Output file.
*
* \return Exit status.
*/
int compile(const std::filesystem::path& in_file, const std::filesystem::path& out_file);
}