Skip to content

Commit

Permalink
Preserve case as is.
Browse files Browse the repository at this point in the history
  • Loading branch information
lhmouse committed Jan 16, 2019
1 parent 770d5c9 commit 7f4c89d
Show file tree
Hide file tree
Showing 78 changed files with 736 additions and 736 deletions.
334 changes: 167 additions & 167 deletions asteria/src/compiler/parser.cpp

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions asteria/src/compiler/parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Parser
};

private:
rocket::variant<std::nullptr_t, Parser_error, rocket::cow_vector<Statement>> m_stor;
rocket::variant<std::nullptr_t, Parser_Error, rocket::cow_vector<Statement>> m_stor;

public:
Parser() noexcept
Expand All @@ -42,10 +42,10 @@ class Parser
return this->state() == state_success;
}

Parser_error get_parser_error() const noexcept;
Parser_Error get_parser_error() const noexcept;
bool empty() const noexcept;

bool load(Token_stream &tstrm_io);
bool load(Token_Stream &tstrm_io);
void clear() noexcept;
Block extract_document();
};
Expand Down
2 changes: 1 addition & 1 deletion asteria/src/compiler/parser_error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Asteria {

const char * Parser_error::get_code_description(Parser_error::Code xcode) noexcept
const char * Parser_Error::get_code_description(Parser_Error::Code xcode) noexcept
{
switch(xcode) {
// Special
Expand Down
12 changes: 6 additions & 6 deletions asteria/src/compiler/parser_error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Asteria {

class Parser_error
class Parser_Error
{
public:
enum Code : std::uint32_t
Expand Down Expand Up @@ -76,7 +76,7 @@ class Parser_error
Code m_code;

public:
constexpr Parser_error(std::uint32_t line, std::size_t offset, std::size_t xlength, Code code) noexcept
constexpr Parser_Error(std::uint32_t line, std::size_t offset, std::size_t xlength, Code code) noexcept
: m_line(line), m_offset(offset), m_length(xlength), m_code(code)
{
}
Expand All @@ -100,20 +100,20 @@ class Parser_error
}
};

constexpr bool operator==(const Parser_error &lhs, Parser_error::Code rhs) noexcept
constexpr bool operator==(const Parser_Error &lhs, Parser_Error::Code rhs) noexcept
{
return lhs.get_code() == rhs;
}
constexpr bool operator!=(const Parser_error &lhs, Parser_error::Code rhs) noexcept
constexpr bool operator!=(const Parser_Error &lhs, Parser_Error::Code rhs) noexcept
{
return lhs.get_code() != rhs;
}

constexpr bool operator==(Parser_error::Code lhs, const Parser_error &rhs) noexcept
constexpr bool operator==(Parser_Error::Code lhs, const Parser_Error &rhs) noexcept
{
return lhs == rhs.get_code();
}
constexpr bool operator!=(Parser_error::Code lhs, const Parser_error &rhs) noexcept
constexpr bool operator!=(Parser_Error::Code lhs, const Parser_Error &rhs) noexcept
{
return lhs != rhs.get_code();
}
Expand Down
22 changes: 11 additions & 11 deletions asteria/src/compiler/simple_source_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,26 @@

namespace Asteria {

Simple_source_file::~Simple_source_file()
Simple_Source_File::~Simple_Source_File()
{
}

void Simple_source_file::do_throw_error(const Parser_error &err)
void Simple_Source_File::do_throw_error(const Parser_Error &err)
{
ASTERIA_THROW_RUNTIME_ERROR("An error was encountered while parsing source data:\n",
"line = ", err.get_line(), ", offset = ", err.get_offset(), ", length = ", err.get_length(), "\n",
"code = ", err.get_code(), ": ", Parser_error::get_code_description(err.get_code()));
"code = ", err.get_code(), ": ", Parser_Error::get_code_description(err.get_code()));
}

Parser_error Simple_source_file::load_file(const rocket::cow_string &filename)
Parser_Error Simple_Source_File::load_file(const rocket::cow_string &filename)
{
std::ifstream ifs(filename.c_str());
return this->load_stream(ifs, filename);
}

Parser_error Simple_source_file::load_stream(std::istream &cstrm_io, const rocket::cow_string &filename)
Parser_Error Simple_Source_File::load_stream(std::istream &cstrm_io, const rocket::cow_string &filename)
{
Token_stream tstrm;
Token_Stream tstrm;
if(!tstrm.load(cstrm_io, filename)) {
return tstrm.get_parser_error();
}
Expand All @@ -42,21 +42,21 @@ Parser_error Simple_source_file::load_stream(std::istream &cstrm_io, const rocke
}
this->m_code = parser.extract_document();
this->m_file = filename;
return Parser_error(0, 0, 0, Parser_error::code_success);
return Parser_Error(0, 0, 0, Parser_Error::code_success);
}

void Simple_source_file::clear() noexcept
void Simple_Source_File::clear() noexcept
{
this->m_code = rocket::cow_vector<Statement>();
this->m_file = std::ref("");
}

Reference Simple_source_file::execute(Global_context &global, rocket::cow_vector<Reference> &&args) const
Reference Simple_Source_File::execute(Global_Context &global, rocket::cow_vector<Reference> &&args) const
{
// Initialize parameters.
const auto loc = Source_location(this->m_file, 0);
const auto loc = Source_Location(this->m_file, 0);
const auto name = rocket::cow_string(std::ref("<file scope>"));
const auto zvarg = rocket::refcounted_object<Variadic_arguer>(loc, name);
const auto zvarg = rocket::refcounted_object<Variadic_Arguer>(loc, name);
const auto params = rocket::cow_vector<rocket::prehashed_string>();
// Execute the code as a function.
Reference self;
Expand Down
26 changes: 13 additions & 13 deletions asteria/src/compiler/simple_source_file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,47 +11,47 @@

namespace Asteria {

class Simple_source_file
class Simple_Source_File
{
private:
Block m_code;
rocket::cow_string m_file;

public:
Simple_source_file() noexcept
Simple_Source_File() noexcept
: m_code(), m_file()
{
}
explicit Simple_source_file(const rocket::cow_string &filename)
: Simple_source_file()
explicit Simple_Source_File(const rocket::cow_string &filename)
: Simple_Source_File()
{
const auto err = this->load_file(filename);
this->do_throw_on_error(err);
}
Simple_source_file(std::istream &cstrm_io, const rocket::cow_string &filename)
: Simple_source_file()
Simple_Source_File(std::istream &cstrm_io, const rocket::cow_string &filename)
: Simple_Source_File()
{
const auto err = this->load_stream(cstrm_io, filename);
this->do_throw_on_error(err);
}
ROCKET_COPYABLE_DESTRUCTOR(Simple_source_file);
ROCKET_COPYABLE_DESTRUCTOR(Simple_Source_File);

private:
void do_throw_on_error(const Parser_error &err)
void do_throw_on_error(const Parser_Error &err)
{
if(ROCKET_EXPECT(err == Parser_error::code_success)) {
if(ROCKET_EXPECT(err == Parser_Error::code_success)) {
return;
}
this->do_throw_error(err);
}
[[noreturn]] void do_throw_error(const Parser_error &err);
[[noreturn]] void do_throw_error(const Parser_Error &err);

public:
Parser_error load_file(const rocket::cow_string &filename);
Parser_error load_stream(std::istream &cstrm_io, const rocket::cow_string &filename);
Parser_Error load_file(const rocket::cow_string &filename);
Parser_Error load_stream(std::istream &cstrm_io, const rocket::cow_string &filename);
void clear() noexcept;

Reference execute(Global_context &global, rocket::cow_vector<Reference> &&args) const;
Reference execute(Global_Context &global, rocket::cow_vector<Reference> &&args) const;
};

}
Expand Down
Loading

0 comments on commit 7f4c89d

Please sign in to comment.