Skip to content

Commit

Permalink
Grammar -> AbstractGrammar; update version numbers and compat
Browse files Browse the repository at this point in the history
  • Loading branch information
THinnerichs committed Feb 22, 2024
1 parent ac39be0 commit 904543a
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 <[email protected]>", "Nicolae Filat <[email protected]>", "Tilman Hinnerichs <[email protected]>", "Sebastijan Dumancic <[email protected]>"]
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

0 comments on commit 904543a

Please sign in to comment.