Interface MoveCheckable

All Known Subinterfaces:
TreeMember
All Known Implementing Classes:
ASTNode, Directive, EmptyTerminalNode, ExtendedContext, ExtendedTerminalNode, ParsableASTNode, StringNode, Tensor, UnparsableASTNode

public interface MoveCheckable
The move checkable interface provides a method for checking if the implementing node replaces a given node. This is helpful for the dynamic parse tree walker in determining if the current node it was looking at has moved or was replaced by an empty terminal node. All nodes that are not terminal nodes with tokens should implement this interface in the parse tree.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the node that this node replaced during a tree transformation.
    static boolean
    replaces(ParseTree oldNode, ParseTree newNode)
    Checks if any given parse tree node replaces another.
    void
    setPreviousNode(ParseTree previousNode)
    Allows the transformation phase to tell this node which node it replaces.
  • Method Details

    • getPreviousNode

      ParseTree getPreviousNode()
      Returns the node that this node replaced during a tree transformation.
      Returns:
      The replaced node
    • setPreviousNode

      void setPreviousNode(ParseTree previousNode)
      Allows the transformation phase to tell this node which node it replaces.
      Parameters:
      previousNode - The node to set as the previous node in this position in the parent's child array that this node replaces
    • replaces

      static boolean replaces(ParseTree oldNode, ParseTree newNode)
      Checks if any given parse tree node replaces another. If the nodes aren't the same, it checks recursively if the previous node of the new node maybe replaces the old node. This chain must end at some point or something is wrong.
      Parameters:
      oldNode - The node having maybe been replaced
      newNode - The node that could be the replacement
      Returns:
      true if the new node replaced the old node