Package net.emustudio.edigen.passes
Class PushDownVariantsVisitor
- java.lang.Object
-
- net.emustudio.edigen.Visitor
-
- net.emustudio.edigen.passes.PushDownVariantsVisitor
-
public class PushDownVariantsVisitor extends Visitor
A visitor which pushes the variant nodes down to the bottom of the tree.Expectation of a tree at input, e.g.:
Rule Variant Mask Pattern ... Mask PatternExpectation of the tree at output:
Rule Mask Pattern ... Mask Pattern Variant
-
-
Constructor Summary
Constructors Constructor Description PushDownVariantsVisitor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidvisit(Mask mask)Saves the topmost mask of the variant and dettaches it from the variant.voidvisit(Pattern pattern)Attaches the variant to the bottommost pattern.voidvisit(Rule rule)Attaches the top mask of each variant to the rule.voidvisit(Variant variant)Saves the current variant and detaches the variant from the rule if at least one variant's child is a mask.
-
-
-
Method Detail
-
visit
public void visit(Rule rule) throws SemanticException
Attaches the top mask of each variant to the rule.- Overrides:
visitin classVisitor- Parameters:
rule- the rule node- Throws:
SemanticException- never
-
visit
public void visit(Variant variant) throws SemanticException
Saves the current variant and detaches the variant from the rule if at least one variant's child is a mask.- Overrides:
visitin classVisitor- Parameters:
variant- the variant node- Throws:
SemanticException- never
-
visit
public void visit(Mask mask) throws SemanticException
Saves the topmost mask of the variant and dettaches it from the variant.- Overrides:
visitin classVisitor- Parameters:
mask- the mask node- Throws:
SemanticException- never
-
visit
public void visit(Pattern pattern) throws SemanticException
Attaches the variant to the bottommost pattern.- Overrides:
visitin classVisitor- Parameters:
pattern- the pattern node- Throws:
SemanticException- never
-
-