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 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

      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

      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