Skip to content

Commit

Permalink
Update derivation_heuristic definition to also take grammar into account
Browse files Browse the repository at this point in the history
  • Loading branch information
THinnerichs committed Nov 24, 2023
1 parent 375a181 commit 90c4e04
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/csg_priority_enumerator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ function _expand(
)::Union{ExpandFailureReason, Vector{TreeConstraints}}
nodes::Vector{TreeConstraints} = []

for rule_index derivation_heuristic(findall(node.domain), context)
for rule_index derivation_heuristic(findall(node.domain), context, grammar)
new_node = RuleNode(rule_index, grammar)

# If dealing with the root of the tree, propagate here
Expand Down
12 changes: 6 additions & 6 deletions src/enumerator_constructors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function get_bfs_enumerator(
max_size::Int,
sym::Symbol,
hole_heuristic::Function=heuristic_leftmost,
derivation_heuristic::Function=(a,_) -> a
derivation_heuristic::Function=(a,_,_) -> a
)::ContextSensitivePriorityEnumerator
expand_function(node, grammar, max_depth, max_holes, context) = _expand(node, grammar, max_depth, max_holes, context, hole_heuristic, derivation_heuristic)
return ContextSensitivePriorityEnumerator(cfg2csg(grammar), max_depth, max_size, bfs_priority_function, expand_function, sym)
Expand All @@ -29,7 +29,7 @@ function get_bfs_enumerator(
max_size::Int,
sym::Symbol,
hole_heuristic::Function=heuristic_leftmost,
derivation_heuristic::Function=(a,_) -> a
derivation_heuristic::Function=(a,_,_) -> a
)::ContextSensitivePriorityEnumerator
expand_function(node, grammar, max_depth, max_holes, context) = _expand(node, grammar, max_depth, max_holes, context, hole_heuristic, derivation_heuristic)
return ContextSensitivePriorityEnumerator(grammar, max_depth, max_size, bfs_priority_function, expand_function, sym)
Expand All @@ -49,7 +49,7 @@ function get_dfs_enumerator(
max_size::Int,
sym::Symbol,
hole_heuristic::Function=heuristic_leftmost,
derivation_heuristic::Function=(a,_) -> a
derivation_heuristic::Function=(a,_,_) -> a
)::ContextSensitivePriorityEnumerator
expand_function(node, grammar, max_depth, max_holes, context) = _expand(node, grammar, max_depth, max_holes, context, hole_heuristic, derivation_heuristic)
return ContextSensitivePriorityEnumerator(cfg2csg(grammar), max_depth, max_size, dfs_priority_function, expand_function, sym)
Expand All @@ -66,7 +66,7 @@ function get_dfs_enumerator(
max_size::Int,
sym::Symbol,
hole_heuristic::Function=heuristic_leftmost,
derivation_heuristic::Function=(a,_) -> a
derivation_heuristic::Function=(a,_,_) -> a
)::ContextSensitivePriorityEnumerator
expand_function(node, grammar, max_depth, max_holes, context) = _expand(node, grammar, max_depth, max_holes, context, hole_heuristic, derivation_heuristic)
return ContextSensitivePriorityEnumerator(grammar, max_depth, max_size, dfs_priority_function, expand_function, sym)
Expand Down Expand Up @@ -97,7 +97,7 @@ function get_most_likely_first_enumerator(
max_size::Int,
sym::Symbol,
hole_heuristic::Function=heuristic_leftmost,
derivation_heuristic::Function=(a,_) -> a
derivation_heuristic::Function=(a,_,_) -> a
)::ContextSensitivePriorityEnumerator
expand_function(node, grammar, max_depth, max_holes, context) = _expand(node, grammar, max_depth, max_holes, context, hole_heuristic, derivation_heuristic)
return ContextSensitivePriorityEnumerator(cfg2csg(grammar), max_depth, max_size, most_likely_priority_function, expand_function, sym)
Expand All @@ -115,7 +115,7 @@ function get_most_likely_first_enumerator(
max_size::Int,
sym::Symbol,
hole_heuristic::Function=heuristic_leftmost,
derivation_heuristic::Function=(a,_) -> a
derivation_heuristic::Function=(a,_,_) -> a
)::ContextSensitivePriorityEnumerator
expand_function(node, grammar, max_depth, max_holes, context) = _expand(node, grammar, max_depth, max_holes, context, hole_heuristic, derivation_heuristic)
return ContextSensitivePriorityEnumerator(grammar, max_depth, max_size, most_likely_priority_function, expand_function, sym)
Expand Down

0 comments on commit 90c4e04

Please sign in to comment.