Skip to content

Commit

Permalink
Merge pull request #9 from Herb-AI/dev
Browse files Browse the repository at this point in the history
Grammar -> AbstractGrammar; update version numbers and compat
  • Loading branch information
THinnerichs authored Feb 22, 2024
2 parents ac39be0 + 904543a commit 1ada2a0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name = "HerbCore"
uuid = "2b23ba43-8213-43cb-b5ea-38c12b45bd45"
authors = ["Jaap de Jong <jaapdejong15@gmail.com>", "Nicolae Filat <N.Filat@student.tudelft.nl>", "Tilman Hinnerichs <t.r.hinnerichs@tudelft.nl>", "Sebastijan Dumancic <s.dumancic@tudelft.nl>"]
version = "0.1.1"
version = "0.2.0"

[compat]
julia = "1.8"
julia = "^1.8"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
2 changes: 1 addition & 1 deletion src/HerbCore.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ export
contains_hole,

Constraint,
Grammar
AbstractGrammar

end # module HerbCore
6 changes: 3 additions & 3 deletions src/grammar.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Grammar
AbstractGrammar
Abstract type representing all grammars.
It is assumed that all grammar structs have at least the following attributes:
Expand All @@ -16,6 +16,6 @@ If a rule is terminal, the corresponding list is empty.
- `log_probabilities::Union{Vector{Real}, Nothing}`: A list of probabilities for each rule.
If the grammar is non-probabilistic, the list can be `nothing`.
For concrete types, see [`ContextFreeGrammar`](@ref) and [`ContextSensitiveGrammar`](@ref).
For concrete types, see [`ContextSensitiveGrammar`](@ref) within the `HerbGrammar` module.
"""
abstract type Grammar end
abstract type AbstractGrammar end
12 changes: 6 additions & 6 deletions src/rulenode.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Abstract type for representing expression trees.
Expression trees consist of [`RuleNode`](@ref)s and [`Hole`](@ref)s.
- A [`RuleNode`](@ref) represents a certain production rule in the [`Grammar`](@ref).
- A [`RuleNode`](@ref) represents a certain production rule in the [`AbstractGrammar`](@ref).
- A [`Hole`](@ref) is a placeholder where certain rules in the grammar still can be applied.
"""
abstract type AbstractRuleNode end
Expand All @@ -14,10 +14,10 @@ abstract type AbstractRuleNode end
RuleNode <: AbstractRuleNode
A [`RuleNode`](@ref) represents a node in an expression tree.
Each node corresponds to a certain rule in the [`Grammar`](@ref).
Each node corresponds to a certain rule in the [`AbstractGrammar`](@ref).
A [`RuleNode`](@ref) consists of:
- `ind`: The index of the rule in the [`Grammar`](@ref) which this node is representing.
- `ind`: The index of the rule in the [`AbstractGrammar`](@ref) which this node is representing.
- `_val`: Field for storing immediately evaluated values
- `children`: The children of this node in the expression tree
Expand Down Expand Up @@ -58,7 +58,7 @@ RuleNode(ind::Int) = RuleNode(ind, nothing, AbstractRuleNode[])
"""
RuleNode(ind::Int, children::Vector{AbstractRuleNode})
Create a [`RuleNode`](@ref) for the [`Grammar`](@ref) rule with index `ind` and `children` as subtrees.
Create a [`RuleNode`](@ref) for the [`AbstractGrammar`](@ref) rule with index `ind` and `children` as subtrees.
"""
RuleNode(ind::Int, children::Vector{AbstractRuleNode}) = RuleNode(ind, nothing, children)
RuleNode(ind::Int, children::Vector{RuleNode}) = RuleNode(ind, nothing, children)
Expand All @@ -68,12 +68,12 @@ RuleNode(ind::Int, children::Vector{Hole}) = RuleNode(ind, nothing, children)
"""
RuleNode(ind::Int, _val::Any)
Create a [`RuleNode`](@ref) for the [`Grammar`](@ref) rule with index `ind`,
Create a [`RuleNode`](@ref) for the [`AbstractGrammar`](@ref) rule with index `ind`,
`_val` as immediately evaluated value and no children
!!! warning
Only use this constructor if you are absolutely certain that a rule is terminal and cannot have children.
Use [`RuleNode(ind::Int, grammar::Grammar)`] for rules that might have children.
Use [`RuleNode(ind::Int, grammar::AbstractGrammar)`] for rules that might have children.
In general, [`Hole`](@ref)s should be used as a placeholder when the children of a node are not yet known.
!!! compat
Expand Down

2 comments on commit 1ada2a0

@THinnerichs
Copy link
Member Author

Choose a reason for hiding this comment

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

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/101461

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.0 -m "<description of version>" 1ada2a0a9522f5f53963a3a0b2a400d2f261a980
git push origin v0.2.0

Please sign in to comment.