Implement defer
This commit is contained in:
@ -9,10 +9,11 @@ namespace boot
|
||||
{
|
||||
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)
|
||||
};
|
||||
position result;
|
||||
result.line = static_cast<std::size_t>(location.begin.line);
|
||||
result.column = static_cast<std::size_t>(location.begin.column);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
syntax_error::syntax_error(const std::string& message,
|
||||
@ -33,7 +34,7 @@ namespace boot
|
||||
|
||||
void driver::error(const yy::location& loc, const std::string& message)
|
||||
{
|
||||
m_errors.emplace_back(std::make_unique<boot::syntax_error>(message, input_file, loc));
|
||||
m_errors.emplace_back(new boot::syntax_error(message, input_file, loc));
|
||||
}
|
||||
|
||||
const std::list<std::unique_ptr<struct error>>& driver::errors() const noexcept
|
||||
@ -41,36 +42,36 @@ namespace boot
|
||||
return m_errors;
|
||||
}
|
||||
|
||||
std::optional<char> escape_char(char escape)
|
||||
char escape_char(char escape)
|
||||
{
|
||||
switch (escape)
|
||||
{
|
||||
case 'n':
|
||||
return std::make_optional<char>('\n');
|
||||
return '\n';
|
||||
case 'a':
|
||||
return std::make_optional<char>('\a');
|
||||
return '\a';
|
||||
case 'b':
|
||||
return std::make_optional<char>('\b');
|
||||
return '\b';
|
||||
case 't':
|
||||
return std::make_optional<char>('\t');
|
||||
return '\t';
|
||||
case 'f':
|
||||
return std::make_optional<char>('\f');
|
||||
return '\f';
|
||||
case 'r':
|
||||
return std::make_optional<char>('\r');
|
||||
return '\r';
|
||||
case 'v':
|
||||
return std::make_optional<char>('\v');
|
||||
return '\v';
|
||||
case '\\':
|
||||
return std::make_optional<char>('\\');
|
||||
return '\\';
|
||||
case '\'':
|
||||
return std::make_optional<char>('\'');
|
||||
return '\'';
|
||||
case '"':
|
||||
return std::make_optional<char>('"');
|
||||
return '"';
|
||||
case '?':
|
||||
return std::make_optional<char>('\?');
|
||||
return '\?';
|
||||
case '0':
|
||||
return std::make_optional<char>('\0');
|
||||
return '\0';
|
||||
default:
|
||||
return std::nullopt;
|
||||
return escape_invalid_char;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user