Skip to content

Commit

Permalink
added Hole parsing for rulenode2expr
Browse files Browse the repository at this point in the history
  • Loading branch information
THinnerichs committed Nov 30, 2023
1 parent f08bc73 commit c84d34c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/nodelocation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ function Base.insert!(root::RuleNode, loc::NodeLoc, rulenode::RuleNode)
root.children = rulenode.children
end
return root
end
end
6 changes: 6 additions & 0 deletions src/rulenode_operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,12 @@ function _rulenode2expr(expr::Expr, rulenode::RuleNode, grammar::Grammar, j=0)
expr.args[k],j = _rulenode2expr(arg, rulenode, grammar, j)
elseif haskey(grammar.bytype, arg)
child = rulenode.children[j+=1]
if isa(child, Hole)
# Find the index of the first element that is true
index = findfirst(==(true), child.domain)
expr.args[k] = isnothing(index) ? :Nothing : grammar.types[index]
continue
end
expr.args[k] = (child._val !== nothing) ?
child._val : deepcopy(grammar.rules[child.ind])
if !isterminal(grammar, child)
Expand Down

0 comments on commit c84d34c

Please sign in to comment.