bablr-lang / bablr-vm

A VM for enforcing language rules on agAST trees
MIT License
40 stars 2 forks source link

Match tree traversal API #18

Closed conartist6 closed 1 year ago

conartist6 commented 2 years ago

I currently provide a few discrete tree-integration methods exported from index, e.g. updateTokens. These methods traverse a match tree. I would like to refactor that code into traversal and visitors, so that a single traversal could perform many operations, e.g. rebuilding tokens and updating ranges in a single pass.

conartist6 commented 1 year ago

I've settled on exposing matchNodesByRef, which saves you from needing to do anything very complicated to achieve a traversal. You don't need to know about the structure of the AST to traverse it, and you don't need to set up and use a resolver either.