Module hyper_ast::position

source ·
Expand description

Positioning elements in HyperAST

Because the HyperAST is a Direct Acyclic Graph (DAG), any given sub-tree possibly has multiple global positions. The global position, path, or offset of a subtree is global/contextual information, thus it cannot be stored efficiently on subtrees of a DAG.

You can look at this module as an example of computing global metrics out of local ones.

This module specifically helps with tasks related to positioning nodes globally,

  • it helps maintain positional states during traversals
  • it helps convert between positional representations
    • topological
    • path (list of offsets)
    • a file path, an offset and a length
    • with/out hidden nodes

Incremental position storing

[structural_pos]

topological index

[topological_offset] - post-order

path

offsets_and_nodes - list of offsets

collection of path

Optimisation related, sometimes necessary to have acceptable perfs.
- list of paths
- it of paths
- topo ordered list of paths
  incremental compute
- reversed dag of paths
  mem optimization,

with hidden nodes (spaces, abtract nodes,….)

Re-exports

Modules

Structs

Traits

Functions

Type Definitions