Record Class Tree
java.lang.Object
java.lang.Record
org.libxmq.imp.ixml.earley.Tree
- Record Components:
symbol- the symbol in the parent production, null for the rootproduction- the production of a rule node, else nullchildren- the children of a rule node, else emptycodepoint- the code point of a character node, else -1from- the input position where the node startsto- the input position after the nodecost- the sum of the rule costs in the tree, lower is preferredambiguous- true if another tree with the same cost was possible
public record Tree(Grammar.Symbol symbol, Grammar.Production production, List<Tree> children, int codepoint, int from, int to, int cost, boolean ambiguous)
extends Record
A node in the parse tree chosen by TreeBuilder.
- A rule node has the production used and one child per symbol of it.
- A character node is a terminal that matched the code point.
- A zero width node is an insertion or a not.
The symbol is the one in the parent production that this node matched,
for a rule node the Call with its mark and alias. The root has no symbol.
-
Constructor Summary
ConstructorsConstructorDescriptionTree(Grammar.Symbol symbol, Grammar.Production production, List<Tree> children, int codepoint, int from, int to, int cost, boolean ambiguous) Creates an instance of aTreerecord class. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the value of theambiguousrecord component.children()Returns the value of thechildrenrecord component.intReturns the value of thecodepointrecord component.intcost()Returns the value of thecostrecord component.final booleanIndicates whether some other object is "equal to" this one.intfrom()Returns the value of thefromrecord component.final inthashCode()Returns a hash code value for this object.booleanisRule()Returns true if this is a rule node.Returns the value of theproductionrecord component.symbol()Returns the value of thesymbolrecord component.intto()Returns the value of thetorecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Tree
public Tree(Grammar.Symbol symbol, Grammar.Production production, List<Tree> children, int codepoint, int from, int to, int cost, boolean ambiguous) Creates an instance of aTreerecord class.- Parameters:
symbol- the value for thesymbolrecord componentproduction- the value for theproductionrecord componentchildren- the value for thechildrenrecord componentcodepoint- the value for thecodepointrecord componentfrom- the value for thefromrecord componentto- the value for thetorecord componentcost- the value for thecostrecord componentambiguous- the value for theambiguousrecord component
-
-
Method Details
-
isRule
public boolean isRule()Returns true if this is a rule node.- Returns:
- true if the node has a production
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
symbol
-
production
Returns the value of theproductionrecord component.- Returns:
- the value of the
productionrecord component
-
children
-
codepoint
-
from
-
to
-
cost
-
ambiguous
-