Visitor & Transformer

class fluent.syntax.visitor.Visitor[source]

Bases: object

Read-only visitor pattern.

Subclass this to gather information from an AST. To generally define which nodes not to descend in to, overload generic_visit. To handle specific node types, add methods like visit_Pattern. If you want to still descend into the children of the node, call generic_visit of the superclass.

class fluent.syntax.visitor.Transformer[source]

Bases: fluent.syntax.visitor.Visitor

In-place AST Transformer pattern.

Subclass this to create an in-place modified variant of the given AST. If you need to keep the original AST around, pass a node.clone() to the transformer.