Class AssemblyParseActionGotoTable

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

public class AssemblyParseActionGotoTable extends Object
The Action/Goto table for a LALR(1) parser

This table is unconventional in that it permits a single cell to be populated by more than one action. Typically, such a situation would indicate ambiguity, or the need for a longer look-ahead value. Because we do not presume to control the grammar (which was automatically derived from another source), the parsing algorithm will simply branch, eventually trying both options.

  • Field Details

  • Constructor Details

    • AssemblyParseActionGotoTable

      public AssemblyParseActionGotoTable()
  • Method Details

    • put

      public boolean put(int fromState, AssemblySymbol next, AssemblyParseActionGotoTable.Action action)
      Add an action entry to the given cell
      Parameters:
      fromState - the state (row) in the table
      next - the symbol (column) in the table
      action - the entry to add to the cell
      Returns:
      true, if the given entry was not already present
    • putShift

      public boolean putShift(int fromState, AssemblyTerminal next, int newState)
      Add a SHIFT (Sn) entry to the given cell
      Parameters:
      fromState - the state (row) in the table
      next - the symbol (column) in the table
      newState - the state (n) after the shift is applied
      Returns:
      true, if the given entry was not already present
    • putReduce

      public boolean putReduce(int fromState, AssemblyTerminal next, AssemblyProduction prod)
      Add a REDUCE (Rn) entry to the given cell
      Parameters:
      fromState - the state (row) in the table
      next - the symbol (column) in the table
      prod - the production (having index n) associated with the reduction
      Returns:
      true, if the given entry was not already present
    • putGoto

      public boolean putGoto(int fromState, AssemblyNonTerminal next, int newState)
      Add a GOTO entry to the given cell
      Parameters:
      fromState - the state (row) in the table
      next - the symbol (column) in the table
      newState - the target state
      Returns:
      true, if the given entry was not already present
    • putAccept

      public boolean putAccept(int fromState)
      Add an ACCEPT entry for the given state at the end of input
      Parameters:
      fromState - the state (row) in the table
      Returns:
      true, if the state does not already accept on end of input
    • getExpected

      public Collection<AssemblyTerminal> getExpected(int fromState)
      Get the terminals that are expected, i.e., have entries for the given state
      Parameters:
      fromState - the state (row) in the table
      Returns:
      the collection of populated columns (terminals) for the given state
    • get

      Get all entries in a given cell
      Parameters:
      fromState - the state (row) in the table
      next - the symbol (column) in the table
      Returns:
      all action entries in the given cell