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
ConstructorsConstructorDescriptionAssemblyParseBranch(AssemblyGrammar grammar, AssemblyProduction prod) Construct a branch from the given grammar and production -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChild(AssemblyParseTreeNode child) Prepend a child to this branchbooleanprotected AssemblySymbolexpects()See what symbol is expected nextGenerate the string that this node parsedGet the production applied to create this branchgetSubstitution(int i) Get the ith child, corresponding to the ith symbol from the RHSGet the list of children, indexed by corresponding symbol from the RHSgetSym()Get the symbol for which this node is substitutedinthashCode()protected booleanCheck if the branch is fullbooleaniterator()protected voidprint(PrintStream out, String indent) For debugging: Display the tree with the given indenttoString()Methods inherited from class ghidra.app.plugin.assembler.sleigh.tree.AssemblyParseTreeNode
getGrammar, getParent, print, setParentMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
AssemblyParseBranch
Construct a branch from the given grammar and production- Parameters:
grammar- the grammar containing the productionprod- the production applied to create this branch
-
-
Method Details
-
hashCode
public int hashCode() -
equals
-
addChild
Prepend a child to this branchBecause 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
See what symbol is expected nextThe 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
Description copied from class:AssemblyParseTreeNodeGet the symbol for which this node is substitutedFor 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
Description copied from class:AssemblyParseTreeNodeFor debugging: Display the tree with the given indent- Specified by:
printin classAssemblyParseTreeNode- Parameters:
out- the streamindent- the indent
-
toString
-
getProduction
Get the production applied to create this branch- Returns:
-
getSubstitutions
Get the list of children, indexed by corresponding symbol from the RHS- Returns:
-
iterator
- Specified by:
iteratorin interfaceIterable<AssemblyParseTreeNode>
-
getSubstitution
Get the ith child, corresponding to the ith symbol from the RHS- Parameters:
i- the position- Returns:
- the child
-
isConstructor
public boolean isConstructor() -
generateString
Description copied from class:AssemblyParseTreeNodeGenerate the string that this node parsed- Specified by:
generateStringin classAssemblyParseTreeNode- Returns:
- the string
-