Implement division
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
#include "elna/source/lexer.hpp"
|
||||
#include <variant>
|
||||
#include <sstream>
|
||||
|
||||
namespace elna::source
|
||||
{
|
||||
@ -194,6 +195,20 @@ namespace elna::source
|
||||
|| of() == type::factor_operator;
|
||||
}
|
||||
|
||||
unexpected_character::unexpected_character(const std::string& character, const source::position position)
|
||||
: error(position), character(character)
|
||||
{
|
||||
}
|
||||
|
||||
std::string unexpected_character::what() const
|
||||
{
|
||||
std::stringstream ss{ "Unexpected character '" };
|
||||
|
||||
ss << character << "'";
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
source_result lex(const std::string& buffer)
|
||||
{
|
||||
std::vector<token> tokens;
|
||||
@ -278,10 +293,10 @@ namespace elna::source
|
||||
}
|
||||
else
|
||||
{
|
||||
return source_result("Unexpected next character", iterator.position());
|
||||
return source_result(unexpected_character{ std::string{ *iterator }, iterator.position() });
|
||||
}
|
||||
++iterator;
|
||||
}
|
||||
return source_result(tokens);
|
||||
return source_result(std::move(tokens));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user