Skip to content

Commit

Permalink
Move pirated functions reported by Aqua to HerbCore
Browse files Browse the repository at this point in the history
  • Loading branch information
ReubenJ committed Nov 15, 2024
1 parent e3b1ca2 commit 608b939
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 34 deletions.
5 changes: 2 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
name = "HerbGrammar"
uuid = "4ef9e186-2fe5-4b24-8de7-9f7291f24af7"
authors = ["Sebastijan Dumancic <[email protected]>", "Jaap de Jong <[email protected]>", "Nicolae Filat <[email protected]>", "Piotr Cichoń <[email protected]>"]
version = "0.4.0"
version = "0.5.0"

[deps]
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
HerbCore = "2b23ba43-8213-43cb-b5ea-38c12b45bd45"
Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
TreeView = "39424ebd-4cf3-5550-a685-96706a953f40"

[compat]
AbstractTrees = "^0.4"
DataStructures = "0.17,0.18"
HerbCore = "^0.3.0"
Serialization = "^1.8,^1.10,^1.11"
TreeView = "^0.5"
julia = "^1.8"
1 change: 0 additions & 1 deletion src/HerbGrammar.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module HerbGrammar

import TreeView: walk_tree
using AbstractTrees
using DataStructures # NodeRecycler
using Serialization # grammar_io

Expand Down
8 changes: 0 additions & 8 deletions src/grammar_base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ function get_childtypes(rule::Any, types::AbstractVector{Symbol})
return retval
end

Base.getindex(grammar::AbstractGrammar, typ::Symbol) = grammar.bytype[typ]

"""
nonterminals(grammar::AbstractGrammar)::Vector{Symbol}
Expand Down Expand Up @@ -183,13 +182,6 @@ Returns the maximum arity (number of children) over all production rules in the
max_arity(grammar::AbstractGrammar)::Int = maximum(length(cs) for cs in grammar.childtypes)


function Base.show(io::IO, grammar::AbstractGrammar)
for i in eachindex(grammar.rules)
println(io, i, ": ", grammar.types[i], " = ", grammar.rules[i])
end
end


"""
add_rule!(g::AbstractGrammar, e::Expr)
Expand Down
14 changes: 0 additions & 14 deletions src/rulenode_operators.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
HerbCore.RuleNode(ind::Int, grammar::AbstractGrammar) = RuleNode(ind, nothing, [Hole(get_domain(grammar, type)) for type grammar.childtypes[ind]])
HerbCore.RuleNode(ind::Int, _val::Any, grammar::AbstractGrammar) = RuleNode(ind, _val, [Hole(get_domain(grammar, type)) for type grammar.childtypes[ind]])

HerbCore.UniformHole(domain::BitVector, grammar::AbstractGrammar) = UniformHole(domain, [Hole(get_domain(grammar, type)) for type grammar.childtypes[findfirst(domain)]])

rulesoftype(::Hole, ::Set{Int}) = Set{Int}()

"""
Expand Down Expand Up @@ -344,12 +339,3 @@ function contains_returntype(node::RuleNode, grammar::AbstractGrammar, sym::Symb
end
return false
end

function Base.display(rulenode::RuleNode, grammar::AbstractGrammar)
root = rulenode2expr(rulenode, grammar)
if isa(root, Expr)
walk_tree(root)
else
root
end
end
11 changes: 3 additions & 8 deletions src/utils.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
# Interface to AbstractTrees.jl
AbstractTrees.children(node::RuleNode) = node.children
AbstractTrees.printnode(io::IO, node::RuleNode) = print(io, node.ind)


"""
mindepth_map(grammar::AbstractGrammar)
Expand Down Expand Up @@ -45,15 +40,15 @@ end
Data structure for mapping terminal symbols in the [`AbstractGrammar`](@ref) to their Julia interpretation.
"""
const SymbolTable = Dict{Symbol,Any}
const SymbolTable{I} = Dict{Symbol,I}

"""
SymbolTable(grammar::AbstractGrammar, mod::Module=Main)
grammar2symboltable(grammar::AbstractGrammar, mod::Module=Main)
Returns a [`SymbolTable`](@ref) populated with a mapping from symbols in the
[`AbstractGrammar`](@ref) to symbols in module `mod` or `Main`, if defined.
"""
function HerbGrammar.SymbolTable(grammar::AbstractGrammar, mod::Module=Main)
function grammar2symboltable(grammar::AbstractGrammar, mod::Module=Main)

Check warning on line 51 in src/utils.jl

View check run for this annotation

Codecov / codecov/patch

src/utils.jl#L51

Added line #L51 was not covered by tests
tab = SymbolTable()
for rule in grammar.rules
_add_to_symboltable!(tab, rule, mod)
Expand Down

0 comments on commit 608b939

Please sign in to comment.