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 TypeMethodDescriptionReturns the node that this node replaced during a tree transformation.static booleanChecks if any given parse tree node replaces another.voidsetPreviousNode(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
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
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 replacednewNode- The node that could be the replacement- Returns:
trueif the new node replaced the old node
-