Package net.emustudio.edigen.passes
Class SemanticCheckVisitor
- java.lang.Object
-
- net.emustudio.edigen.Visitor
-
- net.emustudio.edigen.passes.SemanticCheckVisitor
-
public class SemanticCheckVisitor extends Visitor
A visitor which checks for additional semantic errors (not directly related to name resolution).
-
-
Constructor Summary
Constructors Constructor Description SemanticCheckVisitor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidvisit(Format format)Finds out whether the particular set of rules was not already used.voidvisit(Pattern pattern)Checks whether a subrule without length was already defined in this variant.voidvisit(Rule rule)Adds the rule to the set of returning rules if one of its variants return.voidvisit(Subrule subrule)Checks whether a subrule without length was already defined in this variant and sets the flag if this subrule does not have a specified length.voidvisit(Value value)Finds out whether at least one rule's variant can return a value.voidvisit(Variant variant)Sets the flag if the variant returns something and starts checking for subrule errors.
-
-
-
Method Detail
-
visit
public void visit(Rule rule) throws SemanticException
Adds the rule to the set of returning rules if one of its variants return.- Overrides:
visitin classVisitor- Parameters:
rule- the rule node- Throws:
SemanticException- on semantic error
-
visit
public void visit(Variant variant) throws SemanticException
Sets the flag if the variant returns something and starts checking for subrule errors. The subrule without length must occur only at the end of the variant.- Overrides:
visitin classVisitor- Parameters:
variant- the variant node- Throws:
SemanticException- on subrule error
-
visit
public void visit(Pattern pattern) throws SemanticException
Checks whether a subrule without length was already defined in this variant.- Overrides:
visitin classVisitor- Parameters:
pattern- the pattern node- Throws:
SemanticException- if a subrule without length was defined
-
visit
public void visit(Subrule subrule) throws SemanticException
Checks whether a subrule without length was already defined in this variant and sets the flag if this subrule does not have a specified length.- Overrides:
visitin classVisitor- Parameters:
subrule- the surule node- Throws:
SemanticException- if a subrule without length was defined
-
visit
public void visit(Format format) throws SemanticException
Finds out whether the particular set of rules was not already used. Otherwise it would be ambiguous which format to apply when the decoded instruction contained this set of rules.- Overrides:
visitin classVisitor- Parameters:
format- the format node- Throws:
SemanticException- if the set of values was used in multiple formats
-
visit
public void visit(Value value) throws SemanticException
Finds out whether at least one rule's variant can return a value. Probably only the fields for variants returning a value will be present in the generated code, so using other variants in a disassembler would cause a syntax error.- Overrides:
visitin classVisitor- Parameters:
value- the value node- Throws:
SemanticException- if the rule which this value refers to never returns a value
-
-