Package net.emustudio.edigen.passes
Class MergePatternsVisitor
- java.lang.Object
-
- net.emustudio.edigen.Visitor
-
- net.emustudio.edigen.passes.MergePatternsVisitor
-
public class MergePatternsVisitor extends Visitor
A visitor which merges multiple patterns of a variant into one mask + pattern.In addition, it sets starting offsets for subrules. Expectation of a tree at input:
Rule Variant Subrule Subrule Constant ...Expectation of the tree at output:Rule Variant Subrule Subrule Mask Pattern
-
-
Constructor Summary
Constructors Constructor Description MergePatternsVisitor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidvisit(Pattern pattern)Appends "true" bits to the mask (because these bits will be checked during decoding) and itself to the pattern (these bits should be the result of masking during decoding).voidvisit(Subrule subrule)Sets the starting offset of the subrule.voidvisit(Variant variant)Traverses all children nodes and adds one mask and pattern as a result of joining.
-
-
-
Method Detail
-
visit
public void visit(Variant variant) throws SemanticException
Traverses all children nodes and adds one mask and pattern as a result of joining.- Overrides:
visitin classVisitor- Parameters:
variant- the variant node- Throws:
SemanticException- never
-
visit
public void visit(Pattern pattern)
Appends "true" bits to the mask (because these bits will be checked during decoding) and itself to the pattern (these bits should be the result of masking during decoding).
-
visit
public void visit(Subrule subrule) throws SemanticException
Sets the starting offset of the subrule.If the subrule has length specified, adds "false" bits to the mask because these bits will not be checked against a pattern during decoding.
If the subrule does not refer to a rule (it is used only to return a value), it is removed from the tree.
- Overrides:
visitin classVisitor- Parameters:
subrule- the subrule node- Throws:
SemanticException- when pre-pattern is longer than expected
-
-