49 lines
1.0 KiB
C++
49 lines
1.0 KiB
C++
#pragma once
|
|
|
|
#include <cstddef>
|
|
#include <boost/outcome.hpp>
|
|
|
|
namespace elna
|
|
{
|
|
/**
|
|
* Position in the source text.
|
|
*/
|
|
struct source_position
|
|
{
|
|
/// Line.
|
|
std::size_t line = 1;
|
|
|
|
/// Column.
|
|
std::size_t column = 1;
|
|
};
|
|
|
|
/**
|
|
* A compilation error consists of an error message and position.
|
|
*/
|
|
struct compile_error
|
|
{
|
|
private:
|
|
char const *message;
|
|
source_position position;
|
|
|
|
public:
|
|
/**
|
|
* @param message Error text.
|
|
* @param position Error position in the source text.
|
|
*/
|
|
compile_error(char const *message, const source_position position) noexcept;
|
|
|
|
/// Error text.
|
|
const char *what() const noexcept;
|
|
|
|
/// Error line in the source text.
|
|
std::size_t line() const noexcept;
|
|
|
|
/// Error column in the source text.
|
|
std::size_t column() const noexcept;
|
|
};
|
|
|
|
template<typename T>
|
|
using result = boost::outcome_v2::result<T, compile_error>;
|
|
}
|