elna/source/driver.cc

45 lines
1.2 KiB
C++
Raw Permalink Normal View History

2024-12-27 10:51:46 +01:00
// This Source Code Form is subject to the terms of the Mozilla Public License
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
// obtain one at http://mozilla.org/MPL/2.0/.
2024-12-23 13:54:11 +01:00
#include "elna/source/driver.h"
2024-12-21 14:05:27 +01:00
2024-12-23 13:54:11 +01:00
namespace elna
{
namespace source
2024-12-21 14:05:27 +01:00
{
position make_position(const yy::location& location)
{
return position{
static_cast<std::size_t>(location.begin.line),
static_cast<std::size_t>(location.begin.column)
};
}
syntax_error::syntax_error(const std::string& message,
2024-12-27 10:51:46 +01:00
const char *input_file, const yy::location& location)
2024-12-21 14:05:27 +01:00
: error(input_file, make_position(location)), message(message)
{
}
std::string syntax_error::what() const
{
return message;
}
2024-12-27 10:51:46 +01:00
driver::driver(const char *input_file)
2024-12-21 14:05:27 +01:00
: input_file(input_file)
{
}
void driver::error(const yy::location& loc, const std::string& message)
{
m_errors.emplace_back(std::make_unique<elna::source::syntax_error>(message, input_file, loc));
}
const std::list<std::unique_ptr<struct error>>& driver::errors() const noexcept
{
return m_errors;
}
}
2024-12-23 13:54:11 +01:00
}