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
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 Summary
ConstructorsConstructorDescriptionSimpleNode(int i) Constructs a newSimpleNodewith the specified node identifier.SimpleNode(ASPParser p, int i) Constructs a newSimpleNodewith the specified parser and node identifier. -
Method Summary
Modifier and TypeMethodDescriptionchildrenAccept(ASPParserVisitor visitor, Object data) Accepts the visitor and allows it to visit all the children of this node.voidDumps the structure of this node and its children, including their string representations.jjtAccept(ASPParserVisitor visitor, Object data) Accepts the visitor and allows it to visit this node.voidjjtAddChild(Node n, int i) Adds a child node to this node at the specified index.voidjjtClose()Called when this node is closed.jjtGetChild(int i) Gets the child node at the specified index.intGets the number of children this node has.Gets the parent of this node in the AST.Gets the value associated with this node.voidjjtOpen()Called when this node is opened.voidjjtSetParent(Node n) Sets the parent of this node in the AST.voidjjtSetValue(Object value) Sets the value associated with this node.toString()Returns a string representation of this node.Returns a string representation of this node with a specified prefix.
-
Constructor Details
-
SimpleNode
public SimpleNode(int i) Constructs a newSimpleNodewith the specified node identifier.- Parameters:
i- The identifier for this node.
-
SimpleNode
Constructs a newSimpleNodewith the specified parser and node identifier.- Parameters:
p- The parser that created this node.i- The identifier for this node.
-
-
Method Details
-
jjtOpen
-
jjtClose
-
jjtSetParent
Sets the parent of this node in the AST.- Specified by:
jjtSetParentin interfaceNode- Parameters:
n- The parent node.
-
jjtGetParent
Gets the parent of this node in the AST.- Specified by:
jjtGetParentin interfaceNode- Returns:
- The parent node.
-
jjtAddChild
Adds a child node to this node at the specified index.- Specified by:
jjtAddChildin interfaceNode- Parameters:
n- The child node to add.i- The index at which to add the child node.
-
jjtGetChild
Gets the child node at the specified index.- Specified by:
jjtGetChildin interfaceNode- 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:
jjtGetNumChildrenin interfaceNode- Returns:
- The number of children.
-
jjtSetValue
Sets the value associated with this node.- Parameters:
value- The value to associate with this node.
-
jjtGetValue
Gets the value associated with this node.- Returns:
- The value associated with this node.
-
jjtAccept
Accepts the visitor and allows it to visit this node. -
childrenAccept
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
-
toString
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
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.
-