Skip to main content

Module validated

Module validated 

Source
Expand description

Shared validated-parse surface for generated recognizers.

Every generated parser exposes a strict parsing mode that rejects syntax errors, recovered error nodes, and missing generated required children before handing out a tree whose typed accessors are infallible. The types backing that surface are grammar-agnostic — all grammar-specific information they carry (context and child names) arrives as data from the generated validate_tree_structure — so they are defined once here and aliased by generated modules.

ValidatedTree and ValidatedRuleNode are branded with a Grammar type parameter. Each generated module instantiates them with its module-local ValidatedTreeContext marker (pub type TomlValidatedTree = antlr4_runtime::ValidatedTree<ValidatedTreeContext>;), so trees and nodes of different grammars remain distinct types and ValidatedRuleNode::downcast_ref cannot resolve a node against another grammar’s contexts, whose rule indexes and context kinds are grammar-local numbers. ValidationError is deliberately unbranded: a binary linking several generated parsers handles one error type and compiles one copy of its Display/Error/From machinery.

Structs§

ValidatedRuleNode
A rule node borrowed from a ValidatedTree with the same Grammar brand.
ValidatedTree
A completed, syntax-clean parse tree whose generated child cardinalities have been structurally validated.

Enums§

ValidationError
Failure to recognize or validate a strict generated parse.

Traits§

FromValidatedRuleNode
Constructs a generated validated context from a validated rule node of the same grammar.

Functions§

require_min_count
Checks one generated repeated-child minimum-cardinality invariant.