nemoguardrails.colang.v2_x.lang.transformer
nemoguardrails.colang.v2_x.lang.transformer
Module Contents
Classes
API
Bases: Transformer
A Lark transformer for transforming the parsing tree into the right internal structure.
It extracts the following:
- Flows
- Imports (TODO)
Default function that is called if there is no attribute matching data
Can be overridden. Defaults to creating
a new copy of the tree node (i.e. return Tree(data, children: list, meta))
Processing for flow tree nodes.
Processing for spec tree nodes.
Rule: if_stmt: “if” test suite elifs [“else” suite]
Processing for name tree nodes.
We just copy the values from the children: list, which should be tokens.
The set statement can result in either a Set operation, or a SpecOp with a return value capturing.
Processing for spec tree nodes.
Rule: spec: spec_name [classic_arguments | simple_arguments] (spec_member)* [capture_ref] | var_name (spec_member)* [capture_ref]
Processing for spec_op tree nodes.
Rule: spec_op: [spec_operator] spec_expr | on_var_spec_expr
Processing for spec tree nodes.
Rule: when_stmt: “when” spec_expr suite orwhen [“else” suite]
Helper to create an element of the specified type.