Class AssemblyParseBranch
- java.lang.Object
-
- ghidra.app.plugin.assembler.sleigh.tree.AssemblyParseTreeNode
-
- ghidra.app.plugin.assembler.sleigh.tree.AssemblyParseBranch
-
- All Implemented Interfaces:
java.lang.Iterable<AssemblyParseTreeNode>
public class AssemblyParseBranch extends AssemblyParseTreeNode implements java.lang.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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddChild(AssemblyParseTreeNode child)Prepend a child to this branchbooleanequals(java.lang.Object obj)protected AssemblySymbolexpects()See what symbol is expected next The child added next must be associated with the token expected next.java.lang.StringgenerateString()Generate the string that this node parsedAssemblyProductiongetProduction()Get the production applied to create this branchAssemblyParseTreeNodegetSubstitution(int i)Get the ith child, corresponding to the ith symbol from the RHSjava.util.List<AssemblyParseTreeNode>getSubstitutions()Get the list of children, indexed by corresponding symbol from the RHSAssemblyNonTerminalgetSym()Get the symbol for which this node is substituted For a branch, this is the LHS of the corresponding production.inthashCode()protected booleanisComplete()Check if the branch is fullbooleanisConstructor()Check if this node yields a subconstructor resolutionjava.util.Iterator<AssemblyParseTreeNode>iterator()protected voidprint(java.io.PrintStream out, java.lang.String indent)For debugging: Display the tree with the given indentjava.lang.StringtoString()-
Methods inherited from class ghidra.app.plugin.assembler.sleigh.tree.AssemblyParseTreeNode
getGrammar, getParent, isNumeric, print, setParent
-
-
-
-
Constructor Detail
-
AssemblyParseBranch
public AssemblyParseBranch(AssemblyGrammar grammar, AssemblyProduction prod)
Construct a branch from the given grammar and production- Parameters:
grammar- the grammar containing the productionprod- the production applied to create this branch
-
-
Method Detail
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
addChild
public void addChild(AssemblyParseTreeNode child)
Prepend a child to this branch- Parameters:
child- the child 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.
-
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 corresonding child
-
getSym
public AssemblyNonTerminal getSym()
Description copied from class:AssemblyParseTreeNodeGet 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:
getSymin classAssemblyParseTreeNode- Returns:
- the symbol
-
print
protected void print(java.io.PrintStream out, java.lang.String indent)Description copied from class:AssemblyParseTreeNodeFor debugging: Display the tree with the given indent- Specified by:
printin classAssemblyParseTreeNode- Parameters:
out- the streamindent- the indent
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getProduction
public AssemblyProduction getProduction()
Get the production applied to create this branch- Returns:
-
getSubstitutions
public java.util.List<AssemblyParseTreeNode> getSubstitutions()
Get the list of children, indexed by corresponding symbol from the RHS- Returns:
-
iterator
public java.util.Iterator<AssemblyParseTreeNode> iterator()
- Specified by:
iteratorin interfacejava.lang.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:AssemblyParseTreeNodeCheck if this node yields a subconstructor resolution- Overrides:
isConstructorin classAssemblyParseTreeNode- Returns:
- true if this node yields a subconstructor resolution
-
generateString
public java.lang.String generateString()
Description copied from class:AssemblyParseTreeNodeGenerate the string that this node parsed- Specified by:
generateStringin classAssemblyParseTreeNode- Returns:
- the string
-
-