Package ghidra.app.plugin.assembler.sleigh.parse

# Class AssemblyFirstFollow

java.lang.Object
ghidra.app.plugin.assembler.sleigh.parse.AssemblyFirstFollow

public class AssemblyFirstFollow extends Object
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

  Constructors
  Constructor
  Description
  `AssemblyFirstFollow(AbstractAssemblyGrammar<?,?> grammar)`
  Compute the first and follow sets for every non-terminal in the given grammar

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `computeFirsts()`
  Compute the first set for each non-terminal
  `protected void`
  `computeFollows()`
  Compute the follow set for each non-terminal
  `protected void`
  `computeNullable()`
  Compute the nullable set
  `Collection<AssemblyTerminal>`
  `getFirst(AssemblyNonTerminal nt)`
  Get the first set for a given non-terminal
  `Collection<AssemblyTerminal>`
  `getFollow(AssemblyNonTerminal nt)`
  Get the follow set for a given non-terminal
  `Collection<AssemblyNonTerminal>`
  `getNullable()`
  Get the nullable set
  `void`
  `print(PrintStream out)`
  For debugging, print out the computed sets to the given stream

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

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### AssemblyFirstFollow

    public AssemblyFirstFollow(AbstractAssemblyGrammar<?,?> grammar)
    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

    public Collection<AssemblyNonTerminal> getNullable()
    Get the nullable set

    That is the set of all non-terminals, which through some derivation, can produce epsilon.

    Returns:
      the set

  - ### getFirst

    public Collection<AssemblyTerminal> getFirst(AssemblyNonTerminal nt)
    Get the first set for a given non-terminal

    That 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

    public Collection<AssemblyTerminal> getFollow(AssemblyNonTerminal nt)
    Get the follow set for a given non-terminal

    That 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

    public void print(PrintStream out)
    For debugging, print out the computed sets to the given stream
    Parameters:
      `out` - the stream