Class AssemblyFirstFollow
java.lang.Object
ghidra.app.plugin.assembler.sleigh.parse.AssemblyFirstFollow
A class to compute the first and follow of every non-terminal in a grammar
See Alfred V. Aho, Monica S. Lam, Ravi Sethi, Jeffrey D. Ullman, Compilers: Principles, Techniques, & Tools. Bostom, MA: Pearson, 2007, pp. 220-2.
-
Constructor Summary
ConstructorDescriptionAssemblyFirstFollow
(AbstractAssemblyGrammar<?, ?> grammar) Compute the first and follow sets for every non-terminal in the given grammar -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Compute the first set for each non-terminalprotected void
Compute the follow set for each non-terminalprotected void
Compute the nullable setGet the first set for a given non-terminalGet the follow set for a given non-terminalGet the nullable setvoid
print
(PrintStream out) For debugging, print out the computed sets to the given stream
-
Constructor Details
-
AssemblyFirstFollow
Compute the first and follow sets for every non-terminal in the given grammar- Parameters:
grammar
- the grammar
-
-
Method Details
-
computeNullable
protected void computeNullable()Compute the nullable set -
computeFirsts
protected void computeFirsts()Compute the first set for each non-terminal -
computeFollows
protected void computeFollows()Compute the follow set for each non-terminal -
getNullable
Get the nullable setThat is the set of all non-terminals, which through some derivation, can produce epsilon.
- Returns:
- the set
-
getFirst
Get the first set for a given non-terminalThat is the set of all terminals, which through some derivation from the given non-terminal, can appear first in a sentential form.
- Parameters:
nt
- the non-terminal- Returns:
- the set
-
getFollow
Get the follow set for a given non-terminalThat is the set of all terminals, which through some derivation from the start symbol, can appear immediately after the given non-terminal in a sentential form.
- Parameters:
nt
- the non-terminal- Returns:
- the set
-
print
For debugging, print out the computed sets to the given stream- Parameters:
out
- the stream
-