Package ghidra.app.plugin.assembler.sleigh.tree

# Class AssemblyParseBranch

java.lang.Object
ghidra.app.plugin.assembler.sleigh.tree.AssemblyParseTreeNode
ghidra.app.plugin.assembler.sleigh.tree.AssemblyParseBranch

All Implemented Interfaces:
  `Iterable<AssemblyParseTreeNode>`

public class AssemblyParseBranch extends AssemblyParseTreeNode implements Iterable<AssemblyParseTreeNode>
A branch in a parse tree, corresponding to the application of a production

- ## Field Summary

  ### Fields inherited from class ghidra.app.plugin.assembler.sleigh.tree.AssemblyParseTreeNode

  `grammar, parent`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `AssemblyParseBranch(AssemblyGrammar grammar, AssemblyProduction prod)`
  Construct a branch from the given grammar and production

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addChild(AssemblyParseTreeNode child)`
  Prepend a child to this branch
  `boolean`
  `equals(Object obj)`
  `protected AssemblySymbol`
  `expects()`
  See what symbol is expected next
  `String`
  `generateString()`
  Generate the string that this node parsed
  `AssemblyProduction`
  `getProduction()`
  Get the production applied to create this branch
  `AssemblyParseTreeNode`
  `getSubstitution(int i)`
  Get the ith child, corresponding to the ith symbol from the RHS
  `List<AssemblyParseTreeNode>`
  `getSubstitutions()`
  Get the list of children, indexed by corresponding symbol from the RHS
  `AssemblyNonTerminal`
  `getSym()`
  Get the symbol for which this node is substituted
  `int`
  `hashCode()`
  `protected boolean`
  `isComplete()`
  Check if the branch is full
  `boolean`
  `isConstructor()`
  Check if this node yields a subconstructor resolution
  `Iterator<AssemblyParseTreeNode>`
  `iterator()`
  `protected void`
  `print(PrintStream out, String indent)`
  For debugging: Display the tree with the given indent
  `String`
  `toString()`

  ### Methods inherited from class ghidra.app.plugin.assembler.sleigh.tree.AssemblyParseTreeNode

  `getGrammar, getParent, isNumeric, print, setParent`

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface java.lang.Iterable

  `forEach, spliterator`

- ## Constructor Details

  - ### AssemblyParseBranch

    public AssemblyParseBranch(AssemblyGrammar grammar, AssemblyProduction prod)
    Construct a branch from the given grammar and production
    Parameters:
      `grammar` - the grammar containing the production
      `prod` - the production applied to create this branch

- ## Method Details

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`

  - ### equals

    public boolean equals(Object obj)
    Overrides:
      `equals` in class `Object`

  - ### addChild

    public void addChild(AssemblyParseTreeNode child)
    Prepend a child to this branch

    Because LR parsers produce rightmost derivations, they necessarily populate the branches right to left. During reduction, each child is popped from the stack, traversing them in reverse order. This method prepends children so that when reduction is complete, the children are aligned to the corresponding symbols from the RHS of the production.

    Parameters:
      `child` - the child

  - ### expects

    protected AssemblySymbol expects()
    See what symbol is expected next

    The child added next must be associated with the token expected next.

    Returns:
      the symbol

  - ### isComplete

    protected boolean isComplete()
    Check if the branch is full
    Returns:
      true if every symbol on the RHS has a corresponding child

  - ### getSym

    public AssemblyNonTerminal getSym()
    Description copied from class: `AssemblyParseTreeNode`
    Get the symbol for which this node is substituted

    For a branch, this is the LHS of the corresponding production. For a token, this is the terminal whose tokenizer matched it.

    Specified by:
      `getSym` in class `AssemblyParseTreeNode`
    Returns:
      the symbol

  - ### print

    protected void print(PrintStream out, String indent)
    Description copied from class: `AssemblyParseTreeNode`
    For debugging: Display the tree with the given indent
    Specified by:
      `print` in class `AssemblyParseTreeNode`
    Parameters:
      `out` - the stream
      `indent` - the indent

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### getProduction

    public AssemblyProduction getProduction()
    Get the production applied to create this branch
    Returns:

  - ### getSubstitutions

    public List<AssemblyParseTreeNode> getSubstitutions()
    Get the list of children, indexed by corresponding symbol from the RHS
    Returns:

  - ### iterator

    public Iterator<AssemblyParseTreeNode> iterator()
    Specified by:
      `iterator` in interface `Iterable<AssemblyParseTreeNode>`

  - ### getSubstitution

    public AssemblyParseTreeNode getSubstitution(int i)
    Get the ith child, corresponding to the ith symbol from the RHS
    Parameters:
      `i` - the position
    Returns:
      the child

  - ### isConstructor

    public boolean isConstructor()
    Description copied from class: `AssemblyParseTreeNode`
    Check if this node yields a subconstructor resolution
    Overrides:
      `isConstructor` in class `AssemblyParseTreeNode`
    Returns:
      true if this node yields a subconstructor resolution

  - ### generateString

    public String generateString()
    Description copied from class: `AssemblyParseTreeNode`
    Generate the string that this node parsed
    Specified by:
      `generateString` in class `AssemblyParseTreeNode`
    Returns:
      the string