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 root
production - the production of a rule node, else null
children - the children of a rule node, else empty
codepoint - the code point of a character node, else -1
from - the input position where the node starts
to - the input position after the node
cost - the sum of the rule costs in the tree, lower is preferred
ambiguous - 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 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 a Tree record class.
      Parameters:
      symbol - the value for the symbol record component
      production - the value for the production record component
      children - the value for the children record component
      codepoint - the value for the codepoint record component
      from - the value for the from record component
      to - the value for the to record component
      cost - the value for the cost record component
      ambiguous - the value for the ambiguous record component
  • Method Details

    • isRule

      public boolean isRule()
      Returns true if this is a rule node.
      Returns:
      true if the node has a production
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • symbol

      public Grammar.Symbol symbol()
      Returns the value of the symbol record component.
      Returns:
      the value of the symbol record component
    • production

      public Grammar.Production production()
      Returns the value of the production record component.
      Returns:
      the value of the production record component
    • children

      public List<Tree> children()
      Returns the value of the children record component.
      Returns:
      the value of the children record component
    • codepoint

      public int codepoint()
      Returns the value of the codepoint record component.
      Returns:
      the value of the codepoint record component
    • from

      public int from()
      Returns the value of the from record component.
      Returns:
      the value of the from record component
    • to

      public int to()
      Returns the value of the to record component.
      Returns:
      the value of the to record component
    • cost

      public int cost()
      Returns the value of the cost record component.
      Returns:
      the value of the cost record component
    • ambiguous

      public boolean ambiguous()
      Returns the value of the ambiguous record component.
      Returns:
      the value of the ambiguous record component