internToken<E, Tok, Syn> function

Parser<E, GreenNode<Tok, Syn>> internToken<E, Tok, Syn>(
  1. Parser<E, GreenNode<Tok, Syn>> inner
)

Intern inner's produced green through the parse-scoped cache, so every structurally-equal token green (e.g. each GreenToken(num, "5") in the parse) collapses to one canonical heap instance.

For token-producing parsers (leaves). Equality cost is kind == && text == — cheap. Use internTree for tree-producing parsers, where equality recurses into children. Both produce the same InternedGreen ADT case; the split is a cost signal to the reader, not two mechanisms.

Interning makes structurally-equal siblings identical. RedTree sibling disambiguation uses childIndex, not green reference identity, so it is unaffected — see green_cache.dart's sibling-identity contract.

Implementation

Parser<E, GreenNode<Tok, Syn>> internToken<E, Tok, Syn>(
  Parser<E, GreenNode<Tok, Syn>> inner,
) => InternedGreen(inner);