bablr-lang / bablr-vm

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

Normalize whitespace around tokens on rebuild #2

Closed conartist6 closed 2 years ago

conartist6 commented 2 years ago

This library allows whitespace or comments to be added around the edges of nodes. This is useful for making modifications, but complicates the process of querying the data. When we rebuild tokens we should rebalance any dangling whitespace or comments to be attached to the outer context.

conartist6 commented 2 years ago

Picking this up, as it is next.

conartist6 commented 2 years ago

I think the solution is going to be to make match aware of type: 'Separator' descriptors. This way the implementation can be agnostic to exactly what a separator is, but can be aware of the idea that separators occur between nodes and their tokens may be found on either the inside of the parent or on the outside of the child.

conartist6 commented 2 years ago

Ok, yes, revisiting my roadmap this is definitely next. Essentially it's handling the non-normal representation of whitespace that I intend to leverage in order to push comments down in the tree, rendering them attached to nodes.