Skip to main content

decorate_syntax_tree

Function decorate_syntax_tree 

Source
pub fn decorate_syntax_tree(
    tree: &SyntaxTree,
    decorators: &DecoratorSet,
    source: &[u8],
) -> Result<SyntaxTree, DecoratorError>
Expand description

The syntax tree the executor and recovery decorators of decorators make of tree.

The executor level shows every node and token as { type, kind, field, text } (text for tokens): setting kind or field changes it, and drop replaces a node with its children, so the tree still holds every byte; a token cannot be dropped. The recovery level shows every ERROR node as { type, reason, text } and every MISSING node as { type, kind }: setting reason or kind changes it, and drop removes a MISSING node, which spans no input; an ERROR node cannot be dropped.

ยงErrors

A DecoratorError when a decorator drops a token, an ERROR node or the root.