Package net.emustudio.edigen.passes
Class ResolveNamesVisitor
- java.lang.Object
-
- net.emustudio.edigen.Visitor
-
- net.emustudio.edigen.passes.ResolveNamesVisitor
-
public class ResolveNamesVisitor extends Visitor
A visitor which creates associations between objects according to their names obtained from the input file.Missing implicit subrules are inferred.
Because the AST was constructed in one pass, backward references are not yet solved. This visitor resolves them (along with the backward references).
-
-
Constructor Summary
Constructors Constructor Description ResolveNamesVisitor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidvisit(Decoder decoder)First saves all rule names and then traverses the rule subtrees.voidvisit(Rule rule)Adds item(s) to the map from rule names to rules.voidvisit(Subrule subrule)Associates the subrule with the rule.voidvisit(Value value)Associates the value with the rule.voidvisit(Variant variant)Associates the variant with the subrule which it returns.
-
-
-
Method Detail
-
visit
public void visit(Decoder decoder) throws SemanticException
First saves all rule names and then traverses the rule subtrees.- Overrides:
visitin classVisitor- Parameters:
decoder- the decoder node- Throws:
SemanticException- never
-
visit
public void visit(Rule rule) throws SemanticException
Adds item(s) to the map from rule names to rules.- Overrides:
visitin classVisitor- Parameters:
rule- the rule node- Throws:
SemanticException- if the rule was already defined
-
visit
public void visit(Variant variant) throws SemanticException
Associates the variant with the subrule which it returns.- Overrides:
visitin classVisitor- Parameters:
variant- the variant node- Throws:
SemanticException- if the variant returns nonexistent subrule
-
visit
public void visit(Subrule subrule) throws SemanticException
Associates the subrule with the rule.- Overrides:
visitin classVisitor- Parameters:
subrule- the subrule node- Throws:
SemanticException- on subrule-related semantic errors
-
visit
public void visit(Value value) throws SemanticException
Associates the value with the rule.- Overrides:
visitin classVisitor- Parameters:
value- the value node- Throws:
SemanticException- if the value refers to a nonexistent rule
-
-