
/* In input files cross-references between the grammar tree and the token tree
   are encoded as uids while in memory they are pointers for fast access. This
   API provides the conversion from uid to pointers during the load: in the
   first pass, while nodes are being loaded, an uid->ptr cache is built, then
   after all nodes have been loaded a second pass repaces the uids with pointers
   using this cache. */

typedef struct uid2node_s uid2node_t;

/* alloc a new, empty cache */
uid2node_t *uid2node_alloc(void);

/* n has it's ->uid set, save it in the uid->node_t hash */
void uid2node_save(uid2node_t *cache, node_t *n);

/* traverse a tree from root and replace location uids (twin_parent) with ptr */
void uid2node_resolve(uid2node_t *cache, node_t *root);

/* destroy a cache */
void uid2node_free(uid2node_t *cache);
