normalizer
Defines a normalizer to transform mG expressions in normal form.
This package defines the functions to normalize mG expressions when provided either as strings or expression trees.
The package contains the following objects:
mg_normalizer
mg_normalizer
module-attribute
¶
Normalizer ¶
Bases: Interpreter[Token, Tree]
Normalizer for mG expression trees.
Transforms a mG expression in normal form, by acting on its parse tree. Currently, this class only removes fixpoint/repeat expressions in which the fixpoint variable does not occur in the fixpoint body, and rewrites expressions so that fixpoint variables never occur on the right hand side of a sequential composition expression.
Attributes:
-
bound_vars
–The dictionary of local variables encountered during traversal of the tree.
-
bound_funs
–The dictionary of local functions encountered during traversal of the tree.
Source code in libmg/normalizer/normalizer.py
normalize ¶
Normalizes a mG expression.
If the expression is provided as a parse tree, a normalized parse tree is returned. If the expression is provided as string, a normalized string is returned.
Parameters:
-
expr
(Any
) –The expression to normalize.
Returns:
-
Any
–The normalized expression.