Skip to content

Commit

Permalink
Support octal, hex, and arbitrary radix numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
jianlingzhong committed Dec 3, 2024
1 parent 289344e commit 378f19f
Show file tree
Hide file tree
Showing 5 changed files with 384 additions and 62 deletions.
2 changes: 2 additions & 0 deletions compiler+runtime/bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

set -euo pipefail

git_root=$(git rev-parse --show-toplevel)
"$git_root"/compiler+runtime/bin/format
cmake --build build "$@"
10 changes: 10 additions & 0 deletions compiler+runtime/bin/format
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

set -euo pipefail

git_root=$(git rev-parse --show-toplevel)

for i in $(git status | grep -E "modified:.*[hc]pp" | sed 's/modified:\s*//'); do
"$git_root"/compiler+runtime/build/llvm-install/usr/local/bin/clang-format -i "$i"
echo "formatted" "$i"
done
9 changes: 7 additions & 2 deletions compiler+runtime/include/cpp/jank/read/lex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,19 @@ namespace jank::read::lex
processor(native_persistent_string_view const &f);

result<token, error> next();
option<char> peek() const;
option<char> peek(native_integer const ahead = 1) const;
option<error> check_whitespace(native_bool const found_space);
native_bool is_valid_num_char(char const c) const;

iterator begin();
iterator end();

size_t pos{};
/* Whether or not the previous token requires a space after it. */
native_integer radix{ 10 };
/* The 'r' used in arbitrary radix (prefixed with N and then r, where N is the radix (2 <= radix <= 36); */
/* e.g. 2r10101 for binary, 16rebed00d for hex) */
native_bool found_r{};
/* Whether the previous token requires a space after it. */
native_bool require_space{};
/* True when seeing a '/' following a number. */
native_bool found_slash_after_number{};
Expand Down
Loading

0 comments on commit 378f19f

Please sign in to comment.