Skip to content

Commit

Permalink
Merge pull request #133 from stmonty/feat/support-unicode-identifiers
Browse files Browse the repository at this point in the history
feat/support unicode identifiers
  • Loading branch information
jeaye authored Dec 9, 2024
2 parents 289344e + 6c1d279 commit 469ba56
Show file tree
Hide file tree
Showing 6 changed files with 300 additions and 51 deletions.
5 changes: 3 additions & 2 deletions compiler+runtime/include/cpp/jank/read/lex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ namespace jank::read

namespace jank::read::lex
{
struct codepoint;
struct processor
{
struct iterator
Expand All @@ -150,9 +151,9 @@ namespace jank::read::lex
processor(native_persistent_string_view const &f);

result<token, error> next();
option<char> peek() const;
result<codepoint, error> peek() const;
option<error> check_whitespace(native_bool const found_space);

iterator begin();
iterator end();

Expand Down
19 changes: 19 additions & 0 deletions compiler+runtime/include/cpp/jank/result.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,25 @@ namespace jank
return std::move(boost::get<R>(data));
}

constexpr R &unwrap_or(R &fallback)
{
if(is_ok())
{
return boost::get<R>(data);
}
return fallback;
}

/* We don't take const& and return it since that's just asking for lifetime issues. */
constexpr R unwrap_or(R fallback) const
{
if(is_ok())
{
return boost::get<R>(data);
}
return std::move(fallback);
}

constexpr native_bool operator==(result const &rhs) const
{
return rhs.data == data;
Expand Down
Loading

0 comments on commit 469ba56

Please sign in to comment.