Skip to content

Add method for generated interpreters without input - #51

Open
ReubenJ wants to merge 5 commits into
masterfrom
feat/no-input-generated-interpreters
Open

Add method for generated interpreters without input#51
ReubenJ wants to merge 5 commits into
masterfrom
feat/no-input-generated-interpreters

Conversation

@ReubenJ

@ReubenJ ReubenJ commented Mar 26, 2026

Copy link
Copy Markdown
Member

Support the following use-case:

g = @csgrammar begin
Number = |(1:2)
Number = x
Number = Number + Number
Number = Number * Number
Number = Number + 1
Number = x * 2
end
# Compile once
interpret_custom = HerbInterpret.make_interpreter(g; input_symbols=[:x])
rn = @rulenode(5{4{3,2},7}) # (x + 2) * (x * 2)
input = Dict{Symbol,Any}(:x => 1)
@testset "No input" begin
@test interpret_custom(@rulenode(4{1,1})) == 2
end

Additionally, relax the type bounds on the input argument for generated interpreters. Previously, it was Dict{Symbol,Any} matching only dictionaries with an explicit Any type for the values, where we actually wanted to allow for dictionaries with any type of value <:Any.

While we're at it, switch to ReTestItems.

@ReubenJ
ReubenJ requested a review from THinnerichs March 26, 2026 13:51
@ReubenJ ReubenJ self-assigned this Mar 26, 2026
@ReubenJ ReubenJ added the enhancement New feature or request label Mar 26, 2026
@codecov

codecov Bot commented Mar 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.41%. Comparing base (b5a6c5c) to head (f3debbe).

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #51      +/-   ##
==========================================
+ Coverage   69.11%   69.41%   +0.29%     
==========================================
  Files           3        3              
  Lines         204      206       +2     
==========================================
+ Hits          141      143       +2     
  Misses         63       63              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

github-actions Bot commented Mar 26, 2026

Copy link
Copy Markdown

Benchmark Results

master f3debbe... master / f3debbe...
interpret/Random Expressions 0.126 ± 0.0015 ms 0.126 ± 0.0017 ms 0.997 ± 0.018
time_to_load 0.0853 ± 0.0029 s 0.0848 ± 0.00054 s 1.01 ± 0.035

Benchmark Plots

A plot of the benchmark results have been uploaded as an artifact to the workflow run for this PR.
Go to "Actions"->"Benchmark a pull request"->[the most recent run]->"Artifacts" (at the bottom).

@ReubenJ
ReubenJ force-pushed the feat/no-input-generated-interpreters branch from f632488 to f3debbe Compare March 26, 2026 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant