Constraint Validator
- class ConstraintValidator
This is the base class for all constraint validators. It is used to validate the parse tree of the untrusted input, and to fix the parse tree if it fails a soft-validation pass.
- abstract fix(*, bifrost: Bifrost, grammar: Lark, ctx: TraverseContext, tree: Tree[Token]) str
If the tree fails validation in a soft-pass, attempt to reconstruct it to satisfy the constraints. If the tree cannot be reconstructed, throw a Bifrost-specific exception
- Parameters:
grammar (Lark) – The Lark grammar used to parse the untrusted input. This is often used by
lark.reconstruct.Reconstructor
to fix the parse tree.ctx (TraverseContext) – The traversal context, used for error reporting.
tree (Tree[Token]) – The resulting parse tree of the untrusted input.
bifrost (Bifrost) –
- Return type:
- abstract validate(*, bifrost: Bifrost, ctx: TraverseContext, tree: Tree[Token])
This performs the Bifrost-specific validation of the parse tree. It throws a Bifrost-specific exception if the tree does not pass the constraints.
- Parameters:
ctx (TraverseContext) – The traversal context, used for error reporting.
tree (Tree[Token]) – The resulting parse tree of the untrusted input.
bifrost (Bifrost) –