Class SimpleNode

java.lang.Object
org.tweetyproject.lp.asp.parser.SimpleNode
All Implemented Interfaces:
Node
Direct Known Subclasses:
ASTAggregate, ASTAggrElement, ASTAggrElementList, ASTAggrFunc, ASTAnswerSet, ASTAriTerm, ASTArithop, ASTBinop, ASTBody, ASTBodyList, ASTBuiltInAtom, ASTChoice, ASTChoiceElement, ASTChoiceElementList, ASTClingoID, ASTClingoMeta, ASTDlvArithmeticID, ASTDlvID, ASTHead, ASTHeadElementsList, ASTID, ASTLiteral, ASTNAFLiteral, ASTNAFLiteralList, ASTNumber, ASTOpt, ASTOptElement, ASTOptElementList, ASTOptFunc, ASTProgram, ASTQuery, ASTRule, ASTRuleList, ASTString, ASTTerm, ASTTermList, ASTVar, ASTWeight

public class SimpleNode extends Object implements Node
A base class representing a node in the abstract syntax tree (AST) for the ASPParser.

This class implements the basic operations for managing the structure of the tree, including parent-child relationships and visitor acceptance. It provides a foundation that can be extended to represent specific types of nodes in the AST.

  • Constructor Details

    • SimpleNode

      public SimpleNode(int i)
      Constructs a new SimpleNode with the specified node identifier.
      Parameters:
      i - The identifier for this node.
    • SimpleNode

      public SimpleNode(ASPParser p, int i)
      Constructs a new SimpleNode with the specified parser and node identifier.
      Parameters:
      p - The parser that created this node.
      i - The identifier for this node.
  • Method Details

    • jjtOpen

      public void jjtOpen()
      Called when this node is opened. This method is meant to be overridden by subclasses if needed.
      Specified by:
      jjtOpen in interface Node
    • jjtClose

      public void jjtClose()
      Called when this node is closed. This method is meant to be overridden by subclasses if needed.
      Specified by:
      jjtClose in interface Node
    • jjtSetParent

      public void jjtSetParent(Node n)
      Sets the parent of this node in the AST.
      Specified by:
      jjtSetParent in interface Node
      Parameters:
      n - The parent node.
    • jjtGetParent

      public Node jjtGetParent()
      Gets the parent of this node in the AST.
      Specified by:
      jjtGetParent in interface Node
      Returns:
      The parent node.
    • jjtAddChild

      public void jjtAddChild(Node n, int i)
      Adds a child node to this node at the specified index.
      Specified by:
      jjtAddChild in interface Node
      Parameters:
      n - The child node to add.
      i - The index at which to add the child node.
    • jjtGetChild

      public Node jjtGetChild(int i)
      Gets the child node at the specified index.
      Specified by:
      jjtGetChild in interface Node
      Parameters:
      i - The index of the child node to retrieve.
      Returns:
      The child node at the specified index.
    • jjtGetNumChildren

      public int jjtGetNumChildren()
      Gets the number of children this node has.
      Specified by:
      jjtGetNumChildren in interface Node
      Returns:
      The number of children.
    • jjtSetValue

      public void jjtSetValue(Object value)
      Sets the value associated with this node.
      Parameters:
      value - The value to associate with this node.
    • jjtGetValue

      public Object jjtGetValue()
      Gets the value associated with this node.
      Returns:
      The value associated with this node.
    • jjtAccept

      public Object jjtAccept(ASPParserVisitor visitor, Object data)
      Accepts the visitor and allows it to visit this node.
      Specified by:
      jjtAccept in interface Node
      Parameters:
      visitor - The visitor object.
      data - Additional data for the visitor.
      Returns:
      The result of visiting this node.
    • childrenAccept

      public Object childrenAccept(ASPParserVisitor visitor, Object data)
      Accepts the visitor and allows it to visit all the children of this node.
      Parameters:
      visitor - The visitor object.
      data - Additional data for the visitor.
      Returns:
      The data passed to the visitor.
    • toString

      public String toString()
      Returns a string representation of this node.

      This method can be overridden in subclasses to customize the string representation.

      Overrides:
      toString in class Object
      Returns:
      A string representing this node.
    • toString

      public String toString(String prefix)
      Returns a string representation of this node with a specified prefix.

      This method can be overridden in subclasses to customize the string representation with a prefix.

      Parameters:
      prefix - The prefix to prepend to the string representation.
      Returns:
      A string representing this node with the specified prefix.
    • dump

      public void dump(String prefix)
      Dumps the structure of this node and its children, including their string representations.

      This method can be overridden in subclasses to customize how the node and its children are dumped.

      Parameters:
      prefix - The prefix to prepend to the string representation of each node.