Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement rulenode2expr for StateFixedShapedHole #26

Open
Whebon opened this issue Mar 19, 2024 · 0 comments
Open

Implement rulenode2expr for StateFixedShapedHole #26

Whebon opened this issue Mar 19, 2024 · 0 comments
Assignees

Comments

@Whebon
Copy link
Contributor

Whebon commented Mar 19, 2024

The FixedShapedSolver produces solutions by manipulated a fixed shaped tree. Such fixed shaped trees are a hybrid of two types:

  • RuleNode
  • StateFixedShapedHole

When next_solution! is called, the previous solution is lost and re-manipulated into a new solution. This is intended behavior as this approach to reduce the number of allocations: trees are never copied but reused.

In the current version of Herb, it is not possible to interpret a StateFixedShapedHole directly. So after finding a solution, the tree is converted to rule nodes using statefixedshapedhole2rulenode.

Why is this needed

To reduce to number memory allocations, stop using statefixedshapedhole2rulenode

Target implementation

Implementing rulenode2expr(hole::StateFixedShapedHole, grammar::Grammar) should be straight forward:

  • Ignore rulenode._val
  • Instead of using rulenode.ind, use get_rule(hole)
  • Instead of using rulenode.children, use get_children(hole)
@Whebon Whebon self-assigned this Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant