Package quickparse.parsing.syntaxtree
Class SyntaxTree
java.lang.Object
quickparse.parsing.syntaxtree.SyntaxTree
- Direct Known Subclasses:
ConstructNode,TokenNode
public abstract class SyntaxTree
extends java.lang.Object
Represents a generic node of a syntax tree, which is the result of a parsing process. A syntax tree node represents a
A generic node of a syntax tree has four properties:
char sequence matched by a grammar rule.A generic node of a syntax tree has four properties:
- Source: the source
char sequencethat has been parsed; - Start index: the position in the Source at which the matched
char sequencestarts; - End index: the position in the Source at which the matched
char sequenceends; - Name: the name of the Construct or Token matched (i.e., the head symbol of the grammar rule matched);
-
Field Summary
-
Constructor Summary
Constructors Modifier Constructor Description protectedSyntaxTree(java.lang.CharSequence source, int start, int end, java.lang.String name) -
Method Summary
Modifier and Type Method Description abstract <STV extends SyntaxTreeVisitor>
STVaccept(STV syntaxTreeVisitor)Accepts aSyntaxTreeVisitorand uses it to visit this node and its eventually present children.booleanequals(java.lang.Object o)inthashCode()java.lang.StringtoString()Encodes this structure and its hierarchy in a string.abstract java.lang.StringtoString(int level)Encodes this structure and its hierarchy in a string.
-
Field Details
-
Constructor Details
-
SyntaxTree
protected SyntaxTree(java.lang.CharSequence source, int start, int end, java.lang.String name)
-
-
Method Details
-
equals
public boolean equals(java.lang.Object o)- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()Encodes this structure and its hierarchy in a string.- Overrides:
toStringin classjava.lang.Object- Returns:
- a
Stringobject - See Also:
Object.toString(),toString(int)
-
toString
public abstract java.lang.String toString(int level)Encodes this structure and its hierarchy in a string.- Parameters:
level- The deep level in the hierarchy.- Returns:
- a
Stringobject - See Also:
toString()
-
accept
Accepts aSyntaxTreeVisitorand uses it to visit this node and its eventually present children.- Type Parameters:
STV- the sub-type ofSyntaxTreeVisitor- Parameters:
syntaxTreeVisitor- thevisitorto accept- Returns:
- the same
visitorgiven as input
-