-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
src/interpreter.jl
Outdated
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.")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
src/interpreter.jl
Outdated
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.")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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} |
There was a problem hiding this comment.
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.
src/interpreter.jl
Outdated
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 |
There was a problem hiding this comment.
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(...)
.
There was a problem hiding this comment.
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
test_with_input
toexecute_on_input
(see Renametest_with_input
andexecute_on_examples
#10)