Class AssemblyGrammar
java.lang.Object
ghidra.app.plugin.assembler.sleigh.grammars.AbstractAssemblyGrammar<AssemblyNonTerminal,AssemblyProduction>
ghidra.app.plugin.assembler.sleigh.grammars.AssemblyGrammar
- All Implemented Interfaces:
Iterable<AssemblyProduction>
public class AssemblyGrammar
extends AbstractAssemblyGrammar<AssemblyNonTerminal,AssemblyProduction>
Defines a context free grammar, used to parse mnemonic assembly instructions
This stores the CFG and the associated semantics for each production. It also has mechanisms for tracking "purely recursive" productions. These are productions of the form I => I, and they necessarily create ambiguity. Thus, when constructing a parser, it is useful to identify them early.
-
Field Summary
Modifier and TypeFieldDescriptionprotected final AbstractAssemblyResolutionFactory
<?, ?> protected final Map
<String, AssemblyProduction> protected final Map
<Constructor, AssemblyConstructorSemantic> protected final Map
<AssemblyProduction, Map<Constructor, AssemblyConstructorSemantic>> Fields inherited from class ghidra.app.plugin.assembler.sleigh.grammars.AbstractAssemblyGrammar
nonterminals, prodList, productions, startName, symbols, terminals
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a production to the grammarvoid
addProduction
(AssemblyNonTerminal lhs, AssemblySentential<AssemblyNonTerminal> rhs, DisjointPattern pattern, Constructor cons, List<Integer> indices) Add a production associated with a SLEIGH constructor semanticvoid
Add all the productions of a given grammar to this oneObtain, if present, the purely recursive production having the given LHSGet all productions in the grammar that are purely recursivegetSemantic
(Constructor cons) Get the semantics associated with a given productionprotected AssemblyProduction
Because a subclass may have a different type of production, it must provide a mechanism for constructing an appropriate production given just the LHS and RHS.Methods inherited from class ghidra.app.plugin.assembler.sleigh.grammars.AbstractAssemblyGrammar
addProduction, contains, getNonTerminal, getStart, getStartName, getTerminal, isPureRecursive, iterator, nonTerminals, print, productionsOf, productionsOf, setStart, setStartName, terminals, verify
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
factory
-
semanticsByProduction
protected final Map<AssemblyProduction,Map<Constructor, semanticsByProductionAssemblyConstructorSemantic>> -
semanticsByConstructor
-
pureRecursive
-
-
Constructor Details
-
AssemblyGrammar
-
-
Method Details
-
newProduction
protected AssemblyProduction newProduction(AssemblyNonTerminal lhs, AssemblySentential<AssemblyNonTerminal> rhs) Description copied from class:AbstractAssemblyGrammar
Because a subclass may have a different type of production, it must provide a mechanism for constructing an appropriate production given just the LHS and RHS.- Specified by:
newProduction
in classAbstractAssemblyGrammar<AssemblyNonTerminal,
AssemblyProduction> - Parameters:
lhs
- the left-hand side of the productionrhs
- the right-hand side of the production- Returns:
- the constructed production
-
addProduction
Description copied from class:AbstractAssemblyGrammar
Add a production to the grammar- Overrides:
addProduction
in classAbstractAssemblyGrammar<AssemblyNonTerminal,
AssemblyProduction> - Parameters:
prod
- the production
-
addProduction
public void addProduction(AssemblyNonTerminal lhs, AssemblySentential<AssemblyNonTerminal> rhs, DisjointPattern pattern, Constructor cons, List<Integer> indices) Add a production associated with a SLEIGH constructor semantic- Parameters:
lhs
- the left-hand siderhs
- the right-hand sidepattern
- the pattern associated with the constructorcons
- the SLEIGH constructorindices
- the indices of RHS non-terminals that represent an operand in the constructor
-
getSemantics
Get the semantics associated with a given production- Parameters:
prod
- the production- Returns:
- all semantics associated with the given production
-
getSemantic
-
combine
Description copied from class:AbstractAssemblyGrammar
Add all the productions of a given grammar to this one- Overrides:
combine
in classAbstractAssemblyGrammar<AssemblyNonTerminal,
AssemblyProduction> - Parameters:
that
- the grammar whose productions to add
-
getPureRecursive
Get all productions in the grammar that are purely recursive- Returns:
-
getPureRecursion
Obtain, if present, the purely recursive production having the given LHS- Parameters:
lhs
- the left-hand side- Returns:
- the desired production, or null
-