Skip to main content

Module rule_context

Module rule_context 

Source
Expand description

Rule context and typed node views for rule matching.

This module provides RuleContext, the runtime context object passed to RewriteRule::apply() during AST transformation. It bundles mutable AST access with knowledge-base lookups, validation helpers, and statistics tracking.

It also defines a family of read-only view structs (CommandView, InfixView, DeclarativeView, EnvironmentView) that the match_* helpers extract from AST nodes. Rules operate on these views instead of pattern-matching raw Node variants directly, which keeps rule implementations concise and type-safe.

Structsยง

CommandView
A read-only view of a prefix command node for use in rule matching.
DeclarativeView
A read-only view of a declarative command node for use in rule matching.
EnvironmentView
A read-only view of an environment node for use in rule matching.
InfixView
A read-only view of an infix command node for use in rule matching.
RuleContext
The runtime context object passed to RewriteRule::apply().
RuleScopedContext
A read-only scoped context bound to a rule key for diagnostics and slot extraction.