Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reame functions, adapt to HerbSpecification.jl #11

Merged
merged 6 commits into from
Feb 1, 2024
Merged

Reame functions, adapt to HerbSpecification.jl #11

merged 6 commits into from
Feb 1, 2024

Conversation

THinnerichs
Copy link
Member

@THinnerichs THinnerichs requested a review from ReubenJ February 1, 2024 11:03
@THinnerichs THinnerichs self-assigned this Feb 1, 2024
function test_all_examples(tab::SymbolTable, expr::Any, examples::Vector{Example})::Vector{Bool}
function test_all_examples(tab::SymbolTable, expr::Any, examples::Vector{IOExample})::Vector{Bool}
depwarn("`test_all_examples` is deprecated and should no longer be used.", :test_all_examples)
throw(ErrorException("`test_all_examples` has been deprecated and should not be used."))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
throw(ErrorException("`test_all_examples` has been deprecated and should not be used."))

We shouldn't throw an exception for a deprecation. We can remove the function entirely in the next release, but for now the depwarn is enough.

function evaluate_program(program::RuleNode, examples::Vector{<:Example}, grammar::Grammar, evaluation_function::Function)
function evaluate_program(program::RuleNode, examples::Vector{<:IOExample}, grammar::Grammar, evaluation_function::Function)
depwarn("`evaluate_program` is deprecated and should no longer be used. Please use HerbSearch.evaluate instead.", :evaluate_program)
throw(ErrorException("`evaluate_program` has been deprecated and should not be used."))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
throw(ErrorException("`evaluate_program` has been deprecated and should not be used."))

Here too.


Executes a given expression on a set of inputs and returns the respective outputs.
WARNING: This function throws exceptions that are caused in the given expression.
These exceptions have to be handled by the caller of this function.
"""
function execute_on_examples(tab::SymbolTable, expr::Any, example_inputs::Vector{Dict{Symbol, Any}})::Vector{Any}
return [test_with_input(tab, expr, example) for example in example_inputs]
function execute_on_input(tab::SymbolTable, expr::Any, input::Vector{Dict{Symbol, Any}})::Vector{Any}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have a Vector and non-Vector version for the Grammar, let's add a Vector version of the SymbolTable version.

Comment on lines 183 to 197
elseif ex.head == :while
max_iterations = 1000
result = nothing

for i in 1:max_iterations # limit iterations to 1000
if !interpret(tab, ex.args[1])
break
end
if i == max_iterations
error("Exceeded maximum number of iterations in while-loop.")
end

result = interpret(tab, ex.args[2])
end
return result
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should parameterize max_iterations with a default argument to interpret(...).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And should split the addition of while loops into a different PR

@THinnerichs THinnerichs merged commit 93954b3 into master Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants