Interface Node

All Known Implementing Classes:
ASTConstant, ASTFunNode, ASTOpNode, ASTStart, ASTVarNode, SimpleNode

public interface Node
Interface defining a node in the parse-tree.

All AST nodes must implement this interface. It provides basic machinery for constructing the parent and child relationships between nodes.

  • Method Details

    • jjtOpen

      void jjtOpen()
      This method is called after the node has been made the current node. It indicates that child nodes can now be added to it.
    • jjtClose

      void jjtClose()
      This method is called after all the child nodes have been added.
    • jjtSetParent

      void jjtSetParent(Node n)
      Sets the parent node.
    • jjtGetParent

      Node jjtGetParent()
      Gets the parent node
    • jjtAddChild

      void jjtAddChild(Node n, int i)
      This method tells the node to add its argument to the node's list of children.
    • jjtGetChild

      Node jjtGetChild(int i)
      This method returns a child node. The children are numbered from zero, left to right.
    • jjtGetNumChildren

      int jjtGetNumChildren()
      Return the number of children the node has.
      Returns:
      the number of child nodes
    • jjtAccept

      Object jjtAccept(ParserVisitor visitor, Object data) throws JepException
      Accept the visitor.
      Throws:
      JepException
    • getValue

      Object getValue()
      Return the value associated with the node (if any).
      Returns:
      the value if an ASTConstant, ASTVarNode, null otherwise
    • getName

      String getName()
      Return the name associated with the node (if any).
      Returns:
      the name if an ASTVarNode, ASTFunNode, ASTOpNode, null otherwise
    • getPFMC

      Return the pfmc of a node (if any)
      Returns:
      the PostfixMathCommand for ASTFunNode and ASTOpNode, null otherwise
    • getOperator

      Operator getOperator()
      Return the operator associated with a Node (if any)
      Returns:
      The Operator for ASTOpNodes, null otherwise
    • getVar

      Variable getVar()
      Return the variable associated with a Node (if any)
      Returns:
      The Variable for ASTVarNodes, null otherwise
    • children

      Iterable<Node> children()
      Returns an Iterable object which can be used in a for/in loop.
       for(Node child:node.children()) {
        ...
       }
       
    • childIterator

      Iterator<Node> childIterator()
      Returns an Iterator which iterates over the children of the Node. The remove method is unsupported.
      Returns:
      a new Iterator
    • getId

      int getId()
      Returns the numeric id of a node type. 2 = ASTOpNode, 3 = ASTVarNode, 4 = ASTFunNode, 5 = ASTConstant
      See Also:
    • setHook

      Object setHook(Node.HookKey key, Object data)
      Set the data associated with a given key
      Parameters:
      key - defining the type of data
      data - actual object
      Returns:
      previous object associated with the key
    • getHook

      Object getHook(Node.HookKey key)
      Get the object associated with the key
      Parameters:
      key -
      Returns:
      the object associated with the key
    • hookKeys

      Get all the keys defined for this node.
      Returns:
      all the keys
    • removeHook

      Object removeHook(Node.HookKey key)
      Remove the key
      Parameters:
      key -
      Returns:
      the object which was associated with the key