Package org.tweetyproject.lp.asp.parser
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
ConstructorDescriptionSimpleNode
(int i) Constructs a newSimpleNode
with the specified node identifier.SimpleNode
(ASPParser p, int i) Constructs a newSimpleNode
with 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.void
Dumps 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.void
jjtAddChild
(Node n, int i) Adds a child node to this node at the specified index.void
jjtClose()
Called when this node is closed.jjtGetChild
(int i) Gets the child node at the specified index.int
Gets the number of children this node has.Gets the parent of this node in the AST.Gets the value associated with this node.void
jjtOpen()
Called when this node is opened.void
jjtSetParent
(Node n) Sets the parent of this node in the AST.void
jjtSetValue
(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 newSimpleNode
with the specified node identifier.- Parameters:
i
- The identifier for this node.
-
SimpleNode
Constructs a newSimpleNode
with 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:
jjtSetParent
in interfaceNode
- Parameters:
n
- The parent node.
-
jjtGetParent
Gets the parent of this node in the AST.- Specified by:
jjtGetParent
in interfaceNode
- Returns:
- The parent node.
-
jjtAddChild
Adds a child node to this node at the specified index.- Specified by:
jjtAddChild
in 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:
jjtGetChild
in 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:
jjtGetNumChildren
in 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.
-