Class ExtendedTerminalNode

java.lang.Object
org.antlr.v4.runtime.tree.TerminalNodeImpl
io.github.douira.glsl_transformer.tree.ExtendedTerminalNode
All Implemented Interfaces:
MoveCheckable, TreeMember, ParseTree, SyntaxTree, TerminalNode, Tree
Direct Known Subclasses:
EmptyTerminalNode, TerminalCSTNode

public class ExtendedTerminalNode extends TerminalNodeImpl implements TreeMember
The extended terminal node has additional functionality over the regular terminal node. Most importantly, it implements the functionality required to be a tree member.
  • Constructor Details

    • ExtendedTerminalNode

      public ExtendedTerminalNode(ParserRuleContext parent, Token symbol)
      Creates a new extended terminal node with a parent node and a token as the symbol.
      Parameters:
      parent - The parent node. This is a parser rule context because the parser passes a parser rule context when it creates new terminal nodes.
      symbol - The token to contain with this terminal node
    • ExtendedTerminalNode

      public ExtendedTerminalNode(ExtendedContext parent)
      Creates a null-token terminal node that has an extended context as a parent. This should only be used when the node is a placeholder for something. It will not be printed since the token is null.
      Parameters:
      parent - The parent node
    • ExtendedTerminalNode

      public ExtendedTerminalNode()
      Creates a null-token and parentless terminal node. This is to be used when the node is a placeholder and it will be added to a parse tree node. Adding it as a child using a node's addChild method will attach it as a parent.
  • Method Details

    • getParent

      public ExtendedContext getParent()
      Override to make type more specific
      Specified by:
      getParent in interface ParseTree
      Specified by:
      getParent in interface Tree
      Specified by:
      getParent in interface TreeMember
      Overrides:
      getParent in class TerminalNodeImpl
    • processRemoval

      public void processRemoval()
      Description copied from interface: TreeMember
      Omits the tokens this node encompasses from the next local root. For terminal nodes this is always at least the parent's local root. Other nodes may be their own local root.
      Specified by:
      processRemoval in interface TreeMember
    • getPreviousNode

      public ParseTree getPreviousNode()
      Description copied from interface: MoveCheckable
      Returns the node that this node replaced during a tree transformation.
      Specified by:
      getPreviousNode in interface MoveCheckable
      Returns:
      The replaced node
    • setPreviousNode

      public void setPreviousNode(ParseTree previousNode)
      Description copied from interface: MoveCheckable
      Allows the transformation phase to tell this node which node it replaces.
      Specified by:
      setPreviousNode in interface MoveCheckable
      Parameters:
      previousNode - The node to set as the previous node in this position in the parent's child array that this node replaces