Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
lefticus committed Aug 26, 2024
2 parents bb56d63 + 486344d commit 921ef78
Show file tree
Hide file tree
Showing 9 changed files with 625 additions and 538 deletions.
6 changes: 2 additions & 4 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ HeaderFilterRegex: ''
FormatStyle: none

CheckOptions:
- key: readability-identifier-length.IgnoredVariableNames
value: 'x|y|z'
- key: readability-identifier-length.IgnoredParameterNames
value: 'x|y|z'
readability-identifier-length.IgnoredVariableNames: 'x|y|z|id|ch'
readability-identifier-length.IgnoredParameterNames: 'x|y|z|id|ch'



Expand Down
8 changes: 5 additions & 3 deletions examples/compile_test.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#include <cons_expr/cons_expr.hpp>
#include <format>

using cons_expr_type = lefticus::cons_expr<std::uint16_t, char, long long, long double>;

constexpr long long add(long long x, long long y) { return x + y; }

consteval auto make_scripted_function()
{
lefticus::cons_expr<> evaluator;
cons_expr_type evaluator;

evaluator.add<&add>("add");

Expand All @@ -23,15 +25,15 @@ consteval auto make_scripted_function()


[[maybe_unused]] const auto result = evaluator.sequence(
evaluator.global_scope, std::get<typename lefticus::cons_expr<>::list_type>(evaluator.parse(input).first.value));
evaluator.global_scope, std::get<typename cons_expr_type::list_type>(evaluator.parse(input).first.value));

return std::bind_front(evaluator.make_callable<long long(long long, long long)>("sum"), evaluator);
}


int main()
{
// the kicker here is that this lambda is a full self contained script environment
// the kicker here is that this lambda is a full self-contained script environment
// that was all parsed and optimized at compile-time
auto func = make_scripted_function();

Expand Down
6 changes: 4 additions & 2 deletions examples/speed_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ constexpr long long add(long long x, long long y) { return x + y; }

void display(long long i) { std::cout << i << '\n'; }

using cons_expr_type = lefticus::cons_expr<std::uint16_t, char, long long, double>;

auto evaluate(std::string_view input)
{
lefticus::cons_expr<> evaluator;
cons_expr_type evaluator;

evaluator.add<&add>("add");
evaluator.add<&display>("display");

return evaluator.sequence(
evaluator.global_scope, std::get<typename lefticus::cons_expr<>::list_type>(evaluator.parse(input).first.value));
evaluator.global_scope, std::get<typename cons_expr_type::list_type>(evaluator.parse(input).first.value));
}

template<typename Result> Result evaluate_to(std::string_view input)
Expand Down
Loading

0 comments on commit 921ef78

Please sign in to comment.