Class SemanticCheckVisitor


  • public class SemanticCheckVisitor
    extends Visitor
    A visitor which checks for additional semantic errors (not directly related to name resolution).
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void visit​(Format format)
      Finds out whether the particular set of rules was not already used.
      void visit​(Pattern pattern)
      Checks whether a subrule without length was already defined in this variant.
      void visit​(Rule rule)
      Adds the rule to the set of returning rules if one of its variants return.
      void visit​(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.
      void visit​(Value value)
      Finds out whether at least one rule's variant can return a value.
      void visit​(Variant variant)
      Sets the flag if the variant returns something and starts checking for subrule errors.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SemanticCheckVisitor

        public SemanticCheckVisitor()
    • 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:
        visit in class Visitor
        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:
        visit in class Visitor
        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:
        visit in class Visitor
        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:
        visit in class Visitor
        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:
        visit in class Visitor
        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:
        visit in class Visitor
        Parameters:
        value - the value node
        Throws:
        SemanticException - if the rule which this value refers to never returns a value