Class ASTPtRootNode

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.ArrayList _children
      The children.
      protected int _id
      The id.
      protected boolean _isConstant
      Flags whether the parse tree under this root evaluates to a constant.
      protected Node _parent
      The parent node.
      protected Token _ptToken
      Each node stores its type and state information in this variable.
      protected Type _ptType
      The type of this node.
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      java.lang.Object clone()
      Clone the parse tree node by invoking the clone() method of the base class (java.lang.Object).
      void displayParseTree​(java.lang.String prefix)
      Override this method if you want to customize how the node dumps out its children.
      Token evaluateParseTree()
      Deprecated.
      Use a ParseTreeEvaluator instead.
      Token getToken()
      Return the evaluated token value of this node.
      Type getType()
      Return the type of this node.
      boolean isCongruent​(ASTPtRootNode node, java.util.Map renaming)
      Return true if this node is (hierarchically) congruent to the given node, under the given renaming of bound identifiers.
      boolean isConstant()
      Return true if this node represents a constant value.
      boolean isEvaluated()
      Return true if this node has had its token value set to something other than null.
      void jjtAddChild​(Node n, int i)
      This method tells the node to add its argument to the node's list of children.
      void jjtClose()
      This method is called after all the child nodes have been added.
      Node jjtGetChild​(int i)
      This method returns a child node.
      int jjtGetNumChildren()
      Return the number of children the node has.
      Node jjtGetParent()  
      void jjtOpen()
      This method is called after the node has been made the current node.
      void jjtSetParent​(Node n)
      This pair of methods are used to inform the node of its parent.
      void setConstant​(boolean flag)
      Set whether this node is a constant.
      void setToken​(Token token)
      Set the value of this node.
      void setType​(Type type)
      Set the type of this node.
      java.lang.String toString()
      Return the string value of this node.
      java.lang.String toString​(java.lang.String prefix)
      Return the prefix, followed by the string value of this node.
      void visit​(ParseTreeVisitor visitor)
      Traverse this node with the given visitor.
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • _parent

        protected Node _parent
        The parent node.
      • _children

        protected java.util.ArrayList _children
        The children.
      • _id

        protected int _id
        The id.
      • _ptToken

        protected Token _ptToken
        Each node stores its type and state information in this variable.
      • _ptType

        protected Type _ptType
        The type of this node.
      • _isConstant

        protected boolean _isConstant
        Flags whether the parse tree under this root evaluates to a constant.
    • Constructor Detail

      • ASTPtRootNode

        public ASTPtRootNode​(int i)
      • ASTPtRootNode

        public ASTPtRootNode​(PtParser p,
                             int i)
    • Method Detail

      • clone

        public java.lang.Object clone()
                               throws java.lang.CloneNotSupportedException
        Clone the parse tree node by invoking the clone() method of the base class (java.lang.Object).
        Overrides:
        clone in class java.lang.Object
        Returns:
        A new parse tree node.
        Throws:
        java.lang.CloneNotSupportedException - If the superclass clone() method throws it.
      • displayParseTree

        public void displayParseTree​(java.lang.String prefix)
        Override this method if you want to customize how the node dumps out its children.
        Parameters:
        prefix - The prefix, which is processed by toString(String).
      • evaluateParseTree

        @Deprecated
        public Token evaluateParseTree()
                                throws IllegalActionException
        Deprecated.
        Use a ParseTreeEvaluator instead.
        Evaluate the parse tree.
        Returns:
        The token contained by the root node for the parse tree.
        Throws:
        IllegalActionException - If an error occurs trying to evaluate the PtToken type and/or value to be stored in node in the tree.
      • getToken

        public Token getToken()
        Return the evaluated token value of this node. This value may be set during parsing, if this represents a constant value, or may be set during parse tree evaluation.
        Returns:
        The evaluated token.
      • getType

        public Type getType()
        Return the type of this node. This value may be set during parsing, if this represents a constant value, or may be set during parse tree evaluation.
        Returns:
        The type of this node.
      • isCongruent

        public boolean isCongruent​(ASTPtRootNode node,
                                   java.util.Map renaming)
        Return true if this node is (hierarchically) congruent to the given node, under the given renaming of bound identifiers. Derived classes should extend this method to add additional necessary congruency checks.
        Parameters:
        node - The node to compare to.
        renaming - A map from String to String that gives a renaming from identifiers in this node to identifiers in the given node.
        Returns:
        True if the node is congruent.
      • isConstant

        public boolean isConstant()
        Return true if this node represents a constant value. This will be set to true if the node is a constant leaf node (either it is a constant leaf node, or a pure function with constant children.)
        Returns:
        True if the node represents a constant value.
      • isEvaluated

        public boolean isEvaluated()
        Return true if this node has had its token value set to something other than null.
        Returns:
        True if this node has had its token value set to something other than null.
      • jjtAddChild

        public void jjtAddChild​(Node n,
                                int i)
        Description copied from interface: Node
        This method tells the node to add its argument to the node's list of children.
        Specified by:
        jjtAddChild in interface Node
      • jjtClose

        public void jjtClose()
        Description copied from interface: Node
        This method is called after all the child nodes have been added.
        Specified by:
        jjtClose in interface Node
      • jjtGetChild

        public Node jjtGetChild​(int i)
        Description copied from interface: Node
        This method returns a child node. The children are numbered from zero, left to right.
        Specified by:
        jjtGetChild in interface Node
      • jjtGetNumChildren

        public int jjtGetNumChildren()
        Description copied from interface: Node
        Return the number of children the node has.
        Specified by:
        jjtGetNumChildren in interface Node
      • jjtOpen

        public void jjtOpen()
        Description copied from interface: Node
        This method is called after the node has been made the current node. It indicates that child nodes can now be added to it.
        Specified by:
        jjtOpen in interface Node
      • jjtSetParent

        public void jjtSetParent​(Node n)
        Description copied from interface: Node
        This pair of methods are used to inform the node of its parent.
        Specified by:
        jjtSetParent in interface Node
      • setConstant

        public void setConstant​(boolean flag)
        Set whether this node is a constant. In almost all cases this is statically determined when the parse tree is first parsed, and this method is not normally called. However, it can be useful to transform a parse tree, which can make parts of the parse tree constant which were not before. This method is provided for those transformations.
        Parameters:
        flag - If true, then this node is a constant.
      • setToken

        public void setToken​(Token token)
        Set the value of this node. This may be set during parsing, if the node is a constant node, or during evaluation of the expression.
        Parameters:
        token - The value of this node.
      • setType

        public void setType​(Type type)
        Set the type of this node. This may be set during parsing, if the node is a constant node, or during evaluation of the expression.
        Parameters:
        type - The type of this node.
      • toString

        public java.lang.String toString()
        Return the string value of this node. You can override these two methods in subclasses of RootNode to customize the way the node appears when the tree is dumped. If your output uses more than one line you should override toString(String), otherwise overriding toString() is probably all you need to do.
        Overrides:
        toString in class java.lang.Object
        Returns:
        The string value of this node.
      • toString

        public java.lang.String toString​(java.lang.String prefix)
        Return the prefix, followed by the string value of this node.
        Parameters:
        prefix - The prefix
        Returns:
        The prefix followed by the string value of this node.
      • visit

        public void visit​(ParseTreeVisitor visitor)
                   throws IllegalActionException
        Traverse this node with the given visitor. Subclasses should override this method to invoke the appropriate method in the visitor.
        Parameters:
        visitor - The visitor.
        Throws:
        IllegalActionException - Always thrown in this base class the visit() method is not implemented here.